[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: packed structures usefulness
From: |
Marco Maggi |
Subject: |
Re: packed structures usefulness |
Date: |
Tue, 6 Nov 2007 21:53:31 +0100 |
"address@hidden" wrote:
> "Marco Maggi" writes:
>> 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.
"Thien-Thi Nguyen" wrote:
>> I wonder if such a module would be useful or not.
>
>i think so, if it can handle char, short, and
>bitfields. presuming it has length and signedness
>checks, it would be nice to have those
>configurable, as well (ie., error vs warn vs
>auto-normalize).
"Neil Jerram" wrote:
>I implemented something like this for an
>application whose basic control mechanism is
>message passing using flat C structures ("flat" =>
>no pointers), because I wanted to be able to build
>and manipulate the structures from Scheme.
>[...]
>So to answer your actual question: yes, I think
>this is useful, but only in a rather specific kind
>of application context.
(Thanks (expt 10 3)). I have decided to enqueue it
in my to do list. I will write it as an
independent module, but with the specific purpose
of having a tool to write an interface to Ralf
Engelschall's OSSP MM: a library for shared memory
usage [1].
It is a small project that I started one year ago
and then put aside, because I had no clear idea
about how to define a "mask" of data fields
through which "look" at the allocated shared
memory.
I will use (sub)SMOBs and define the struct format
from the Scheme level only, I do not want to make
it a way to "see" a foreign C struct from the
Scheme level. There should be no problem to
register an assertion function and set/get
conversion functions.
But... ahem... bitfields? These are *boring* to
code... ;-)
[1] <http://www.ossp.org/pkg/lib/mm/>
--
Marco Maggi
"Now feel the funk blast!"
Rage Against the Machine - "Calm like a bomb"