guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: packed structures usefulness


From: Ludovic Courtès
Subject: Re: packed structures usefulness
Date: Fri, 02 Nov 2007 11:42:02 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Hi,

"Marco Maggi" <address@hidden> writes:

>   I am in the position to add, with relatively
> little effort, a module to GEE to handle
> packed data structures. This means that,
> as example of a still unimplemented API, doing:
>
> (define *triplet*
>   (make-gstruct-type '((one . int)
>              (two . double)
>              (three . (int64 . 3)))))
>
> (define S (make-gstruct *triplet*))
>
> (set! (one S) 123)
> (set! (two S) 1.2)
> (set! (three S 2) 44)
>
> one can define a SMOB whose internal
> representation is equivalent to the C language
> type:
>
> struct triplet {
>   int one;
>   double two;
>   int64_t three[3];
> }; 
>
> and then access its fields.
>
> Remembering that, IMHO, there is no way to
> mimic the C structure fields alignment from a
> Scheme level inteface, I wonder if such a module
> would be useful or not.

I'm not convinced.  :-)

Most "modern" C libraries use opaque types, typically pointers to
structs, so you rarely get to access the fields directly.

(BTW, note that Guile's structs have a specified C layout in terms of
`SCM' fields, though.)

Thanks,
Ludovic.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]