[M3devel] ADR is *too* unsafe..
Jay K
jay.krell at cornell.edu
Wed Jun 2 17:48:56 CEST 2010
for example:
/dev2/cm3/m3-libs/m3core/src/unix/Common/Ustat.i3
TYPE
struct_stat = RECORD
(*
This MUST match UstatC.c.
Sorted by size, then by name; make everything LONGINT if possible, else INTEGER;
Limit on LONGINT is compatibility with existing Modula-3 code. Blowing up the sizes
larger than necessary is a slight deoptimization for the sake of simplicity and
commonality. *)
st_dev : LONGINT; (* Utypes.dev_t *)
st_ino : LONGINT; (* Utypes.ino_t *)
st_mtime : LONGINT; (* not time_t *)
st_nlink : LONGINT; (* Utypes.nlink_t *)
st_rdev : LONGINT; (* Utypes.dev_t *)
st_size : LONGINT; (* Utypes.off_t *)
st_flags : INTEGER; (* only on some platforms: Darwin, FreeBSD, OpenBSD, NetBSD, else 0 *)
st_gid : INTEGER; (* Utypes.gid_t *)
st_mode : INTEGER; (* Utypes.mode_t *)
st_uid : INTEGER; (* Utypes.uid_t *)
END;
struct_stat_star = UNTRACED REF struct_stat;
/dev2/cm3/m3-libs/m3core/src/unix/Common/UstatC.c
struct _m3_stat_t
{
/*
This MUST match Ustat.i3.
Sorted by size, then by name; make everything LONGINT if possible, else INTEGER;
Limit on LONGINT is compatibility with existing Modula-3 code. Blowing up the sizes
larger than necessary is a slight deoptimization for the sake of simplicity and
commonality.
"st_" prefix is omitted from the names in case they are macros, which does happen */
LONGINT dev;
LONGINT ino;
LONGINT mtime;
LONGINT nlink;
LONGINT rdev;
LONGINT size;
INTEGER flags;
INTEGER gid;
INTEGER mode;
INTEGER uid;
};
We used to clone headers through careful reading of multiple platform-specified #ifdefed-to-heck headers.
Now we clone them through easier reading of simple platform-independent #ifdef-free headers.
This is progress, it is easier for programmer to get it right and eyeball it and believe it is right.
But what should actually happen is compiler should generate Ustat.h from Ustat.i3.
The only mechanical duplicate that should occur, should be done by programs.
Comments that say "must match" are the signature of a compromise, that I made.
Similarly but less obviously how, Uconstants.c should be generated.
Given a list of symbols, the C code should just #ifdef foo const bar__foo = foo #endif tc.
Such generation should happen every time one builds.
Not just once and check them in and hope they stay current (as many folks are prone to, not necessarily present company)
- Jay
----------------------------------------
> To: jay.krell at cornell.edu
> CC: m3devel at elegosoft.com
> Subject: Re: [M3devel] ADR is *too* unsafe..
> Date: Wed, 2 Jun 2010 08:37:04 -0700
> From: mika at async.async.caltech.edu
>
> Jay K writes:
>>
>>Cool.
>>
>>=A0> but also modified the front-end of the compiler to generate C
>>header files for Modula-3 interface files.
>>=A0> This way=2C procedures exported via a
>>Modula-3 interface can be called directly from C using "module dot method"
>>syntax
>>
>>
>>I've been wanting that. :)
>
> What do you want it to do?
>
> My Modula-Scheme system does this for Scheme already.. in fact it's
> probably doing something even more complicated than what you want... hmm.
> I've been meaning to check it in somewhere for a long time.
>
> Mika
>
>>
>>=A0> "CVAR"
>>
>>Sounds like a good small change?
>>
>>=A0- Jay
>>
>>
> ...
More information about the M3devel
mailing list