[plt-scheme] ffi equivalent of array in struct

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Tue Apr 25 02:40:41 EDT 2006

> This is not a problem that should be solved by a macro.  (And once you 
> start going that way, it's a classic trap that keeps you from doing the 
> simple thing.)  If all you had was define-cstruct, then you would need a 
> macro to do generate things like
>
>  (define-cstruct _Foo [x1 _int] [x2 _int] ... [x100 _int])
>
> But in this case, make-cstruct-type is available, and can do something 
> equivalent to that, with no need for macros at all.  All you need is to 
> create a list of 100 _int values, like
>
>  (build-list 100 (lambda (i) _int))

*smack on head* I'm so silly sometimes, and I'm glad someone's making sure 
to keep me from doing too much damage.


Posted on the users mailing list.