Lisp HUG Maillist Archive

fli:with-foreign-slots slots-and-options ... ?

Hi list,

The docs for FLI:WITH-FOREIGN-SLOTS doesn't mention it, but 
the auto-complete hints that options could be passed through 
the list of slots to FLI:FOREIGN-SLOT-VALUE (i.e. it says 
"SLOTS-AND-OPTIONS" rather than just "SLOT-NAMES"). But I 
can't get it to work.

I have a foreign structure with structure slots such that I 
need to pass :COPY-FOREIGN-OBJECT NIL to 
FLI:FOREIGN-SLOT-VALUE. It would be nice if I could pass the 
same option to the expansion of FLI:WITH-FOREIGN-SLOTS; is 
this in fact possible?

Cheers,

John :^P

P.S. FWIW, I have made my own macro called -> for (possibly 
nested) foreign slot references:

(defmacro -> (obj &rest slots)
   (if slots
       `(-> (fli:foreign-slot-value ,obj
                                    ,(car slots)
                                    :copy-foreign-object nil)
	   ,@(cdr slots))
       obj))
--
John Pallister
john@synchromesh.com


Re: fli:with-foreign-slots slots-and-options ... ?

OK, I've figured it out: each slot name can be a form that 
matches the lambda list

   (binding slot-name &key (:copy-foreign-object :error))

Which also allows you to rename unexported slot names from 
other packages.

It would be nice if the documentation for WITH-FOREIGN-SLOTS 
could be updated to reflect this.

Cheers,

John :^P

John Pallister wrote:
> 
> Hi list,
> 
> The docs for FLI:WITH-FOREIGN-SLOTS doesn't mention it, but the 
> auto-complete hints that options could be passed through the list of 
> slots to FLI:FOREIGN-SLOT-VALUE (i.e. it says "SLOTS-AND-OPTIONS" rather 
> than just "SLOT-NAMES"). But I can't get it to work.
> 
> I have a foreign structure with structure slots such that I need to pass 
> :COPY-FOREIGN-OBJECT NIL to FLI:FOREIGN-SLOT-VALUE. It would be nice if 
> I could pass the same option to the expansion of FLI:WITH-FOREIGN-SLOTS; 
> is this in fact possible?
> 
> Cheers,
> 
> John :^P
> 
> P.S. FWIW, I have made my own macro called -> for (possibly nested) 
> foreign slot references:
> 
> (defmacro -> (obj &rest slots)
>   (if slots
>       `(-> (fli:foreign-slot-value ,obj
>                                    ,(car slots)
>                                    :copy-foreign-object nil)
>        ,@(cdr slots))
>       obj))
> -- 
> John Pallister
> john@synchromesh.com
> 

-- 
John Pallister
john@synchromesh.com


Updated at: 2020-12-10 08:45 UTC