[M3devel] declaring a type's existance but not enough to instantiate it?

Jay jay.krell at cornell.edu
Mon Jan 12 10:56:43 CET 2009


Yes, generating the headers is viable.
I thought I mentioned that a few times.
They could be generated in any build "that can".  i.e. a native build, that has a working C development system  and checked against the checked in ones.
 So then porting is:   copy the generator to new system, run it, copy results back, proceed 
 Maybe a good compromise.  Not good for "embedded systems", but heck, is there any such thing  any longer? Doesn't everything have megs of RAM and gigs of persistant storage? :)
You don't need Scheme.
Just Quake + compiling and running C code.
Assuming a native build system.
I've done stuff in cross build systems like:
typedef struct foo_t {int i; int j; } foo_t;
extern const int xi = offsetof(foo_t, i);
 
compile that, and read the value of xi out of the .obj file.
 
 The .obj file reader was written in Perl. :) 
  (Python not available.)
 but to do that here, I'd have to support multiple .obj file formats.
 
 - Jay> To: jay.krell at cornell.edu> Date: Mon, 12 Jan 2009 01:34:24 -0800> From: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] declaring a type's existance but not enough to instantiate it?> > > You present it as a true tragic Dilemma.> > But isn't there a Third Way---to wit, can't you "Ask the Computer"> to do the work for you?> > Generate the code somehow... Parsing the C headers is an obvious> way but there may be others that are simpler, such as writing a> Modula-3 program to generate the cloned M3 headers, sorry, interfaces.> > If I had to do this I would use my Scheme interpreter that's coded> in Modula-3 to write a Scheme program to generate the headers. This> program could pull whatever tricks are deemed necessary and suitable,> down to the point of generating and compiling and running C programs> as necessary (or parsing C code, or reading tea leaves). But the> end result would be a set of interfaces written in "Pure Modula-3".> The process of running the header generator would also have very> few dependencies on anything outside the M3 distribution.> > Mika> > Jay writes:> >--_6117a048-9185-4c03-badb-ef8f93402268_> >Content-Type: text/plain; charset="iso-8859-1"> >Content-Transfer-Encoding: quoted-printable> >> >> >This is what you "have to" chose between.> >Header cloning or C code (and C headers).> >=20> >CONST or VAR (or functions?)> >=20> >I'm going to likely make the Uerror change tonight.> >You can still veto it (er=2C vote against it :) )> >=20> >Possibly some convuluted C (enum/#undef)=2C or splitting the Modula-3> >at boundaries that weren't previously believed "natural".> >(See how SetupHandlers is ~two lines in Modula-3 and the rest in C=3B> >this is partly out of ignorance. I don't know how to write those> >two lines in C=3B and laziness=2C I didn't look into how).> >=20> >=20> >=20> >Remember I'm still staying away from mainstream platforms=2C> >so the value isn't what it might appear to be=2C but it is "stage setting"=> >=2C> >and the show might go on. :)> >=20> >=20> >Also=2C the dilemna does get more difficult now=2C with the little C header=> > cloning that remains.> >=20> >For example=2C look at Upthreads.i3.> >Mainly=2C look at function prototypes.> >Constants and types are "known problems".> >Prototypes are gray. They actually tend to be portable.> >=20> >For example:> >=20> >TYPE pid_t =3D INTEGER=3B> ><*EXTERNAL "m3_getpid*> PROCEDURE getpid():pid_t=3B> >=20> >or leave it alone?> >getpid is probably the worst example.> >It is so very portable declared in Modula-3.> >But still=2C imagine pid_t might be 16bits or 32 or 64.> >Writing a wrapper is more portable -- as long as the pid isn't stuff into s=> >ome record that the system defines.> >=20> >=20> >Again=2C Upthreads.i3.> >Would you like to see it reduced=2C or left alone?> >Only deal with the types and initializers=2C or also the prototypes?> >You know=2C I could write a little portable layer=2C where all the types ar=> >e pointers=2C always null initialized.> >It would buy /some/ portability=2C and cost some.> >=20> >=20> >Do you like the sem_t change? Partly? Not at all?> >There is one sem_t in the system. So I moved it to be in C code.> >Or=2C as I had it before=2C declared as the max size/align of all the platf=> >orms -- getting that right is the same work as getting it right "the old wa=> >y"=2C except if you make a mistake=2C odds are still good of it being ok.> >=20> >=20> >Should the line be drawn at generating the remaining headers=2C rather than=> > eliminating them?> >Uerror.i3 is easily generated. Good enough?> >=20> >Upthread.i3's types can be generated generally as records with opaque array=> >s with the right size and alignment.> >=20> >Other stuff can be generated or at least checked.> >e.g. to check that getpid is declared correctly=2C you can assign it to a f=> >unction pointer and see if that compiles.> >=20> >Perf on Uerror arguably doesn't matter.> >Is it only error handling code?Or do sockets often go down "error" paths=2C=> > because they are slow and you are waiting for more data?> >=20> >Anyway=2C point is=2C I agree for sure this is valuable=2C but I might be h=> >itting the "tail" of the approach and should switch=2C I'm not sure. I keep=> > saying that though=2C and then press further.> >=20> >=20> > - Jay> >> >> >> >From: hosking at cs.purdue.eduTo: jay.krell at cornell.eduDate: Mon=2C 12 Jan 200=> >9 19:24:50 +1100CC: m3devel at elegosoft.comSubject: Re: [M3devel] declaring a=> > type's existance but not enough to instantiate it?> >> >> >Point taken. We live in a C universe and so need to interact. I do think => >your work with the headers is useful=2C and I want it to continue. Especia=> >lly in simplifying ports.> >> >> >On 12 Jan 2009=2C at 19:18=2C Jay wrote:> >> >I don't think a development system without C headers is interesting.. Is it=> > really? The transform I apply at times is wherever there is interaction wi=> >th C code that is described by system-dependent headers=2C or perhaps even => >fairly system-independent headers outside the Modula-3 tree=2C either write=> > wrapper functions for the functionality in the headers (e.g. stat=2C waitp=> >id)=2C which can be done in a system-independent way=2C or move the Modula-=> >3<->C transition higher=2C which is also usually system-independent=2C e.g.=> > ThreadPThreadC_SetupHandlers. It is either that or clone the headers=2C wh=> >ich seems like the worse evil. There is always going to be a Modula-3<->C t=> >ransition=2C it is just a matter of where it occurs. - Jay> >> >CC: m3devel at elegosoft.comFrom: hosking at cs.purdue.eduTo: jay.krell at cornell.e=> >duSubject: Re: [M3devel] declaring a type's existance but not enough to ins=> >tantiate it?Date: Mon=2C 12 Jan 2009 12:32:15 +1100> >> >> >Jay=2C I really think you are bending over backwards too far just to be abl=> >e to shoe-horn things into C. I *like* having the transpar of C header fil=> >es expressed in Modula-3=2C *particularly* for system calls=2C where you mi=> >ght even be trying to build on a system that does not have the C header fil=> >es installed=2C even though the libraries exist and can be linked to. Fund=> >amentally=2C I think anytime the Modula-3 code is made less transparent you=> > should think hard about what you are doing. The same with the change of c=> >onstants to variables.> >> >I am getting very nervous that the changes you are making are destroying th=> >e clarity of the Modula-3 run-time code.> >> >In this particular case=2C you are wanting to use a Modula-3 parameter pass=> >ing mechanism on something that is not declared in Modula-3. Seems kind of=> > dubious to me. Also=2C I really don't like the idea of accessing external=> > variables in C.> >> >-- Tony> >> >On 12 Jan 2009=2C at 11:55=2C Jay wrote:> >> >I considered ADDRESS.However I think it still doesn't satisfy. I want to be=> > able to do this: TYPE Foo_t =3D something=3B<* EXTERNAL *> VAR Foo1=2C Foo=> >2:Foo_t=3B<* EXTERNAL *> PROCEDURE UseFoo(READONLY (* or VAR *) foo:Foo_t)=> >=3B (* Modula-3=2C not external *)PROCEDURE x()=3DBEGIN UseFoo(Foo1)=3B U=> >seFoo(Foo2)=3BEND x=3B AND I want any use of:VAR Foo3:Foo3_t=3B (* Modula-3=> >=2C not external *)to error. This is sem_t and sigset_t in particular. Poss=> >ibly renaming is the thing.They used to be declared in Modula-3=2C system-d=> >ependently=2C butI moved them to portable C. I could remove the types entir=> >ely and change UseFoo to take an address=2Cand declare mask and ackSem to b=> >e integers or I guess.<*EXTERNAL> VAR ackSem : RECORD END=3B That would sat=> >isfy but I thought it might be nicer to still provide the namedtypes to ref=> >er to the external variables. - Jay> >> >From: hosking at cs.purdue.eduTo: jay.krell at cornell.eduDate: Mon=2C 12 Jan 200=> >9 11:13:00 +1100CC: m3devel at elegosoft.comSubject: Re: [M3devel] declaring a=> > type's existance but not enough to instantiate it?What's wrong with using => >ADDRESS for references to opaque values? If sigset_t is never instantiated=> > in Modula-3=2C then why do you need it declared there?> >> >> >> >Antony Hosking | Associate Professor | Computer Science | Purdue University> >305 N. University Street | West Lafayette | IN 47907 | USA> >Office +1 765 494 6001 | Mobile +1 765 427 5484> >> >> >On 12 Jan 2009=2C at 01:44=2C Jay wrote:> >> >Is there a way in Modula-3 to declare that a type exists=2C and there are <=> >*external*> instances of it=2C without "fully" declaring it=2C so that no M=> >odula-3 can instantiate it? I have done this for sigset_t and sem_t=2C but => >they could erroneously be instantiated by Modula-3 and I'd like to remove t=> >hat ability to mess up so easily. (* This type is not declared correctly. I=> >t is only instantiated in C code. *) sigset_t =3D RECORD END=3B(* This typ=> >e is not declared correctly. It is only instantiated in C code. *) sem_t => >=3D RECORD END=3BIn C I believe you can do this=2C like: typedef struct fo=> >o foo_t=3B extern foo_t foo=3B void UseFoo(foo_t*)=3B foo_t* GetFoo=> >(void)=3B Thanks=2C - Jay=> >> >--_6117a048-9185-4c03-badb-ef8f93402268_> >Content-Type: text/html; charset="iso-8859-1"> >Content-Transfer-Encoding: quoted-printable> >> ><html>> ><head>> ><style>> >.hmmessage P> >{> >margin:0px=3B> >padding:0px> >}> >body.hmmessage> >{> >font-size: 10pt=3B> >font-family:Verdana> >}> ></style>> ></head>> ><body class=3D'hmmessage'>> >This is what you "have to" chose between.<BR>> >Header cloning or C code (and C headers).<BR>> >&nbsp=3B<BR>> >CONST or VAR (or functions?)<BR>> >&nbsp=3B<BR>> >I'm going to likely make the Uerror change tonight.<BR>> >You can still veto it (er=2C vote against it :) )<BR>> >&nbsp=3B<BR>> >Possibly some convuluted C (enum/#undef)=2C or splitting the Modula-3<BR>> >at boundaries that weren't previously believed "natural".<BR>> >(See how SetupHandlers is ~two lines in Modula-3 and the rest in C=3B<BR>> >this is partly out of ignorance. I don't know how to write those<BR>> >two lines in C=3B and laziness=2C I didn't look into how).<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >Remember I'm still staying away from mainstream platforms=2C<BR>> >so the value isn't what it might appear to be=2C but it is "stage setting"=> >=2C<BR>> >and the show might go on. :)<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >Also=2C the dilemna does get more difficult now=2C with the little C header=> > cloning that remains.<BR>> >&nbsp=3B<BR>> >For example=2C look at Upthreads.i3.<BR>> >Mainly=2C look at function prototypes.<BR>> >Constants and types are "known problems".<BR>> >Prototypes are gray. They actually tend to be portable.<BR>> >&nbsp=3B<BR>> >For example:<BR>> >&nbsp=3B<BR>> >TYPE pid_t =3D INTEGER=3B<BR>> >&lt=3B*EXTERNAL "m3_getpid*&gt=3B PROCEDURE getpid():pid_t=3B<BR>> >&nbsp=3B<BR>> >or leave it alone?<BR>> >getpid is probably the worst example.<BR>> >It is so very portable declared in Modula-3.<BR>> >But still=2C imagine pid_t might be 16bits or 32 or 64.<BR>> >Writing a wrapper is more portable -- as long as the pid isn't stuff into s=> >ome record that the system defines.<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >Again=2C Upthreads.i3.<BR>> >Would you like to see it reduced=2C or left alone?<BR>> >Only deal with the types and initializers=2C or also the prototypes?<BR>> >You know=2C I could write a little portable layer=2C where all the types ar=> >e pointers=2C always null initialized.<BR>> >It would buy /some/ portability=2C and cost some.<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >Do you like the sem_t change? Partly? Not at all?<BR>> >There is one sem_t in the system. So I moved it to be in C code.<BR>> >Or=2C as I had it before=2C declared as the max size/align of all the platf=> >orms -- getting that right is the same work as getting it right "the old wa=> >y"=2C except if you make a mistake=2C odds are still good of it being ok.<B=> >R>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >Should the line be drawn at generating the remaining headers=2C rather than=> > eliminating them?<BR>> >Uerror.i3 is easily generated. Good enough?<BR>> >&nbsp=3B<BR>> >Upthread.i3's types can be generated generally as records with opaque array=> >s with the right size and alignment.<BR>> >&nbsp=3B<BR>> >Other stuff can be generated or at least checked.<BR>> >e.g. to check that getpid is declared correctly=2C you can assign it to a f=> >unction pointer and see if that compiles.<BR>> >&nbsp=3B<BR>> >Perf on Uerror arguably doesn't matter.<BR>> >Is it only error handling code?<BR>Or do sockets often go down "error" path=> >s=2C because they are slow and you are waiting for more data?<BR>> >&nbsp=3B<BR>> >Anyway=2C point is=2C I agree for sure this is valuable=2C but I might be h=> >itting the "tail" of the approach and should switch=2C I'm not sure. I keep=> > saying that though=2C and then press further.<BR>> >&nbsp=3B<BR>> >&nbsp=3B<BR>> >&nbsp=3B- Jay<BR><BR>> >> ><HR id=3DstopSpelling>> <BR>> >From: hosking at cs.purdue.edu<BR>To: jay.krell at cornell.edu<BR>Date: Mon=2C 12=> > Jan 2009 19:24:50 +1100<BR>CC: m3devel at elegosoft.com<BR>Subject: Re: [M3de=> >vel] declaring a type's existance but not enough to instantiate it?<BR><BR>=> ><BR>> ><DIV><SPAN class=3DEC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: => >12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-IND=> >ENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPS=> >E: separate">> ><DIV style=3D"WORD-WRAP: break-word"><SPAN class=3DEC_Apple-style-span styl=> >e=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B C=> >OLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-S=> >PACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_Apple-style-s=> >pan style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: n=> >one=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B => >LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_Apple=> >-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRAN=> >SFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: no=> >rmal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3D=> >EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B T=> >EXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-S=> >PACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN => >class=3DEC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvet=> >ica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B=> > WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate=> >"><SPAN class=3DEC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12p=> >x Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT=> >: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: => >separate"><SPAN class=3DEC_Apple-style-span style=3D"WORD-SPACING: 0px=3B F=> >ONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEX=> >T-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-CO=> >LLAPSE: separate"><SPAN class=3DEC_Apple-style-span style=3D"WORD-SPACING: => >0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0=> >)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B B=> >ORDER-COLLAPSE: separate">> ><DIV>Point taken. &nbsp=3BWe live in a C universe and so need to interact. => >&nbsp=3BI do think your work with the headers is useful=2C and I want it to=> > continue. &nbsp=3BEspecially in simplifying ports.</DIV>> ><DIV><BR></DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DI=> >V></SPAN></DIV>> ><DIV>> ><DIV>On 12 Jan 2009=2C at 19:18=2C Jay wrote:</DIV><BR class=3DEC_Apple-int=> >erchange-newline>> ><BLOCKQUOTE><SPAN class=3DEC_Apple-style-span style=3D"WORD-SPACING: 0px=3B=> > FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B T=> >EXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-=> >COLLAPSE: separate">> ><DIV class=3DEC_hmmessage style=3D"FONT-SIZE: 10pt=3B FONT-FAMILY: Verdana"=> >>I don't think a development system without C headers is interesting.. Is i=> >t really?<BR>&nbsp=3B<BR>The transform I apply at times is wherever there i=> >s interaction with C code that is described by system-dependent headers=2C => >or perhaps even fairly system-independent headers outside the Modula-3 tree=> >=2C either write wrapper functions for the functionality in the headers (e.=> >g. stat=2C waitpid)=2C which&nbsp=3Bcan be done in a system-independent way=> >=2C&nbsp=3Bor move the Modula-3&lt=3B-&gt=3BC transition higher=2C which is=> > also usually system-independent=2C e.g. ThreadPThreadC_SetupHandlers.<BR>&=> >nbsp=3B<BR>It is either that or clone the headers=2C which seems like the w=> >orse evil.<BR>&nbsp=3B<BR>There is always going to be a Modula-3&lt=3B-&gt=> >=3BC transition=2C it is just a matter of where it occurs.<BR>&nbsp=3B<BR>&=> >nbsp=3B- Jay<BR><BR>> ><HR id=3DEC_stopSpelling>> ><BR>CC:<SPAN class=3DEC_Apple-converted-space>&nbsp=3B</SPAN><A href=3D"mai=> >lto:m3devel at elegosoft.com">m3devel at elegosoft.com</A><BR>From:<SPAN class=3D=> >EC_Apple-converted-space>&nbsp=3B</SPAN><A href=3D"mailto:hosking at cs.purdue=> >.edu">hosking at cs.purdue.edu</A><BR>To:<SPAN class=3DEC_Apple-converted-spac=> >e>&nbsp=3B</SPAN><A href=3D"mailto:jay.krell at cornell.edu">jay.krell at cornell=> >.edu</A><BR>Subject: Re: [M3devel] declaring a type's existance but not eno=> >ugh to instantiate it?<BR>Date: Mon=2C 12 Jan 2009 12:32:15 +1100<BR><BR><B=> >R>> <DIV><SPAN class=3DEC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FON=> >T: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-=> >INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLL=> >APSE: separate">> ><DIV style=3D"WORD-WRAP: break-word"><SPAN class=3DEC_EC_Apple-style-span s=> >tyle=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=> >=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LET=> >TER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_Apple=> >-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRAN=> >SFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: no=> >rmal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3D=> >EC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=> >=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WH=> >ITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><=> >SPAN class=3DEC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12p=> >x Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT=> >: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: => >separate"><SPAN class=3DEC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=> >=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=> >=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BO=> >RDER-COLLAPSE: separate"><SPAN class=3DEC_EC_Apple-style-span style=3D"WORD=> >-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb=> >(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: n=> >ormal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_Apple-style-span st=> >yle=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B=> > COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER=> >-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_Apple-st=> >yle-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFO=> >RM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: norma=> >l=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate">> ><DIV>Jay=2C I really think you are bending over backwards too far just to b=> >e able to shoe-horn things into C. &nbsp=3BI *like* having the transpar of => >C header files expressed in Modula-3=2C *particularly* for system calls=2C => >where you might even be trying to build on a system that does not have the => >C header files installed=2C even though the libraries exist and can be link=> >ed to. &nbsp=3BFundamentally=2C I think anytime the Modula-3 code is made l=> >ess transparent you should think hard about what you are doing. &nbsp=3BThe=> > same with the change of constants to variables.</DIV>> ><DIV><BR></DIV>> ><DIV>I am getting very nervous that the changes you are making are destroyi=> >ng the clarity of the Modula-3 run-time code.</DIV>> ><DIV><BR></DIV>> ><DIV>In this particular case=2C you are wanting to use a Modula-3 parameter=> > passing mechanism on something that is not declared in Modula-3. &nbsp=3BS=> >eems kind of dubious to me. &nbsp=3BAlso=2C I really don't like the idea of=> > accessing external variables in C.</DIV>> ><DIV><BR></DIV>> ><DIV>-- Tony</DIV></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN><=> >/DIV></SPAN></DIV><BR>> ><DIV>> ><DIV>On 12 Jan 2009=2C at 11:55=2C Jay wrote:</DIV><BR class=3DEC_EC_Apple-=> >interchange-newline>> ><BLOCKQUOTE><SPAN class=3DEC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=> >=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=> >=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BO=> >RDER-COLLAPSE: separate">> ><DIV class=3DEC_EC_hmmessage style=3D"FONT-SIZE: 10pt=3B FONT-FAMILY: Verda=> >na">I considered ADDRESS.<BR>However I think it still doesn't satisfy.<BR>&=> >nbsp=3B<BR>I want to be able to do this:<BR>&nbsp=3B<BR>TYPE&nbsp=3BFoo_t => >=3D something=3B<BR>&lt=3B* EXTERNAL *&gt=3B VAR Foo1=2C Foo2:Foo_t=3B<BR>&=> >lt=3B* EXTERNAL *&gt=3B PROCEDURE&nbsp=3BUseFoo(READONLY (* or VAR *) foo:F=> >oo_t)=3B<BR>&nbsp=3B<BR>(* Modula-3=2C not external *)<BR>PROCEDURE x()=3D<=> >BR>BEGIN<BR>&nbsp=3B UseFoo(Foo1)=3B<BR>&nbsp=3B UseFoo(Foo2)=3B<BR>END x=> >=3B<BR>&nbsp=3B<BR>AND I want any use of:<BR>VAR Foo3:Foo3_t=3B (* Modula-3=> >=2C not external *)<BR><BR>to error. This is sem_t and sigset_t in particul=> >ar.<BR>&nbsp=3B<BR>Possibly renaming is the thing.<BR>They used to be decla=> >red in Modula-3=2C system-dependently=2C but<BR>I moved them to portable C.=> ><BR>&nbsp=3B<BR>I could remove the types entirely and change UseFoo to take=> > an address=2C<BR>and declare mask and ackSem to be integers or I guess.<BR=> >>&lt=3B*EXTERNAL&gt=3B VAR ackSem&nbsp=3B: RECORD END=3B<BR>&nbsp=3B<BR>Tha=> >t would satisfy but I thought it might be nicer to still provide the named<=> >BR>types to refer to the external variables.<BR>&nbsp=3B<BR>&nbsp=3B- Jay<B=> >R><BR>> ><HR id=3DEC_EC_stopSpelling>> ><BR>From:<SPAN class=3DEC_EC_Apple-converted-space>&nbsp=3B</SPAN><A href=> >=3D"mailto:hosking at cs.purdue.edu">hosking at cs.purdue.edu</A><BR>To:<SPAN cla=> >ss=3DEC_EC_Apple-converted-space>&nbsp=3B</SPAN><A href=3D"mailto:jay.krell=> >@cornell.edu">jay.krell at cornell.edu</A><BR>Date: Mon=2C 12 Jan 2009 11:13:0=> >0 +1100<BR>CC:<SPAN class=3DEC_EC_Apple-converted-space>&nbsp=3B</SPAN><A h=> >ref=3D"mailto:m3devel at elegosoft.com">m3devel at elegosoft.com</A><BR>Subject: => >Re: [M3devel] declaring a type's existance but not enough to instantiate it=> >?<BR><BR>What's wrong with using ADDRESS for references to opaque values? &=> >nbsp=3BIf sigset_t is never instantiated in Modula-3=2C then why do you nee=> >d it declared there?<BR>> ><DIV><BR>> ><DIV><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B => >FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TE=> >XT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-C=> >OLLAPSE: separate">> ><DIV style=3D"WORD-WRAP: break-word"><SPAN class=3DEC_EC_EC_Apple-style-spa=> >n style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: non=> >e=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LE=> >TTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_EC_A=> >pple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-=> >TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE=> >: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN clas=> >s=3DEC_EC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helv=> >etica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=> >=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separ=> >ate"><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B => >FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TE=> >XT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-C=> >OLLAPSE: separate"><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"WORD-SP=> >ACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=> >=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: nor=> >mal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_EC_Apple-style-span s=> >tyle=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=> >=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LET=> >TER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=3DEC_EC_EC_Ap=> >ple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helvetica=3B TEXT-T=> >RANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=3B WHITE-SPACE:=> > normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separate"><SPAN class=> >=3DEC_EC_EC_Apple-style-span style=3D"WORD-SPACING: 0px=3B FONT: 12px Helve=> >tica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0)=3B TEXT-INDENT: 0px=> >=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B BORDER-COLLAPSE: separ=> >ate">> ><DIV><FONT class=3DEC_EC_EC_Apple-style-span color=3D#0000ff><FONT class=3D=> >EC_EC_EC_Apple-style-span face=3D"Gill Sans"><SPAN class=3DEC_EC_EC_Apple-s=> >tyle-span style=3D"COLOR: rgb(0=2C0=2C255)=3B FONT-FAMILY: 'Gill Sans'"><SP=> >AN class=3DEC_EC_EC_Apple-style-span style=3D"COLOR: rgb(0=2C0=2C255)=3B FO=> >NT-FAMILY: 'Gill Sans'">Antony Hosking</SPAN></SPAN></FONT></FONT><FONT cla=> >ss=3DEC_EC_EC_Apple-style-span face=3D"Gill Sans"><SPAN class=3DEC_EC_EC_Ap=> >ple-style-span style=3D"FONT-FAMILY: 'Gill Sans'"><SPAN class=3DEC_EC_EC_Ap=> >ple-style-span style=3D"FONT-FAMILY: 'Gill Sans'"><SPAN class=3DEC_EC_Apple=> >-converted-space>&nbsp=3B</SPAN>|<SPAN class=3DEC_EC_Apple-converted-space>=> >&nbsp=3B</SPAN></SPAN></SPAN><SPAN class=3DEC_EC_EC_Apple-style-span style=> >=3D"FONT-FAMILY: 'Gill Sans'"><SPAN class=3DEC_EC_EC_Apple-style-span style=> >=3D"FONT-FAMILY: 'Gill Sans'">Associate Professor</SPAN></SPAN><SPAN class=> >=3DEC_EC_EC_Apple-style-span style=3D"FONT-FAMILY: 'Gill Sans'"><SPAN class=> >=3DEC_EC_EC_Apple-style-span style=3D"FONT-FAMILY: 'Gill Sans'">&nbsp=3B| C=> >omputer Science | Purdue University</SPAN></SPAN></FONT></DIV>> ><DIV><FONT class=3DEC_EC_EC_Apple-style-span face=3DGillSans-Light><SPAN cl=> >ass=3DEC_EC_EC_Apple-style-span style=3D"FONT-FAMILY: GillSans-Light">305 N=> >. University Street | West Lafayette | IN 47907 | USA</SPAN></FONT></DIV>> ><DIV><FONT class=3DEC_EC_EC_Apple-style-span face=3D"Gill Sans" color=3D#00=> >00ff><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"COLOR: rgb(0=2C0=2C25=> >5)=3B FONT-FAMILY: 'Gill Sans'"><SPAN class=3DEC_EC_EC_Apple-style-span sty=> >le=3D"COLOR: rgb(0=2C0=2C255)=3B FONT-FAMILY: 'Gill Sans'">Office</SPAN></S=> >PAN></FONT><FONT class=3DEC_EC_EC_Apple-style-span face=3DGillSans-Light><S=> >PAN class=3DEC_EC_EC_Apple-style-span style=3D"FONT-FAMILY: GillSans-Light"=> >><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"FONT-FAMILY: GillSans-Lig=> >ht">&nbsp=3B+1 765 494 6001 |<SPAN class=3DEC_EC_Apple-converted-space>&nbs=> >p=3B</SPAN></SPAN></SPAN></FONT><FONT class=3DEC_EC_EC_Apple-style-span fac=> >e=3D"Gill Sans" color=3D#0000ff><SPAN class=3DEC_EC_EC_Apple-style-span sty=> >le=3D"COLOR: rgb(0=2C0=2C255)=3B FONT-FAMILY: 'Gill Sans'"><SPAN class=3DEC=> >_EC_EC_Apple-style-span style=3D"COLOR: rgb(0=2C0=2C255)=3B FONT-FAMILY: 'G=> >ill Sans'">Mobile</SPAN></SPAN></FONT><FONT class=3DEC_EC_EC_Apple-style-sp=> >an face=3DGillSans-Light><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"F=> >ONT-FAMILY: GillSans-Light"><SPAN class=3DEC_EC_EC_Apple-style-span style=> >=3D"FONT-FAMILY: GillSans-Light"><SPAN class=3DEC_EC_Apple-converted-space>=> >&nbsp=3B</SPAN>+1 765 427 5484</SPAN></SPAN></FONT></DIV>> ><DIV><FONT class=3DEC_EC_EC_Apple-style-span face=3DGillSans-Light><BR clas=> >s=3DEC_EC_EC_khtml-block-placeholder></FONT></DIV></SPAN></SPAN></SPAN></SP=> >AN></SPAN></SPAN></SPAN><BR class=3DEC_EC_EC_Apple-interchange-newline></SP=> >AN></DIV></SPAN></DIV><BR>> ><DIV>> ><DIV>On 12 Jan 2009=2C at 01:44=2C Jay wrote:</DIV><BR class=3DEC_EC_EC_App=> >le-interchange-newline>> ><BLOCKQUOTE><SPAN class=3DEC_EC_EC_Apple-style-span style=3D"WORD-SPACING: => >0px=3B FONT: 12px Helvetica=3B TEXT-TRANSFORM: none=3B COLOR: rgb(0=2C0=2C0=> >)=3B TEXT-INDENT: 0px=3B WHITE-SPACE: normal=3B LETTER-SPACING: normal=3B B=> >ORDER-COLLAPSE: separate">> ><DIV class=3DEC_EC_EC_hmmessage style=3D"FONT-SIZE: 10pt=3B FONT-FAMILY: Ve=> >rdana">Is there a way in Modula-3 to declare that&nbsp=3Ba type exists=2C a=> >nd there are &lt=3B*external*&gt=3B instances of it=2C without "fully" decl=> >aring it=2C so that no Modula-3 can instantiate it?<BR>&nbsp=3B<BR>I have d=> >one this for sigset_t and sem_t=2C but they could erroneously be instantiat=> >ed by Modula-3 and I'd like to remove that ability to mess up so easily.<BR=> >>&nbsp=3B<BR>(* This type is not declared correctly. It is only instantiate=> >d in C code. *)<BR>&nbsp=3B sigset_t =3D RECORD END=3B<BR><BR>(* This type => >is not declared correctly. It is only instantiated in C code. *)<BR>&nbsp=> >=3B sem_t =3D RECORD END=3B<BR><BR>In C I believe you can do this=2C like:<=> >BR>&nbsp=3B&nbsp=3Btypedef struct foo foo_t=3B&nbsp=3B<SPAN class=3DEC_EC_E=> >C_Apple-converted-space>&nbsp=3B</SPAN><BR>&nbsp=3B&nbsp=3Bextern foo_t foo=> >=3B&nbsp=3B<SPAN class=3DEC_EC_EC_Apple-converted-space>&nbsp=3B</SPAN><BR>=> >&nbsp=3B<BR>&nbsp=3Bvoid UseFoo(foo_t*)=3B<SPAN class=3DEC_EC_EC_Apple-conv=> >erted-space>&nbsp=3B</SPAN><BR>&nbsp=3B foo_t* GetFoo(void)=3B<SPAN class=> >=3DEC_EC_EC_Apple-converted-space>&nbsp=3B</SPAN><BR>&nbsp=3B<BR>Thanks=2C<=> >BR>&nbsp=3B- Jay<BR><BR><BR><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV><=> >/DIV></SPAN><BR class=3DEC_EC_Apple-interchange-newline></BLOCKQUOTE></DIV>=> ><BR></DIV></SPAN><BR class=3DEC_Apple-interchange-newline></BLOCKQUOTE></DI=> >V><BR></body>> ></html>=> >> >--_6117a048-9185-4c03-badb-ef8f93402268_--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090112/59a20639/attachment-0002.html>


More information about the M3devel mailing list