[M3devel] ADR is *too* unsafe..

Mika Nystrom mika at async.async.caltech.edu
Wed Jun 2 18:08:11 CEST 2010


That shouldn't be hard, provided you're willing to write some
Scheme code :-)

     Mika

Jay K writes:
>
>for example:
>
>/dev2/cm3/m3-libs/m3core/src/unix/Common/Ustat.i3
>
>TYPE
>=A0 struct_stat =3D RECORD
>(*
>This MUST match UstatC.c.
>
>Sorted by size=2C then by name=3B make everything LONGINT if possible=2C el=
>se INTEGER=3B
>Limit on LONGINT is compatibility with existing Modula-3 code. Blowing up t=
>he sizes
>larger than necessary is a slight deoptimization for the sake of simplicity=
> and
>commonality. *)
>=A0=A0=A0 st_dev=A0=A0 : LONGINT=3B (* Utypes.dev_t=A0=A0 *)
>=A0=A0=A0 st_ino=A0=A0 : LONGINT=3B (* Utypes.ino_t=A0=A0 *)
>=A0=A0=A0 st_mtime : LONGINT=3B (* not time_t=A0=A0=A0=A0 *)
>=A0=A0=A0 st_nlink : LONGINT=3B (* Utypes.nlink_t *)
>=A0=A0=A0 st_rdev=A0 : LONGINT=3B (* Utypes.dev_t=A0=A0 *)
>=A0=A0=A0 st_size=A0 : LONGINT=3B (* Utypes.off_t=A0=A0 *)
>=A0=A0=A0 st_flags : INTEGER=3B (* only on some platforms: Darwin=2C FreeBS=
>D=2C OpenBSD=2C NetBSD=2C else 0 *)
>=A0=A0=A0 st_gid=A0=A0 : INTEGER=3B (* Utypes.gid_t=A0=A0 *)
>=A0=A0=A0 st_mode=A0 : INTEGER=3B (* Utypes.mode_t=A0 *)
>=A0=A0=A0 st_uid=A0=A0 : INTEGER=3B (* Utypes.uid_t=A0=A0 *)
>=A0 END=3B
>=A0 struct_stat_star =3D UNTRACED REF struct_stat=3B
>
>
>/dev2/cm3/m3-libs/m3core/src/unix/Common/UstatC.c=20
>
>struct _m3_stat_t
>{
>/*
>This MUST match Ustat.i3.
>
>Sorted by size=2C then by name=3B make everything LONGINT if possible=2C el=
>se INTEGER=3B
>Limit on LONGINT is compatibility with existing Modula-3 code. Blowing up t=
>he sizes
>larger than necessary is a slight deoptimization for the sake of simplicity=
> and
>commonality.
>=A0=A0=A0=20
>"st_" prefix is omitted from the names in case they are macros=2C which doe=
>s happen */
>
>=A0=A0=A0 LONGINT dev=3B
>=A0=A0=A0 LONGINT ino=3B
>=A0=A0=A0 LONGINT mtime=3B
>=A0=A0=A0 LONGINT nlink=3B
>=A0=A0=A0 LONGINT rdev=3B
>=A0=A0=A0 LONGINT size=3B
>=A0=A0=A0 INTEGER flags=3B
>=A0=A0=A0 INTEGER gid=3B
>=A0=A0=A0 INTEGER mode=3B
>=A0=A0=A0 INTEGER uid=3B
>}=3B
>
>
>We used to clone headers through careful reading of multiple platform-speci=
>fied #ifdefed-to-heck headers.
>Now we clone them through easier reading of simple platform-independent #if=
>def-free headers.
>This is progress=2C 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 Us=
>tat.i3.
>The only mechanical duplicate that should occur=2C should be done by progra=
>ms.
>Comments that say "must match" are the signature of a compromise=2C that I =
>made.
>
>
>Similarly but less obviously how=2C Uconstants.c should be generated.
>Given a list of symbols=2C the C code should just #ifdef foo const bar__foo=
> =3D foo #endif tc.
>
>
>Such generation should happen every time one builds.
>=A0Not just once and check them in and hope they stay current (as many folk=
>s are prone to=2C not necessarily present company)
>
>
>=A0- Jay
>
>----------------------------------------
>> To: jay.krell at cornell.edu
>> CC: m3devel at elegosoft.com
>> Subject: Re: [M3devel] ADR is *too* unsafe..
>> Date: Wed=2C 2 Jun 2010 08:37:04 -0700
>> From: mika at async.async.caltech.edu
>>
>> Jay K writes:
>>>
>>>Cool.
>>>
>>>=3DA0> but also modified the front-end of the compiler to generate C
>>>header files for Modula-3 interface files.
>>>=3DA0> This way=3D2C 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
>>
>>>
>>>=3DA0> "CVAR"
>>>
>>>Sounds like a good small change?
>>>
>>>=3DA0- Jay
>>>
>>>
>> ...
> 		 	   		  =



More information about the M3devel mailing list