On Fri, Sep 9, 2011 at 2:50 AM, Jean-Claude Beaudoin jean.claude.beaudoin@gmail.com wrote:
Has anyone of you given a look at what Franz did on this very subject for their Allegro 8.2 (http://www.franz.com/support/documentation/8.2/doc/contents.htm#foreign-func...) (http://www.franz.com/support/documentation/8.2/doc/foreign-functions.htm#str...) They added a keyword argument to their def-foreign-call form and also added a global variable ff:*pass-structs-by-value* that controls the default value of the keyword arg.
What do you think of that?
Cheers,
Jean-Claude Beaudoin
I like their approach, and I think we should follow a similar path with the argument passing determined by declaration (:pointer for call by reference and the stucture type name for call by value), but I would be a little stronger on the default behavior. I would make an "notification-interpretation" global variable that determines what the compiler will do (notification and possible conversion) if it encounters a structure name declaration to a function argument or return. Options could be (:warn :pointer), (:error), (:accept :pointer), (:accept :value), etc., :value meaning call by value and :pointer meaning call by reference. The current CFFI has (:accept :pointer). The default on release could be (:warn :pointer) if FSBV is not loaded, and (:warn :value) if it is. After a while (succeeding release, say), we should change this to (:warn :pointer) and (:accept :value), respectively. Ultimately, I think it should be (:error) and (:accept :value) respectively.
Liam