[cffi-devel] Re: translate-type-from-foreign

Luis Oliveira luismbo at gmail.com
Sun Apr 15 21:09:20 UTC 2007


Sean <rosssd at gmail.com> writes:
> What does the :simple-parser slot-option do?

The (:simple-parser foo) in (define-foreign-type foo-type ...) expands to:

  (define-parse-method foo ()
    (make-instance 'foo-type))


> I'm just wondering does this provide any value other than the ability to
> define translations on c-structs? Not that this is the wrong way to do
> it but it does seem like a large amount of work to enable translations.

I agree that it's unfortunate that you need to define an extra type to
wrap the struct type and add translations, which is why I propose a
:CLASS option to defcstruct that would do that for you.

The big change in cffi-newtypes is that type translators work with
objects of type CFFI::FOREIGN-TYPE instead of symbols naming types.  To
answer your question, I do think this provides a lot of value.
Inheritance is more intituite (plain CLOS) and you handle type
arguments, e.g. (:string :encoding foo), which you can save as slots in
your type instance, much more easily.

-- 
Luís Oliveira
http://student.dei.uc.pt/~lmoliv/




More information about the cffi-devel mailing list