From jay.krell at cornell.edu Fri Nov 2 21:37:38 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 2 Nov 2007 20:37:38 +0000 Subject: [M3devel] iterating over sets? In-Reply-To: References: Message-ID: I was asking about Modula-3 syntax and built in mechanisms. Here are the ways to implement this sort of thing. There are two main scenarios: a small set this can be either 0..n or n..m "small" is n or m-n a big set again 0..n or n..m offseting the start is trivial A small set should be represented by an array of some integer type,such as array of 8 bit int, or 16 bit int, or 32 bit, or 64 bit int It should support operations such as: Operations my question needs: FindFirstSetBit FindNextSetBit(start) Operation of course needed: GetBit(offset) Operations other uses of this data structure would want, though maybe not a "set": FindFirstClearBit FindNextClearBit(start) FindClearBits(start,count) FindSetBits(start,count) SetBits(start,count) ClearBits(start,count) You might want to combine some of them -- FindClearBitsAndSet, FindSetBitsAndClear. Operations that Modula-3 already has: union intersect difference symmetric_difference I was asked stuff about this as an interview question years ago. Depending on processor support, one implementation is an array of bytes and youhave roughly the following small tables: typedef unsigned char byte;byte MaximumBitsSet[256];byte MaximumBitsClear[256];byte BitsSetLeft[256];byte BitsClearLeft[256];byte BitsSetRight[256];byte BitsClearRight[256];byte OffsetOfMaximumBitsSet[256];byte OffsetOfMaximumBitsClear[256]; Some of this might be redundant.You could pack them the other way: typedef struct BitInfo_t { byte MaximumBitsSet; // or 3 bit bitfield byte MaximumBitsClear; etc.} BitInfo_t; BitInfo_t BitInfo[256]; >From here you can reasonably easily reasonably efficiently implementthe functions I identified. Now, if your processor supports intructions to compute some of thesefigures efficiently, esp. on a 32 bit or 64 bit integer, that mightbe more efficient. There's a term here "population count" and an instructionin some processors. Maybe also "lzcnt" -- leading zero count. If the set does not start at 0, you just offset things at some point. Easy. For a large set, this will use too much memory.You can use simply a sorted array of integers.And use binary search against that.Not terrible. Or you can use an array of offset, length pairs."extents" perhaps this is called.You would sort this by offset, and again use binary search.This would tend to be more compact. You could be adaptive.You could set some thresholds of size or density at which you would switchthe representation from one to the other.Of course you if I am frequently adding/removing items to a set, you don'twant to frequently change the representation. I'm still pondering 64 bit integer support in the x86 back end.The basic dilemna is a stack of pairs or the existing stack of singletons wheresometimes you'd use two stack items at a time. I'm leaning towarda stack of pairs. After that we can discuss something like: FindFirstMemberInSet FindNextMemberInSet and adding that to the language, etc. FIRST and NEXT seem natural but I believe FIRST already meansthe first possible value, not the first present value. On Windows, run link /dump /exports %windir%\system32\ntdll.dll | findstr /i bit.You'll see some of this stuff and more. - Jay > Date: Wed, 31 Oct 2007 23:09:11 +0100> From: lemming at henning-thielemann.de> Subject: Re: [M3devel] iterating over sets?> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> > > On Wed, 31 Oct 2007, Jay wrote:> > > Let's say I had> >> > TYPE T = SET OF { 0 .. 256 };> >> > Must I say:> >> > VAR t: T;> > FOR i := FIRST(t) TO LAST(t)> > IF i IN t DO> > something with i> > END> > END> > You may speed up search by splitting the set into subsets.> > E.g.> > IF t * T{16..31} = T{} THEN> skip this block completely> ELSE> inspect that block in detail> END; _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Mon Nov 5 16:05:14 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon, 05 Nov 2007 16:05:14 +0100 (MET) Subject: [M3devel] m3.org Message-ID: Does the domain have a new owner? From wagner at elegosoft.com Mon Nov 5 17:06:32 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Mon, 05 Nov 2007 17:06:32 +0100 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: <20071105170632.1cuq7pj8mccgc8w0@mail.elegosoft.com> Quoting Henning Thielemann : > > Does the domain have a new owner? No, it still belongs to Farshad Nayeri, and he wants to keep it. All content has been moved to modula3.org several months ago. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From darko at darko.org Mon Nov 5 18:26:20 2007 From: darko at darko.org (Darko) Date: Mon, 5 Nov 2007 09:26:20 -0800 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: Looks like it. modula3.org is being used instead. On 05/11/2007, at 7:05 AM, Henning Thielemann wrote: > > Does the domain have a new owner? From wagner at elegosoft.com Fri Nov 9 12:45:25 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:45:25 +0100 Subject: [M3devel] Fwd: install problems Message-ID: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Sorry, I'm afraid there's currently no one here at Elego to look into this; perhaps anybody here on m3devel can help out? I myself am busy at a customer. Thanks in advance, Olaf ----- Forwarded message from radugrigore at gmail.com ----- Date: Fri, 9 Nov 2007 10:02:28 +0000 From: Radu Grigore Reply-To: Radu Grigore Subject: install problems To: m3-support at elego.de OK, I stopped trying the CVS and followed the installation notes. It stopes working here: rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship CM3C = /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap rehearsecode replayheap showheap shownew showthread pkl-fonts juno-machine juno-compiler juno-app cube calculator fisheye mentor === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' +++ Segmentation fault (core dumped) *** execution of failed *** -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- A non-text attachment was scrubbed... Name: Install.log Type: text/x-log Size: 9440 bytes Desc: not available URL: From wagner at elegosoft.com Fri Nov 9 12:47:14 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:47:14 +0100 Subject: [M3devel] Fwd: Re: install problems Message-ID: <20071109124714.cocmjgc4pc8c08cw@mail.elegosoft.com> Seem's I've been too pessimistic, Stefan has taken charge :-) Olaf ----- Forwarded message from stsp at elego.de ----- Date: Fri, 9 Nov 2007 11:31:07 +0100 From: Stefan Sperling Reply-To: Stefan Sperling Subject: Re: install problems To: Radu Grigore Cc: m3-support at elego.de On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From stsp at elego.de Fri Nov 9 15:13:11 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 15:13:11 +0100 Subject: [M3devel] [radugrigore@gmail.com: Re: install problems] Message-ID: <20071109141311.GF27811@jack.stsp.lan> Olaf, why did you forward Radu's request to the m3devel list? Is only elego staff on m3-support? If so, why? Just in case people missed his response, here it is. I don't know what his problem could be, may be someone who has an idea could respond and make it clear that further replies should go the m3devel list directly? Thanks. ----- Forwarded message from Radu Grigore ----- Date: Fri, 9 Nov 2007 11:30:42 +0000 From: Radu Grigore To: Stefan Sperling Subject: Re: install problems Cc: m3-support at elego.de Thanks for the reply! On Nov 9, 2007 10:31 AM, Stefan Sperling wrote: > What platform? Ubuntu gutsy. Linux rg-ucd 2.6.22-14-386 #1 Sun Oct 14 22:36:54 GMT 2007 i686 GNU/Linux > Which notes exactly? http://modula3.elegosoft.com/cm3/installation.html (Please note that I am not subscribed to this list. I wasn't even aware that it _is_ a list. I sent an email only because of the note at the end of the webpage linked above. Oh, you should probably know that the web form mentioned in the same paragraph on that webpage insists on "all mandatory fields being filled in" even when _all_ fields are filled in.) > Someone else on the list may have a better idea of what > this could be, I'm not following cm3 development closely. After ./do-cm3-core.sh buildship // seem to work fine ./install-cm3-compiler.sh upgrade running cm3 crashes every time actually. It just so happened that ./do-cm3-std.sh buildship was the next command that was supposed to be run. (Might be relevant: the command "./install-cm3-compiler.sh upgrade" didn't work because I installed cm3 in /homr/rg/tools/cm3 instead of /usr/local/cm3 and the latter is hardcoded in sysinfo.sh. The same for the lib directory. It did seem to work after fixing those.) > In any case, a backtrace would be great to help people > diagnose this. Please run: The backtrace doesn't seem useful: (gdb) where #0 0x9e841069 in ?? () Cannot access memory at address 0x405fcfa2 It crashes quite fast: rg at rg-ucd:src$ strace cm3 execve("/home/rg/tools/cm3/bin/cm3", ["cm3"], [/* 36 vars */]) = 0 uname({sys="Linux", node="rg-ucd", ...}) = 0 brk(0) = 0x8b1f000 brk(0x8b1fcb0) = 0x8b1fcb0 set_thread_area({entry_number:-1 -> 6, base_addr:0x8b1f830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 brk(0x8b40cb0) = 0x8b40cb0 brk(0x8b41000) = 0x8b41000 gettimeofday({1194607166, 865750}, NULL) = 0 gettimeofday({1194607166, 865831}, NULL) = 0 rt_sigaction(SIGHUP, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGINT, {0x820cc21, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGQUIT, {0x820cc81, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGSEGV, {0x820cce6, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTERM, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 mmap2(NULL, 270336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f34000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV (core dumped) +++ Same output with LD_POINTER_GUARD=0. -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From hosking at cs.purdue.edu Fri Nov 9 15:28:28 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 9 Nov 2007 09:28:28 -0500 Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Message-ID: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> WHat's your build target? On Nov 9, 2007, at 6:45 AM, Olaf Wagner wrote: > Sorry, > > I'm afraid there's currently no one here at Elego to look into this; > perhaps anybody here on m3devel can help out? > I myself am busy at a customer. > > Thanks in advance, > > Olaf > > ----- Forwarded message from radugrigore at gmail.com ----- > Date: Fri, 9 Nov 2007 10:02:28 +0000 > From: Radu Grigore > Reply-To: Radu Grigore > Subject: install problems > To: m3-support at elego.de > > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: > > rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship > CM3C = > /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build > -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 > patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen > m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry > set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf > debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex > m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq > netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc > postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt > jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit > codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn > obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui > obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui > obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap > rehearsecode replayheap showheap shownew showthread pkl-fonts > juno-machine juno-compiler juno-app cube calculator fisheye mentor > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** > > > -- > regards, > radu > http://rgrig.blogspot.com/ > > > ----- End forwarded message ----- > > > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > > > Thank you for using Critical Mass CM3. This program > will configure and install the system. > > cminstall_root is set to /home/rg/temp > If this is not correct, please restart the installer with > -root > > The installer will ask you some questions about the locations of > programs > and libraries. Usually it will display a default inside [], which > can be > accepted with . > If the installer has found several choices, you may cycle through them > with `+' or `.' for the next and `-' for the previous one. > You may of course also enter a completely different value. > > > Where would you like the system installed? [/usr/local/cm3] > What should be the default text editor for new Reactor users? > checking for executable with environment variable EDITOR... not found > checking for executable emacsclient... found > checking for executable emacs... found > checking for executable vi... found > checking for executable textedit... not found > checking for executable xedit... not found > checking for executable emacsclient in directory /usr/local/emacs/ > bin... not found > checking for executable emacsclient in directory /usr/local/bin... > not found > checking for executable emacs in directory /usr/local/emacs/bin... > not found > checking for executable emacs in directory /usr/local/bin... not found > checking for executable vi in directory /usr/bin... found > checking for executable xedit in directory /usr/local/X11R5/bin... > not found > checking for executable textedit in directory /usr/openwin/bin... > not found > checking for executable xedit in directory /usr/openwin/bin... not > found > checking for executable xedit in directory /usr/X11/bin... not found > checking for executable xedit in directory /usr/bin/X11... not found > > 1: /usr/bin/emacsclient > 2: /usr/bin/emacs > 3: /usr/bin/vi > What should be the default text editor for new Reactor users? > [/usr/bin/emacsclient](1 of 3) /usr/bin/vi > > Where should Reactor be installed? > setting INSTALL_ROOT to /usr/local/cm3 > Where are the flex/bison libraries? > looking for library file(s): libfl.a > checking for library files in directory /usr/lib... found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the flex/bison libraries? [/usr/lib](1 of 1) > > Where are the Postgres95 libraries? > looking for library file(s): libpq.so > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) > The libraries libpq.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) /home/rg/lib/ > links > > Where are the OpenGL libraries? > looking for library file(s): libGLU.so > looking for library file(s): libGL.so libGLU.so > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) > The libraries libGL.so libGLU.so are not present in the chosen > directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) /home/rg/lib/links > > Where are the ODBC libraries? > looking for library file(s): libodbc.so > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/pgsql/lib... not > found > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for directory /usr/local/lib... found > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) > The libraries libodbc.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) /home/rg/lib/ > links > > Where are the Motif libraries? > looking for library file(s): libXm.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the Motif libraries? [/usr/X11R6/lib](1 of 2) /home/rg/ > lib/links > > Where are the X11 libraries? > looking for library file(s): libXaw.so > looking for library file(s): libXmu.so libXaw.so > looking for library file(s): libXext.so libXmu.so libXaw.so > looking for library file(s): libXt.so libXext.so libXmu.so libXaw.so > looking for library file(s): libSM.so libXt.so libXext.so libXmu.so > libXaw.so > looking for library file(s): libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so > looking for library file(s): libX11.so libICE.so libSM.so libXt.so > libXext.so libXmu.so libXaw.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) > The libraries libX11.so libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) /home/rg/lib/ > links > > Where is your C compiler? > checking for executable gcc... found > checking for executable gcc in directory /bin... not found > checking for executable gcc in directory /usr/bin... found > checking for executable gcc in directory /usr/local... not found > checking for executable gcc in directory /usr/local/bin... not found > checking for executable gcc in directory /usr/local/gnu... not found > checking for executable cc... found > checking for executable cc in directory /bin... not found > checking for executable cc in directory /usr/bin... found > checking for executable cc in directory /usr/local... not found > checking for executable cc in directory /usr/local/bin... not found > checking for executable cc in directory /usr/local/gnu... not found > > 1: /usr/bin/gcc > 2: /usr/bin/cc > Where is your C compiler? [/usr/bin/gcc](1 of 2) > > Where is your library archiver? > checking for executable ar... found > checking for executable ar in directory /usr/bin... found > checking for executable ar in directory /bin... not found > checking for executable ar in directory /usr/local... not found > checking for executable ar in directory /usr/local/bin... not found > checking for executable ar in directory /usr/local/gnu... not found > > 1: /usr/bin/ar > Where is your library archiver? [/usr/bin/ar](1 of 1) > > Where is your assembler? > checking for executable as... found > checking for executable as in directory /usr/bin... found > checking for executable as in directory /bin... not found > checking for executable as in directory /usr/local... not found > checking for executable as in directory /usr/local/bin... not found > checking for executable as in directory /usr/local/gnu... not found > > 1: /usr/bin/as > Where is your assembler? [/usr/bin/as](1 of 1) > > > Installing CM3 in: /usr/local/cm3 > This may take a few minutes... > > CM3 is now installed. > > Before you begin, here's a few reminders: > > 1) The CM3 compiler executable is in: > /usr/local/cm3/bin/cm3 > You may need to modify your PATH environment variable to find it. > And on Unix, you may need to type "rehash" to your shell. > > 2) CM3's shared libraries and any you create and ship are in: > /usr/local/cm3/lib > On most Unix systems you need to set the LD_LIBRARY_PATH > (on Darwin / MacOS X it's called DYLD_LIBRARY_PATH) > environment variable before running programs that use > these shared libraries. > > 3) Your system configuration file is: > /usr/local/cm3/bin/cm3.cfg > At any point in time, you may edit it to modify or update your > installation. > > 4) A copy of this installation dialogue is in: > /usr/local/cm3/Install.log > > 5) If you had trouble with this installation or need more > assistance, > please send us a transcript of this installation via e-mail at > "m3-support at elego.de". > > Thank you. From stsp at elego.de Fri Nov 9 16:42:12 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 16:42:12 +0100 Subject: [M3devel] Fwd: install problems In-Reply-To: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> Message-ID: <20071109154212.GH27811@jack.stsp.lan> On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From dabenavidesd at yahoo.es Sat Nov 10 04:14:37 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 10 Nov 2007 04:14:37 +0100 (CET) Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109154212.GH27811@jack.stsp.lan> Message-ID: <610753.84071.qm@web27102.mail.ukl.yahoo.com> Hi all: Maybe I can help you. After all the help you have gave to me, I can contribute; first Im not sure but maybe Radu has some problem with cm3.cfg file and the way I have used the new cm3 binary is more "manual" than the cminstall process which should adjust the cm3.cfg file. The first thing to do is dowload the appropiate libraries/programs to be able to compile the cm3 standard. The packages I have used for the Ubuntu Feisty are these: http://es.geocities.com/dabenavidesd/cm3Manual.html#SECTION00020000000000000000 The above guide is for users of ubuntu feisty (older than gutsy), but the only version dependant thing are the names of some packages, but normally it should work for the gutsy, I can try it on these weekend as soon as I can. After that tough the instructions are in spanish you can see the line commands I have used, please inform me if there is something worng, and I will take account of that and change the "instructions". I will do a english version if it is really important (I think yes). Bye On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner Stefan Sperling escribi?: --------------------------------- ?Descubre una nueva forma de obtener respuestas a tus preguntas! Entra en Yahoo! Respuestas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sat Nov 10 12:33:03 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 03:33:03 -0800 Subject: [M3devel] leap-second issue with Date.i3 Message-ID: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Hello everyone, I just ... added a workaround for a nasty bug I had in some code of my own. My code used Unix's localtime to convert a Time.T to a Date.T using the zoneinfo files. I'm not sure if there's a "normal" way to do this in M3, so I have some messy stuff involving mutexes, static storage, etc. (Note one has to be careful when linking this stuff into a program with the normal M3 conversion codes---Date.FromTime and Date.ToTime---which also use (other) hidden mutexes to protect some of the same data structures!) The issue is this. I just realized that localtime sometimes returns "60" for the seconds---namely, during a leap second! Just copying this into a Date.T will lead to a range error and a program crash. Do we really want Modula-3 users to have to restart their servers the moment after popping the champagne corks? (Ok, well during New Year's Eve in my time zone, but still...) Does anyone know how Date.T handles/should handle this? As correct as it is, I find it somewhat unsatisfying to change the seconds field to [0..60], because off-by-one errors are so common in programming... it's probably The Right Thing to do, though. Mika From hosking at cs.purdue.edu Sat Nov 10 17:22:21 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Sat, 10 Nov 2007 11:22:21 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: I see no problem with changing seconds to [0..60]. That matches the POSIX spec nicely enough. On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes--- > Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From hendrik at topoi.pooq.com Sat Nov 10 21:11:01 2007 From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com) Date: Sat, 10 Nov 2007 15:11:01 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: <20071110201101.GB1273@topoi.pooq.com> On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes---Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) Does that mean that each time zone, as midnight creeps around the world, will insert the leap second at its own midnight, resulting in time-zone differences of 59 minutes and 59 seconds? -- hendrik > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From mika at async.caltech.edu Sat Nov 10 21:40:33 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 12:40:33 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 15:11:01 EST." <20071110201101.GB1273@topoi.pooq.com> Message-ID: <200711102040.lAAKeXoK067937@camembert.async.caltech.edu> hendrik at topoi.pooq.com writes: >On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: ... >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) > >Does that mean that each time zone, as midnight creeps around the world, >will insert the leap second at its own midnight, resulting in time-zone >differences of 59 minutes and 59 seconds? No, I think it happens at midnight UTC... during New Year's Eve here in California, early New Year's Day in CET. > >-- hendrik ... From jay.krell at cornell.edu Mon Nov 12 01:51:55 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 00:51:55 +0000 Subject: [M3devel] small array in modula-3? Message-ID: What is the right way to have a variably sized but always small array in Modula-3?My array will only ever have 1 or 2 elements.I'd like to always allocate room for 2 elements, and have there be a size. It seems I have a choice of a) an "open" arrayb) wrap it up in a record I'd like so have, like: TYPE A = ARRAY [0..1] OF FOO; And be able to say: VAR a : A; .. a.size FOR i := 0 TO a.size DO do something with a[i] It seems I have no option but, like: TYPE A = RECORD a: ARRAY[0..1] OF FOO; size := 1; (* usually of size 1, sometimes 2 *)END and then FOR i := 0 TO a.size DO do something with a.a[i]; That is "ok". Not great -- what to call the inner a? But then furthermore, I'd like to construct constants.It seems I am stuck with either the verbose: PROCEDURE F(a:A); F( A { ARRAY[0..1] OF FOO { .. } ); OR I have to come up with a name for the embedded array.But of course, its type is really "the same" as the outer type. To wit: TYPE FooArray = ARRAY[0..1] OF Foo; TYPE FooArray = RECORD a : FooArray; size := 1;END; F( FooArray { FooArray { .. } ); But I have to come up with different names. And I don't think I can leave out the name for the constructor, like: F( FooArray { { .. } ); Though that might seem nice. Am I understanding everything? Have folks hit this before and there's a set of names that don't seem too lamethat folks use? Also -- language documentation?Nelson's green book is excellent.The stuff in the doc directory is very dry and scientific.The tutorial seems more like a reference. Or maybe I didn't read it enough.Is there better, in case I need a refresher?I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,but I don't think anyone could learn from the current online docs in the source tree. Maybe it's me, some combination of laziness and short attention span as I age.. Btw, C doesn't offer a great solution here, though it offers leaving out some type names.In C++ I could have both .size and operator[].Modula-3 seems to be missing operator overloading.It's got some builtin stuff, even array assignment and equality and I think even record assignment and equality, but it is still a bit limiting. Also, if I understand things correctly, this has long bothered me about Modula-3, though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght objects. Like, small stack allocated structs with member functions. You seem to have to chose between heap allocated garbage collected virtual member functions full featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- objects don't have to be heap allocated and member functions don't have be virtual. Or am I missing something? Anyway, I've gotten to accept C a bit more vs. C++ so I can deal witht: Type;Type_DoSomething(t); in place of:t.DoSomething(); - Jay _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Mon Nov 12 06:16:32 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 05:16:32 +0000 Subject: [M3devel] test Message-ID: Is this working? - Jay _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sun Nov 11 23:36:39 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sun, 11 Nov 2007 14:36:39 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711112236.lABMad1c028825@camembert.async.caltech.edu> My only problem with it is that it is likely to break some programs, those that depend on the seconds field never exceeding 60. I think it's legitimate to ask whether it is not more reasonable to expect a well-written Modula-3 program(mer) to have used the contents of Date.i3 rather than the POSIX standard to decide how to treat the values of type Date.T.... Which are these "twilight zone" programs? I have no idea.. Mika Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Mon Nov 12 12:42:09 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 03:42:09 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711121142.lACBg95n060864@camembert.async.caltech.edu> Now it's not clear to me that [0..59] was wrong in the first place. The key thing to remember is that the following oft-repeated statement (from the FreeBSD time(3) man page)... The time() function returns the value of time in seconds since 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time. is actually wrong. Today, the "right"(*) specification is that the time() function returns a value that is currently 23 (I think that's the number) less than the number of seconds since the Unix epoch. This is obvious if you've ever noticed that the 0th second of a minute always comes out divisible by 60 in Unix time. The leap seconds are just not representable in Unix time. POSIX localtime can't return 60 for the seconds, because the same POSIX time represents two different seconds. Wikipedia talks about this a bit. They give the example of Unix time 915,148,800, which corresponds to BOTH 23:59:60 UTC on December 31, 1998 and 00:00:00 UTC on January 1, 1999. I am a bit baffled why POSIX bothers to have the 60 in their struct tm definition, if the underlying timeval data structure just can't represent the time in question. That is, when you pass 915,148,800 to Date.FromTime you probably get 00:00:00 UTC, Jan 1, 1999, and NOT 23:59:60 UTC, Dec. 31, 1998, even though both are equally correct. There is however a cryptic comment in my localtime man page that The asctime(), ctime(), difftime(), gmtime(), localtime(), and mktime() functions conform to ISO/IEC 9899:1990 (``ISO C90''), and conform to ISO/IEC 9945-1:1996 (``POSIX.1'') provided the selected local timezone does not contain a leap-second table (see zic(8)). I read the zic man page several times and am none the wiser!!!! ... that is, I don't know if POSIX functions localtime et al. can ever return 60 for the seconds field. Possibly FreeBSD ones may if zic is fed the proper information, but then does that mess up the Unix time values? (One would think it would have to.) I really just want to be sure that my server programs don't crash because they try to do something like s : [0..59] := 60 at an inopportune moment! (And your solution accomplishes that, at least.) Mika (*) actually the correct specification for the Unix time defines it in terms of UTC. Unix time = 86400*(# of days since Jan 1, 1970) + 3600 * UTC.hour + 60 * UTC.minute + UTC.second. It follows from this definition that Unix time maps neither linearly nor single-valuedly to actual time. Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Tue Nov 13 08:06:58 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 23:06:58 -0800 Subject: [M3devel] time conversion re-entrancy issues Message-ID: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Hello everyone, I just ran into this on the program I'm developing. It's a crash in my own code, but I believe that the conversion routines in Date.i3 aren't immune to it either... Program received signal SIGBUS, Bus error. ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 ThreadPosix.m3:126: No such file or directory. (gdb) where #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 #2 16_bfbfff94 in ?? () #3 16_6827e4c0 in tzsetwall () #4 16_6827e789 in localtime_r () #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, _result=RECORD year = 0; month = Jan; day = ; hour = 0; minute = 0; second = 0; offset = 2; zone = ; weekDay = ; END) at TZ.m3:47 #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, t=1194934056.6984761, prec=3, simplified=TRUE) at SafeTZ.m3:23 What's going on is that I'm converting a Time.T to a Date.T using my own conversion routine, which eventually calls the Unix localtime_r function (same procedure, done a bit more elaborately, as in the standard implementation of Date.FromTime). The problem is that localtime apparently under certain circumstances can call tzsetwall, which can take a while to run, as it involves reading timezone info from /usr/share/zoneinfo. My diagnosis is that the thread doing the conversion yielded, and then something in ThreadPosix (OK this is an old version, but the current version works the same) calls gettimeofday. And apparently gettimeofday isn't re-entrant w.r.t. tzsetwall. Is there a portable (i.e., across M3 versions) way of stopping all threadswitching activity while a call into some nasty C code is proceeding? I don't see how one can avoid it here... Mika From lemming at henning-thielemann.de Tue Nov 13 15:31:30 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue, 13 Nov 2007 15:31:30 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Mon, 12 Nov 2007, Jay wrote: > What is the right way to have a variably sized but always small array in > Modula-3?My array will only ever have 1 or 2 elements.I'd like to always > allocate room for 2 elements, and have there be a size. How about SUBARRAY of a two-element array? From hosking at cs.purdue.edu Tue Nov 13 17:57:29 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:57:29 -0500 Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Nov 13, 2007, at 9:31 AM, Henning Thielemann wrote: > > On Mon, 12 Nov 2007, Jay wrote: > >> What is the right way to have a variably sized but always small >> array in >> Modula-3?My array will only ever have 1 or 2 elements.I'd like to >> always >> allocate room for 2 elements, and have there be a size. > > How about SUBARRAY of a two-element array? Yes indeed! From hosking at cs.purdue.edu Tue Nov 13 17:56:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:56:05 -0500 Subject: [M3devel] time conversion re-entrancy issues In-Reply-To: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> References: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Message-ID: <49D06EC8-37FE-4876-A84E-A854E754A749@cs.purdue.edu> On Nov 13, 2007, at 2:06 AM, Mika Nystrom wrote: > Hello everyone, > > I just ran into this on the program I'm developing. It's a crash > in my > own code, but I believe that the conversion routines in Date.i3 aren't > immune to it either... > > > Program received signal SIGBUS, Bus error. > ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = > 1747444928; > END) at ThreadPosix.m3:126 > ThreadPosix.m3:126: No such file or directory. > (gdb) where > #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; > tv_usec = 1747444928; END) at ThreadPosix.m3:126 > #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 > #2 16_bfbfff94 in ?? () > #3 16_6827e4c0 in tzsetwall () > #4 16_6827e789 in localtime_r () > #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, > _result=RECORD year = 0; month = Jan; > day = ; hour = 0; minute > = 0; > second = 0; offset = 2; zone = Bad address>; > weekDay = ; END) at TZ.m3:47 > #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, > t=1194934056.6984761, > prec=3, simplified=TRUE) at SafeTZ.m3:23 > > What's going on is that I'm converting a Time.T to a Date.T using > my own conversion routine, which eventually calls the Unix > localtime_r function (same procedure, done a bit more elaborately, > as in the standard implementation of Date.FromTime). > > The problem is that localtime apparently under certain circumstances > can call tzsetwall, which can take a while to run, as it involves > reading > timezone info from /usr/share/zoneinfo. My diagnosis is that the > thread > doing the conversion yielded, and then something in ThreadPosix > (OK this is an old version, but the current version works the same) > calls gettimeofday. And apparently gettimeofday isn't re-entrant > w.r.t. > tzsetwall. > > Is there a portable (i.e., across M3 versions) way of stopping all > threadswitching activity while a call into some nasty C code is > proceeding? I don't see how one can avoid it here... Not really a portable way to do it. SchedulerPosix.DisableSwitching works when using ThreadPosix. For ThreadPThread SchedulerPosix.DisableSwitching is a no-op but the libraries should be thread-safe anyway so it probably works there too. What you really need is a lock somewhere. From mika at async.caltech.edu Tue Nov 13 21:41:40 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Tue, 13 Nov 2007 12:41:40 -0800 Subject: [M3devel] opening files under Win32 Message-ID: <200711132041.lADKfedp052254@camembert.async.caltech.edu> Hello again everyone, This may be a silly question, but does anyone out there in Modula-3-land know how to get more "Unix-like" semantics in opening files on Windows? I am using an old version of Modula-3 under "NT386GNU"/Cygwin and I'd like to open a file (for reading only) while another process has it open for writing (via FileWr.Open). Ideally, the method wouldn't change the writer at all, because I kind of like the fact that I have exclusive write access to the file (which avoids having to do all kinds of other external locking that is necessary when running the same program on Unix). I know what I'm trying to do is possible, because the Cygwin tools (like less, cp, etc.) can read the contents of the file, no problem, but when I try to open it with FileRd.Open, it doesn't work... Mika From rodney.bates at wichita.edu Fri Nov 16 01:39:18 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Thu, 15 Nov 2007 18:39:18 -0600 Subject: [M3devel] small array in modula-3? Message-ID: <473CE6B6.3030402@wichita.edu> Jay wrote: > What is the right way to have a variably sized but always small array in Modula-3? > My array will only ever have 1 or 2 elements. > I'd like to always allocate room for 2 elements, and have there be a size. > > It seems I have a choice of > > a) an "open" array Heap allocated, I presume? If the max size is only 2 elements, this is pretty extravagant, as a heap allocated open array will have 4 extra behind-the-scenes words of space overhead, plus maybe heap fragmentation, and time overhead of allocation, collection, and maybe reduced locality of reference. > b) wrap it up in a record > > I'd like so have, like: > > TYPE A = ARRAY [0..1] OF FOO; > > And be able to say: > > VAR > a : A; > > .. > a.size > FOR i := 0 TO a.size DO > do something with a[i] > > It seems I have no option but, like: > > TYPE A = RECORD > a: ARRAY[0..1] OF FOO; > size := 1; (* usually of size 1, sometimes 2 *) > END > > and then > FOR i := 0 TO a.size DO > do something with a.a[i]; > > That is "ok". Not great -- what to call the inner a? > But then furthermore, I'd like to construct constants. > It seems I am stuck with either the verbose: > > PROCEDURE F(a:A); > > F( A { ARRAY[0..1] OF FOO { .. } ); > > OR I have to come up with a name for the embedded array. > But of course, its type is really "the same" as the outer type. Ignoring the fact that the types are different linguistically (one a record type, the other an array), the types are different at a deep semantic level too. The inner array has static size, the outer one (call it a "variable array", perhaps) has dynamically changeable size, even more easily changed after it is created than a heap-allocated open array. This is a significant semantic difference, so it also makes program design sense to view them as different types. > > To wit: > > TYPE FooArray = ARRAY[0..1] OF Foo; > > TYPE FooArray = RECORD > a : FooArray; > size := 1; > END; > > F( FooArray { FooArray { .. } ); > > But I have to come up with different names. > > And I don't think I can leave out the name for the constructor, like: > > F( FooArray { { .. } ); Yes, this is a limitation in Modula-3. Ada allows value constructors to omit inner type names in cases like this, and it is convenient. But it also crosses a really major line on complexity of the language semantics, since type analysis information now flows not only upward, but also downward in expression typing. I am mostly content to live with this as one bit of the price of avoiding a horribly over complex language. Ordinary procedures can do pretty much all of the things done by exotic and complex language stuff like C++ constructors. If you don't want to write the ponderous nested value constructor, write a constructor procedure and call it. As Antony suggested, you can make it accept an open array formal, which then codes just like a simple array value constructor. You could even make it elaborate and general, e.g.: PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F = VAR LSize : CARDINAL ; VAR LResult : A ; BEGIN LSize := NUMBER ( Val ) <* ASSERT LSize <= NUMBER ( FooArray ) *> ; LResult . size := LSize ; SUBARRAY ( LResult . a , 0 , LSize ) := SUBARRAY ( Val , FIRST ( Val ) , LSize ) ; RETURN LResult END MakeF Alternatively, since your maximum element count is so small, you could write a constructor procedure that took two formals of type FOO, with at least the second one optional. (This would require a distinguished value of type FOO that would be used to mean "omitted".) And, of course, if you want to use abstraction, you can put the types, constructor procedures, and various other procedures for manipulating the variable sized array in a module, behind an interface. An additional limitation of Modula-3 in this regard, is that you can't make the type F opaque, unless you heap allocate it, which we were trying to avoid. Ada would allow you to do this, but it's another example of a convenience with high cost. It forces the equivalent of the revelation to be located in the equivalent of the interface, but makes it illegal to write client code that depends on what the revelation is. This in turn creates a source code control nightmare in a large project, because now someone who wants to make what is really a purely internal, implementation change, nevertheless has to check out the interface, and if you aren't in denial mode, that means implementers of all the client code have to go to extra trouble to somehow find out that what appears to be an interface change actually doesn't affect them after all. > > Though that might seem nice. > > Am I understanding everything? > > Have folks hit this before and there's a set of names that don't seem too lame > that folks use? > > Also -- language documentation? > Nelson's green book is excellent. > The stuff in the doc directory is very dry and scientific. > The tutorial seems more like a reference. Or maybe I didn't read it enough. > Is there better, in case I need a refresher? > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference, > but I don't think anyone could learn from the current online docs in the source tree. > > Maybe it's me, some combination of laziness and short attention span > as I age.. > > Btw, C doesn't offer a great solution here, though it offers leaving out some type names. > In C++ I could have both .size and operator[]. > Modula-3 seems to be missing operator overloading. > It's got some builtin stuff, even array assignment and equality and I think > even record assignment and equality, but it is still a bit limiting. I have raved on this before, but, having had lots of painful experience with user-defined overloading in Ada and C++, I can say with authority, that it is a programming language disaster. It interacts with just about everything else in the language, in very complicated ways, and all it buys you is saving time/energy thinking up distinct names for procedures/functions. Even this, aside from the effects on the language, is a net loss, by the time you consider readability along with writability. User-defined overloaded operators provide a slight readability benefit, _if_ used with great restraint and discipline, something you can rely on not happening. Meanwhile, the language complexity can easily double or worse. And, with the exception of compiler writers and language lawyers who spend hundreds of hours on just this, programmers don't understand the rules, not even close. > > Also, if I understand things correctly, this has long bothered me about Modula-3, > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght > objects. Like, small stack allocated structs with member functions. You seem to have > to chose between heap allocated garbage collected virtual member functions full > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- > objects don't have to be heap allocated and member functions don't have be virtual. > Or am I missing something? C++'s supposedly lighter weight forms of classes/structs with their special member functions buy nothing that plain records, plain procedures, and interfaces/modules don't already provide, again, at significant and gratuitous language complexity. Except when methods/member functions actually dispatch dynamically, there is nothing that the above won't do, and when you create a class instance as a local variable (i.e., on the stack), it is necessarily not polymorphic, that is, it can't change its "allocated" or dynamic type among various subtypes at runtime. This in turn means it can't dispatch. So, just use plain procedures, an interface and a module, and you will get everything a lighter-weight C++ class would give you. > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with > t: Type; > Type_DoSomething(t); > > in place of: > t.DoSomething(); Exactly. The special "receiver object" in a true method call has significant semantic differences from an ordinary parameter and introduces new complexities and non-orthogonalities. It has some very valuable uses too. But to then create degenerate forms of it that still carry a lot of these complexities, but are equivalent in programing power to plain old parameters is just bad program design and bad language design. Objects and methods are indeed cool for situations that utilize their semantic complexity. But it's deeply uncool to try to look superficially cool by using an inappropriately sophisticated construct when the problem doesn't justify it. Some OO proponents have gone way over the deep end here. > > - Jay > > > ------------------------------------------------------------------------ > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From jay.krell at cornell.edu Fri Nov 16 05:08:22 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:08:22 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: Rodney, thank you, this is interesting. I definitely don't want to pay for heap allocation for a tiny array. I don't know about "subarray". It looks like it takes and returns arrays. It's not a type. I ordered another copy of the Nelson book so I don't have to find mine. Good idea "MakeT" I forgot about that pattern. I'll try it out. The record and array I propose are not all that different really. I just heard of something new. Have you heard of it? "Duck typing". If it acts/quacks/walks like a duck, it is a duck. This is in very dynamic languages like Ruby. You apply object.method and if object defines something named "method", then it "must" have "the" meaning you intend. Kind of like how C++ templates "accept as parameters whatever happens to work". Operator overloading is great for strings and "math". Maybe I should try to have this language debate from scratch again..? I still am conflcted. Modules seem overly heavyweight. I don't want Module1.T, Module2.T, I want T1, T2. C++ stack structs with non virtual member functions: class Rect_t { Rect_t() : top(0), left(0), right(0), bottom(0) { } int Height() { return bottom - top; } int Width() { return right - left; } int top, left, bottom, right; }; seems "good". And it seems not really all that complicated for the compiler to flow the static type information around to resolve the functions.. Rect_t r; r.Height() => Rect_Height(&r); ..and would be inlined anyway. I do find some compelling features in Modula-3. Mainly that it compiles to native code and has OPTIONAL safety, optional garbage collection, and that the syntax of modules/interfaces allows fast compilation -- no longer reparsing the same headers over and over and over and over. Operator overloading btw..have seen "template SafeInt"? It acts like a primitive integer, but raises exceptions upon overflow. For this to work very much requires operator overloading. A point, of course, is to be able to have user defined types that can act like the built in types.. - Jay > Date: Thu, 15 Nov 2007 18:39:18 -0600> From: rodney.bates at wichita.edu> To: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > Jay wrote:> > > What is the right way to have a variably sized but always small array in Modula-3?> > My array will only ever have 1 or 2 elements.> > I'd like to always allocate room for 2 elements, and have there be a size.> >> > It seems I have a choice of> >> > a) an "open" array> > Heap allocated, I presume? If the max size is only 2 elements,> this is pretty extravagant, as a heap allocated open array will> have 4 extra behind-the-scenes words of space overhead, plus> maybe heap fragmentation, and time overhead of allocation,> collection, and maybe reduced locality of reference.> > > b) wrap it up in a record> >> > I'd like so have, like:> >> > TYPE A = ARRAY [0..1] OF FOO;> >> > And be able to say:> >> > VAR> > a : A;> >> > ..> > a.size> > FOR i := 0 TO a.size DO> > do something with a[i]> >> > It seems I have no option but, like:> >> > TYPE A = RECORD> > a: ARRAY[0..1] OF FOO;> > size := 1; (* usually of size 1, sometimes 2 *)> > END> >> > and then> > FOR i := 0 TO a.size DO> > do something with a.a[i];> >> > That is "ok". Not great -- what to call the inner a?> > But then furthermore, I'd like to construct constants.> > It seems I am stuck with either the verbose:> >> > PROCEDURE F(a:A);> >> > F( A { ARRAY[0..1] OF FOO { .. } );> >> > OR I have to come up with a name for the embedded array.> > But of course, its type is really "the same" as the outer type.> > > Ignoring the fact that the types are different linguistically> (one a record type, the other an array), the types are different> at a deep semantic level too. The inner array has static> size, the outer one (call it a "variable array", perhaps)> has dynamically changeable size, even more easily changed> after it is created than a heap-allocated open array. This> is a significant semantic difference, so it also makes program> design sense to view them as different types.> > >> > To wit:> >> > TYPE FooArray = ARRAY[0..1] OF Foo;> >> > TYPE FooArray = RECORD> > a : FooArray;> > size := 1;> > END;> >> > F( FooArray { FooArray { .. } );> >> > But I have to come up with different names.> >> > And I don't think I can leave out the name for the constructor, like:> >> > F( FooArray { { .. } );> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> to omit inner type names in cases like this, and it is convenient. But> it also crosses a really major line on complexity of the language semantics,> since type analysis information now flows not only upward, but also downward> in expression typing. I am mostly content to live with this as one bit of> the price of avoiding a horribly over complex language.> > Ordinary procedures can do pretty much all of the things done by exotic> and complex language stuff like C++ constructors. If you don't want to write> the ponderous nested value constructor, write a constructor procedure and> call it. As Antony suggested, you can make it accept an open array formal,> which then codes just like a simple array value constructor. You could even> make it elaborate and general, e.g.:> > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > = VAR LSize : CARDINAL> ; VAR LResult : A> > ; BEGIN> LSize := NUMBER ( Val )> <* ASSERT LSize <= NUMBER ( FooArray ) *>> ; LResult . size := LSize> ; SUBARRAY ( LResult . a , 0 , LSize )> := SUBARRAY ( Val , FIRST ( Val ) , LSize )> ; RETURN LResult> END MakeF> > Alternatively, since your maximum element count is so small, you could> write a constructor procedure that took two formals of type FOO, with> at least the second one optional. (This would require a distinguished> value of type FOO that would be used to mean "omitted".)> > And, of course, if you want to use abstraction, you can put the types,> constructor procedures, and various other procedures for manipulating> the variable sized array in a module, behind an interface.> > An additional limitation of Modula-3 in this regard, is that you can't> make the type F opaque, unless you heap allocate it, which we were trying> to avoid. Ada would allow you to do this, but it's another example of> a convenience with high cost. It forces the equivalent of the revelation> to be located in the equivalent of the interface, but makes it illegal> to write client code that depends on what the revelation is.> > This in turn creates a source code control nightmare in a large project,> because now someone who wants to make what is really a purely internal,> implementation change, nevertheless has to check out the interface, and> if you aren't in denial mode, that means implementers of all the client> code have to go to extra trouble to somehow find out that what appears> to be an interface change actually doesn't affect them after all.> > >> > Though that might seem nice.> >> > Am I understanding everything?> >> > Have folks hit this before and there's a set of names that don't seem too lame> > that folks use?> >> > Also -- language documentation?> > Nelson's green book is excellent.> > The stuff in the doc directory is very dry and scientific.> > The tutorial seems more like a reference. Or maybe I didn't read it enough.> > Is there better, in case I need a refresher?> > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,> > but I don't think anyone could learn from the current online docs in the source tree.> >> > Maybe it's me, some combination of laziness and short attention span> > as I age..> >> > Btw, C doesn't offer a great solution here, though it offers leaving out some type names.> > In C++ I could have both .size and operator[].> > Modula-3 seems to be missing operator overloading.> > It's got some builtin stuff, even array assignment and equality and I think> > even record assignment and equality, but it is still a bit limiting.> > > I have raved on this before, but, having had lots of painful experience with> user-defined overloading in Ada and C++, I can say with authority, that it is> a programming language disaster. It interacts with just about everything> else in the language, in very complicated ways, and all it buys you is saving> time/energy thinking up distinct names for procedures/functions. Even this,> aside from the effects on the language, is a net loss, by the time you consider> readability along with writability.> > User-defined overloaded operators provide a slight readability benefit, _if_> used with great restraint and discipline, something you can rely on not happening.> Meanwhile, the language complexity can easily double or worse. And, with the> exception of compiler writers and language lawyers who spend hundreds of hours> on just this, programmers don't understand the rules, not even close.> > >> > Also, if I understand things correctly, this has long bothered me about Modula-3,> > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght> > objects. Like, small stack allocated structs with member functions. You seem to have> > to chose between heap allocated garbage collected virtual member functions full> > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids --> > objects don't have to be heap allocated and member functions don't have be virtual.> > Or am I missing something?> > > C++'s supposedly lighter weight forms of classes/structs with their special> member functions buy nothing that plain records, plain procedures, and> interfaces/modules don't already provide, again, at significant and gratuitous> language complexity. Except when methods/member functions actually dispatch> dynamically, there is nothing that the above won't do, and when you create a> class instance as a local variable (i.e., on the stack), it is necessarily> not polymorphic, that is, it can't change its "allocated" or dynamic type> among various subtypes at runtime. This in turn means it can't dispatch.> > So, just use plain procedures, an interface and a module, and you will get> everything a lighter-weight C++ class would give you.> > > >> > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with> > t: Type;> > Type_DoSomething(t);> >> > in place of:> > t.DoSomething();> > > Exactly. The special "receiver object" in a true method call has significant> semantic differences from an ordinary parameter and introduces new complexities> and non-orthogonalities. It has some very valuable uses too.> > But to then create degenerate forms of it that still carry a lot of these> complexities, but are equivalent in programing power to plain old> parameters is just bad program design and bad language design. Objects and> methods are indeed cool for situations that utilize their semantic complexity.> But it's deeply uncool to try to look superficially cool by using an> inappropriately sophisticated construct when the problem doesn't justify it.> Some OO proponents have gone way over the deep end here.> > >> > - Jay> >> >> > ------------------------------------------------------------------------> > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! > > > > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu> > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:15:27 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:15:27 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Is it really four words? I would have thought it might need a type reference and a size, what are the others for? On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > Jay wrote: > > > What is the right way to have a variably sized but always small > array in Modula-3? > > My array will only ever have 1 or 2 elements. > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > It seems I have a choice of > > > > a) an "open" array > > Heap allocated, I presume? If the max size is only 2 elements, > this is pretty extravagant, as a heap allocated open array will > have 4 extra behind-the-scenes words of space overhead, plus > maybe heap fragmentation, and time overhead of allocation, > collection, and maybe reduced locality of reference. > > > b) wrap it up in a record > > > > I'd like so have, like: > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > And be able to say: > > > > VAR > > a : A; > > > > .. > > a.size > > FOR i := 0 TO a.size DO > > do something with a[i] > > > > It seems I have no option but, like: > > > > TYPE A = RECORD > > a: ARRAY[0..1] OF FOO; > > size := 1; (* usually of size 1, sometimes 2 *) > > END > > > > and then > > FOR i := 0 TO a.size DO > > do something with a.a[i]; > > > > That is "ok". Not great -- what to call the inner a? > > But then furthermore, I'd like to construct constants. > > It seems I am stuck with either the verbose: > > > > PROCEDURE F(a:A); > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > OR I have to come up with a name for the embedded array. > > But of course, its type is really "the same" as the outer type. > > > Ignoring the fact that the types are different linguistically > (one a record type, the other an array), the types are different > at a deep semantic level too. The inner array has static > size, the outer one (call it a "variable array", perhaps) > has dynamically changeable size, even more easily changed > after it is created than a heap-allocated open array. This > is a significant semantic difference, so it also makes program > design sense to view them as different types. > > > > > To wit: > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > TYPE FooArray = RECORD > > a : FooArray; > > size := 1; > > END; > > > > F( FooArray { FooArray { .. } ); > > > > But I have to come up with different names. > > > > And I don't think I can leave out the name for the constructor, > like: > > > > F( FooArray { { .. } ); > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > to omit inner type names in cases like this, and it is convenient. > But > it also crosses a really major line on complexity of the language > semantics, > since type analysis information now flows not only upward, but also > downward > in expression typing. I am mostly content to live with this as one > bit of > the price of avoiding a horribly over complex language. > > Ordinary procedures can do pretty much all of the things done by > exotic > and complex language stuff like C++ constructors. If you don't > want to write > the ponderous nested value constructor, write a constructor > procedure and > call it. As Antony suggested, you can make it accept an open array > formal, > which then codes just like a simple array value constructor. You > could even > make it elaborate and general, e.g.: > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > = VAR LSize : CARDINAL > ; VAR LResult : A > > ; BEGIN > LSize := NUMBER ( Val ) > <* ASSERT LSize <= NUMBER ( FooArray ) *> > ; LResult . size := LSize > ; SUBARRAY ( LResult . a , 0 , LSize ) > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > ; RETURN LResult > END MakeF > > Alternatively, since your maximum element count is so small, you could > write a constructor procedure that took two formals of type FOO, with > at least the second one optional. (This would require a distinguished > value of type FOO that would be used to mean "omitted".) > > And, of course, if you want to use abstraction, you can put the types, > constructor procedures, and various other procedures for manipulating > the variable sized array in a module, behind an interface. > > An additional limitation of Modula-3 in this regard, is that you can't > make the type F opaque, unless you heap allocate it, which we were > trying > to avoid. Ada would allow you to do this, but it's another example of > a convenience with high cost. It forces the equivalent of the > revelation > to be located in the equivalent of the interface, but makes it illegal > to write client code that depends on what the revelation is. > > This in turn creates a source code control nightmare in a large > project, > because now someone who wants to make what is really a purely > internal, > implementation change, nevertheless has to check out the interface, > and > if you aren't in denial mode, that means implementers of all the > client > code have to go to extra trouble to somehow find out that what appears > to be an interface change actually doesn't affect them after all. > > > > > Though that might seem nice. > > > > Am I understanding everything? > > > > Have folks hit this before and there's a set of names that don't > seem too lame > > that folks use? > > > > Also -- language documentation? > > Nelson's green book is excellent. > > The stuff in the doc directory is very dry and scientific. > > The tutorial seems more like a reference. Or maybe I didn't read > it enough. > > Is there better, in case I need a refresher? > > I think I got it, via Nelson's book from memory (wonder if I can > find mine..) and the reference, > > but I don't think anyone could learn from the current online docs > in the source tree. > > > > Maybe it's me, some combination of laziness and short attention span > > as I age.. > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > In C++ I could have both .size and operator[]. > > Modula-3 seems to be missing operator overloading. > > It's got some builtin stuff, even array assignment and equality > and I think > > even record assignment and equality, but it is still a bit > limiting. > > > I have raved on this before, but, having had lots of painful > experience with > user-defined overloading in Ada and C++, I can say with authority, > that it is > a programming language disaster. It interacts with just about > everything > else in the language, in very complicated ways, and all it buys you > is saving > time/energy thinking up distinct names for procedures/functions. > Even this, > aside from the effects on the language, is a net loss, by the time > you consider > readability along with writability. > > User-defined overloaded operators provide a slight readability > benefit, _if_ > used with great restraint and discipline, something you can rely on > not happening. > Meanwhile, the language complexity can easily double or worse. > And, with the > exception of compiler writers and language lawyers who spend > hundreds of hours > on just this, programmers don't understand the rules, not even close. > > > > > Also, if I understand things correctly, this has long bothered me > about Modula-3, > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > objects. Like, small stack allocated structs with member > functions. You seem to have > > to chose between heap allocated garbage collected virtual member > functions full > > featured objects, or featureless dumb structs. It's nice how C++ > allow hybrids -- > > objects don't have to be heap allocated and member functions > don't have be virtual. > > Or am I missing something? > > > C++'s supposedly lighter weight forms of classes/structs with their > special > member functions buy nothing that plain records, plain procedures, and > interfaces/modules don't already provide, again, at significant and > gratuitous > language complexity. Except when methods/member functions actually > dispatch > dynamically, there is nothing that the above won't do, and when you > create a > class instance as a local variable (i.e., on the stack), it is > necessarily > not polymorphic, that is, it can't change its "allocated" or > dynamic type > among various subtypes at runtime. This in turn means it can't > dispatch. > > So, just use plain procedures, an interface and a module, and you > will get > everything a lighter-weight C++ class would give you. > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal > with > > t: Type; > > Type_DoSomething(t); > > > > in place of: > > t.DoSomething(); > > > Exactly. The special "receiver object" in a true method call has > significant > semantic differences from an ordinary parameter and introduces new > complexities > and non-orthogonalities. It has some very valuable uses too. > > But to then create degenerate forms of it that still carry a lot of > these > complexities, but are equivalent in programing power to plain old > parameters is just bad program design and bad language design. > Objects and > methods are indeed cool for situations that utilize their semantic > complexity. > But it's deeply uncool to try to look superficially cool by using an > inappropriately sophisticated construct when the problem doesn't > justify it. > Some OO proponents have gone way over the deep end here. > > > > > - Jay > > > > > > > ---------------------------------------------------------------------- > -- > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! trial.aspx?s_cid=wl_hotmailnews> > > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu From darko at darko.org Fri Nov 16 05:29:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:29:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Not sure what the problem is with modules. If you want to avoid the dot you can name the type something unique then import that type name. You can create an interface with all the nice type names and import all those names in modules by adding an EXPORTS clause too. Personally I think M3, with a couple of extensions, wouldn't need unsafe anything. The unsafe features are there mostly because of legacy interfaces. I forget the name but the folk who wrote an OS in M3 found it very effective with only couple of minor points with regards to interfacing to C code they built on top of, I think one of them was being able to pass NIL to a VAR parameter, which is a common C idiom (and an annoying one for M3 users who then can't use VAR). On 15/11/2007, at 8:08 PM, Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book > so I don't have to find mine. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". > If it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named > "method", then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever > happens to work". > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; > > seems "good". > > And it seems not really all that complicated for the compiler to > flow the static type information around to resolve the functions.. > > Rect_t r; > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > I do find some compelling features in Modula-3. Mainly that it > compiles to native code and has OPTIONAL safety, optional garbage > collection, and that the syntax of modules/interfaces allows fast > compilation -- no longer reparsing the same headers over and over > and over and over. > > Operator overloading btw..have seen "template SafeInt"? It acts > like a primitive integer, but raises exceptions upon overflow. > For this to work very much requires operator overloading. > > A point, of course, is to be able to have user defined types that > can act like the built in types.. > > - Jay > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > From: rodney.bates at wichita.edu > > To: m3devel at elegosoft.com > > Subject: Re: [M3devel] small array in modula-3? > > > > Jay wrote: > > > > > What is the right way to have a variably sized but always small > array in Modula-3? > > > My array will only ever have 1 or 2 elements. > > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > > > It seems I have a choice of > > > > > > a) an "open" array > > > > Heap allocated, I presume? If the max size is only 2 elements, > > this is pretty extravagant, as a heap allocated open array will > > have 4 extra behind-the-scenes words of space overhead, plus > > maybe heap fragmentation, and time overhead of allocation, > > collection, and maybe reduced locality of reference. > > > > > b) wrap it up in a record > > > > > > I'd like so have, like: > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > And be able to say: > > > > > > VAR > > > a : A; > > > > > > .. > > > a.size > > > FOR i := 0 TO a.size DO > > > do something with a[i] > > > > > > It seems I have no option but, like: > > > > > > TYPE A = RECORD > > > a: ARRAY[0..1] OF FOO; > > > size := 1; (* usually of size 1, sometimes 2 *) > > > END > > > > > > and then > > > FOR i := 0 TO a.size DO > > > do something with a.a[i]; > > > > > > That is "ok". Not great -- what to call the inner a? > > > But then furthermore, I'd like to construct constants. > > > It seems I am stuck with either the verbose: > > > > > > PROCEDURE F(a:A); > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > OR I have to come up with a name for the embedded array. > > > But of course, its type is really "the same" as the outer type. > > > > > > Ignoring the fact that the types are different linguistically > > (one a record type, the other an array), the types are different > > at a deep semantic level too. The inner array has static > > size, the outer one (call it a "variable array", perhaps) > > has dynamically changeable size, even more easily changed > > after it is created than a heap-allocated open array. This > > is a significant semantic difference, so it also makes program > > design sense to view them as different types. > > > > > > > > To wit: > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > TYPE FooArray = RECORD > > > a : FooArray; > > > size := 1; > > > END; > > > > > > F( FooArray { FooArray { .. } ); > > > > > > But I have to come up with different names. > > > > > > And I don't think I can leave out the name for the constructor, > like: > > > > > > F( FooArray { { .. } ); > > > > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > > to omit inner type names in cases like this, and it is > convenient. But > > it also crosses a really major line on complexity of the language > semantics, > > since type analysis information now flows not only upward, but > also downward > > in expression typing. I am mostly content to live with this as > one bit of > > the price of avoiding a horribly over complex language. > > > > Ordinary procedures can do pretty much all of the things done by > exotic > > and complex language stuff like C++ constructors. If you don't > want to write > > the ponderous nested value constructor, write a constructor > procedure and > > call it. As Antony suggested, you can make it accept an open > array formal, > > which then codes just like a simple array value constructor. You > could even > > make it elaborate and general, e.g.: > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > = VAR LSize : CARDINAL > > ; VAR LResult : A > > > > ; BEGIN > > LSize := NUMBER ( Val ) > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > ; LResult . size := LSize > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > ; RETURN LResult > > END MakeF > > > > Alternatively, since your maximum element count is so small, you > could > > write a constructor procedure that took two formals of type FOO, > with > > at least the second one optional. (This would require a > distinguished > > value of type FOO that would be used to mean "omitted".) > > > > And, of course, if you want to use abstraction, you can put the > types, > > constructor procedures, and various other procedures for > manipulating > > the variable sized array in a module, behind an interface. > > > > An additional limitation of Modula-3 in this regard, is that you > can't > > make the type F opaque, unless you heap allocate it, which we > were trying > > to avoid. Ada would allow you to do this, but it's another > example of > > a convenience with high cost. It forces the equivalent of the > revelation > > to be located in the equivalent of the interface, but makes it > illegal > > to write client code that depends on what the revelation is. > > > > This in turn creates a source code control nightmare in a large > project, > > because now someone who wants to make what is really a purely > internal, > > implementation change, nevertheless has to check out the > interface, and > > if you aren't in denial mode, that means implementers of all the > client > > code have to go to extra trouble to somehow find out that what > appears > > to be an interface change actually doesn't affect them after all. > > > > > > > > Though that might seem nice. > > > > > > Am I understanding everything? > > > > > > Have folks hit this before and there's a set of names that > don't seem too lame > > > that folks use? > > > > > > Also -- language documentation? > > > Nelson's green book is excellent. > > > The stuff in the doc directory is very dry and scientific. > > > The tutorial seems more like a reference. Or maybe I didn't > read it enough. > > > Is there better, in case I need a refresher? > > > I think I got it, via Nelson's book from memory (wonder if I > can find mine..) and the reference, > > > but I don't think anyone could learn from the current online > docs in the source tree. > > > > > > Maybe it's me, some combination of laziness and short attention > span > > > as I age.. > > > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > > In C++ I could have both .size and operator[]. > > > Modula-3 seems to be missing operator overloading. > > > It's got some builtin stuff, even array assignment and equality > and I think > > > even record assignment and equality, but it is still a bit > limiting. > > > > > > I have raved on this before, but, having had lots of painful > experience with > > user-defined overloading in Ada and C++, I can say with > authority, that it is > > a programming language disaster. It interacts with just about > everything > > else in the language, in very complicated ways, and all it buys > you is saving > > time/energy thinking up distinct names for procedures/functions. > Even this, > > aside from the effects on the language, is a net loss, by the > time you consider > > readability along with writability. > > > > User-defined overloaded operators provide a slight readability > benefit, _if_ > > used with great restraint and discipline, something you can rely > on not happening. > > Meanwhile, the language complexity can easily double or worse. > And, with the > > exception of compiler writers and language lawyers who spend > hundreds of hours > > on just this, programmers don't understand the rules, not even > close. > > > > > > > > Also, if I understand things correctly, this has long bothered > me about Modula-3, > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > > objects. Like, small stack allocated structs with member > functions. You seem to have > > > to chose between heap allocated garbage collected virtual > member functions full > > > featured objects, or featureless dumb structs. It's nice how C+ > + allow hybrids -- > > > objects don't have to be heap allocated and member functions > don't have be virtual. > > > Or am I missing something? > > > > > > C++'s supposedly lighter weight forms of classes/structs with > their special > > member functions buy nothing that plain records, plain > procedures, and > > interfaces/modules don't already provide, again, at significant > and gratuitous > > language complexity. Except when methods/member functions > actually dispatch > > dynamically, there is nothing that the above won't do, and when > you create a > > class instance as a local variable (i.e., on the stack), it is > necessarily > > not polymorphic, that is, it can't change its "allocated" or > dynamic type > > among various subtypes at runtime. This in turn means it can't > dispatch. > > > > So, just use plain procedures, an interface and a module, and you > will get > > everything a lighter-weight C++ class would give you. > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > deal with > > > t: Type; > > > Type_DoSomething(t); > > > > > > in place of: > > > t.DoSomething(); > > > > > > Exactly. The special "receiver object" in a true method call has > significant > > semantic differences from an ordinary parameter and introduces > new complexities > > and non-orthogonalities. It has some very valuable uses too. > > > > But to then create degenerate forms of it that still carry a lot > of these > > complexities, but are equivalent in programing power to plain old > > parameters is just bad program design and bad language design. > Objects and > > methods are indeed cool for situations that utilize their > semantic complexity. > > But it's deeply uncool to try to look superficially cool by using an > > inappropriately sophisticated construct when the problem doesn't > justify it. > > Some OO proponents have gone way over the deep end here. > > > > > > > > - Jay > > > > > > > > > > ---------------------------------------------------------------------- > -- > > > Boo! Scare away worms, viruses and so much more! Try Windows > Live OneCare! Try now! > > s_cid=wl_hotmailnews> > > > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! From jay.krell at cornell.edu Fri Nov 16 05:40:40 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:40:40 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: But if I don't want to pay for heap allocation, I can't say: VAR T: v; v.DoSomething(); Only IMPORT T FROM M; VAR T: v; M.DoSomething(v); Right? SPIN I think you mean. Anyone build it and bring it up? I was long curious but never did.. - Jay > CC: m3devel at elegosoft.com> From: darko at darko.org> Subject: Re: [M3devel] small array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.krell at cornell.edu> > Not sure what the problem is with modules. If you want to avoid the > dot you can name the type something unique then import that type > name. You can create an interface with all the nice type names and > import all those names in modules by adding an EXPORTS clause too.> > Personally I think M3, with a couple of extensions, wouldn't need > unsafe anything. The unsafe features are there mostly because of > legacy interfaces. I forget the name but the folk who wrote an OS in > M3 found it very effective with only couple of minor points with > regards to interfacing to C code they built on top of, I think one of > them was being able to pass NIL to a VAR parameter, which is a common > C idiom (and an annoying one for M3 users who then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > > Rodney, thank you, this is interesting.> > I definitely don't want to pay for heap allocation for a tiny array.> > I don't know about "subarray". It looks like it takes and returns > > arrays. It's not a type. I ordered another copy of the Nelson book > > so I don't have to find mine.> >> > Good idea "MakeT" I forgot about that pattern. I'll try it out.> >> > The record and array I propose are not all that different really.> > I just heard of something new. Have you heard of it? "Duck typing". > > If it acts/quacks/walks like a duck, it is a duck.> > This is in very dynamic languages like Ruby.> > You apply object.method and if object defines something named > > "method", then it "must" have "the" meaning you intend.> > Kind of like how C++ templates "accept as parameters whatever > > happens to work".> >> > Operator overloading is great for strings and "math".> >> > Maybe I should try to have this language debate from scratch again..?> >> > I still am conflcted.> >> > Modules seem overly heavyweight.> > I don't want Module1.T, Module2.T, I want T1, T2.> >> > C++ stack structs with non virtual member functions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(0) { }> >> > int Height() { return bottom - top; }> > int Width() { return right - left; }> > int top, left, bottom, right;> > };> >> > seems "good".> >> > And it seems not really all that complicated for the compiler to > > flow the static type information around to resolve the functions..> >> > Rect_t r;> > r.Height() => Rect_Height(&r); ..and would be inlined anyway.> >> > I do find some compelling features in Modula-3. Mainly that it > > compiles to native code and has OPTIONAL safety, optional garbage > > collection, and that the syntax of modules/interfaces allows fast > > compilation -- no longer reparsing the same headers over and over > > and over and over.> >> > Operator overloading btw..have seen "template SafeInt"? It acts > > like a primitive integer, but raises exceptions upon overflow.> > For this to work very much requires operator overloading.> >> > A point, of course, is to be able to have user defined types that > > can act like the built in types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:18 -0600> > > From: rodney.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > Subject: Re: [M3devel] small array in modula-3?> > >> > > Jay wrote:> > >> > > > What is the right way to have a variably sized but always small > > array in Modula-3?> > > > My array will only ever have 1 or 2 elements.> > > > I'd like to always allocate room for 2 elements, and have there > > be a size.> > > >> > > > It seems I have a choice of> > > >> > > > a) an "open" array> > >> > > Heap allocated, I presume? If the max size is only 2 elements,> > > this is pretty extravagant, as a heap allocated open array will> > > have 4 extra behind-the-scenes words of space overhead, plus> > > maybe heap fragmentation, and time overhead of allocation,> > > collection, and maybe reduced locality of reference.> > >> > > > b) wrap it up in a record> > > >> > > > I'd like so have, like:> > > >> > > > TYPE A = ARRAY [0..1] OF FOO;> > > >> > > > And be able to say:> > > >> > > > VAR> > > > a : A;> > > >> > > > ..> > > > a.size> > > > FOR i := 0 TO a.size DO> > > > do something with a[i]> > > >> > > > It seems I have no option but, like:> > > >> > > > TYPE A = RECORD> > > > a: ARRAY[0..1] OF FOO;> > > > size := 1; (* usually of size 1, sometimes 2 *)> > > > END> > > >> > > > and then> > > > FOR i := 0 TO a.size DO> > > > do something with a.a[i];> > > >> > > > That is "ok". Not great -- what to call the inner a?> > > > But then furthermore, I'd like to construct constants.> > > > It seems I am stuck with either the verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name for the embedded array.> > > > But of course, its type is really "the same" as the outer type.> > >> > >> > > Ignoring the fact that the types are different linguistically> > > (one a record type, the other an array), the types are different> > > at a deep semantic level too. The inner array has static> > > size, the outer one (call it a "variable array", perhaps)> > > has dynamically changeable size, even more easily changed> > > after it is created than a heap-allocated open array. This> > > is a significant semantic difference, so it also makes program> > > design sense to view them as different types.> > >> > > >> > > > To wit:> > > >> > > > TYPE FooArray = ARRAY[0..1] OF Foo;> > > >> > > > TYPE FooArray = RECORD> > > > a : FooArray;> > > > size := 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );> > > >> > > > But I have to come up with different names.> > > >> > > > And I don't think I can leave out the name for the constructor, > > like:> > > >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> > > to omit inner type names in cases like this, and it is > > convenient. But> > > it also crosses a really major line on complexity of the language > > semantics,> > > since type analysis information now flows not only upward, but > > also downward> > > in expression typing. I am mostly content to live with this as > > one bit of> > > the price of avoiding a horribly over complex language.> > >> > > Ordinary procedures can do pretty much all of the things done by > > exotic> > > and complex language stuff like C++ constructors. If you don't > > want to write> > > the ponderous nested value constructor, write a constructor > > procedure and> > > call it. As Antony suggested, you can make it accept an open > > array formal,> > > which then codes just like a simple array value constructor. You > > could even> > > make it elaborate and general, e.g.:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = VAR LSize : CARDINAL> > > ; VAR LResult : A> > >> > > ; BEGIN> > > LSize := NUMBER ( Val )> > > <* ASSERT LSize <= NUMBER ( FooArray ) *>> > > ; LResult . size := LSize> > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > := SUBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RETURN LResult> > > END MakeF> > >> > > Alternatively, since your maximum element count is so small, you > > could> > > write a constructor procedure that took two formals of type FOO, > > with> > > at least the second one optional. (This would require a > > distinguished> > > value of type FOO that would be used to mean "omitted".)> > >> > > And, of course, if you want to use abstraction, you can put the > > types,> > > constructor procedures, and various other procedures for > > manipulating> > > the variable sized array in a module, behind an interface.> > >> > > An additional limitation of Modula-3 in this regard, is that you > > can't> > > make the type F opaque, unless you heap allocate it, which we > > were trying> > > to avoid. Ada would allow you to do this, but it's another > > example of> > > a convenience with high cost. It forces the equivalent of the > > revelation> > > to be located in the equivalent of the interface, but makes it > > illegal> > > to write client code that depends on what the revelation is.> > >> > > This in turn creates a source code control nightmare in a large > > project,> > > because now someone who wants to make what is really a purely > > internal,> > > implementation change, nevertheless has to check out the > > interface, and> > > if you aren't in denial mode, that means implementers of all the > > client> > > code have to go to extra trouble to somehow find out that what > > appears> > > to be an interface change actually doesn't affect them after all.> > >> > > >> > > > Though that might seem nice.> > > >> > > > Am I understanding everything?> > > >> > > > Have folks hit this before and there's a set of names that > > don't seem too lame> > > > that folks use?> > > >> > > > Also -- language documentation?> > > > Nelson's green book is excellent.> > > > The stuff in the doc directory is very dry and scientific.> > > > The tutorial seems more like a reference. Or maybe I didn't > > read it enough.> > > > Is there better, in case I need a refresher?> > > > I think I got it, via Nelson's book from memory (wonder if I > > can find mine..) and the reference,> > > > but I don't think anyone could learn from the current online > > docs in the source tree.> > > >> > > > Maybe it's me, some combination of laziness and short attention > > span> > > > as I age..> > > >> > > > Btw, C doesn't offer a great solution here, though it offers > > leaving out some type names.> > > > In C++ I could have both .size and operator[].> > > > Modula-3 seems to be missing operator overloading.> > > > It's got some builtin stuff, even array assignment and equality > > and I think> > > > even record assignment and equality, but it is still a bit > > limiting.> > >> > >> > > I have raved on this before, but, having had lots of painful > > experience with> > > user-defined overloading in Ada and C++, I can say with > > authority, that it is> > > a programming language disaster. It interacts with just about > > everything> > > else in the language, in very complicated ways, and all it buys > > you is saving> > > time/energy thinking up distinct names for procedures/functions. > > Even this,> > > aside from the effects on the language, is a net loss, by the > > time you consider> > > readability along with writability.> > >> > > User-defined overloaded operators provide a slight readability > > benefit, _if_> > > used with great restraint and discipline, something you can rely > > on not happening.> > > Meanwhile, the language complexity can easily double or worse. > > And, with the> > > exception of compiler writers and language lawyers who spend > > hundreds of hours> > > on just this, programmers don't understand the rules, not even > > close.> > >> > > >> > > > Also, if I understand things correctly, this has long bothered > > me about Modula-3,> > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > > objects. Like, small stack allocated structs with member > > functions. You seem to have> > > > to chose between heap allocated garbage collected virtual > > member functions full> > > > featured objects, or featureless dumb structs. It's nice how C+ > > + allow hybrids --> > > > objects don't have to be heap allocated and member functions > > don't have be virtual.> > > > Or am I missing something?> > >> > >> > > C++'s supposedly lighter weight forms of classes/structs with > > their special> > > member functions buy nothing that plain records, plain > > procedures, and> > > interfaces/modules don't already provide, again, at significant > > and gratuitous> > > language complexity. Except when methods/member functions > > actually dispatch> > > dynamically, there is nothing that the above won't do, and when > > you create a> > > class instance as a local variable (i.e., on the stack), it is > > necessarily> > > not polymorphic, that is, it can't change its "allocated" or > > dynamic type> > > among various subtypes at runtime. This in turn means it can't > > dispatch.> > >> > > So, just use plain procedures, an interface and a module, and you > > will get> > > everything a lighter-weight C++ class would give you.> > >> > >> > > >> > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > deal with> > > > t: Type;> > > > Type_DoSomething(t);> > > >> > > > in place of:> > > > t.DoSomething();> > >> > >> > > Exactly. The special "receiver object" in a true method call has > > significant> > > semantic differences from an ordinary parameter and introduces > > new complexities> > > and non-orthogonalities. It has some very valuable uses too.> > >> > > But to then create degenerate forms of it that still carry a lot > > of these> > > complexities, but are equivalent in programing power to plain old> > > parameters is just bad program design and bad language design. > > Objects and> > > methods are indeed cool for situations that utilize their > > semantic complexity.> > > But it's deeply uncool to try to look superficially cool by using an> > > inappropriately sophisticated construct when the problem doesn't > > justify it.> > > Some OO proponents have gone way over the deep end here.> > >> > > >> > > > - Jay> > > >> > > >> > > > > > ---------------------------------------------------------------------- > > --> > > > Boo! Scare away worms, viruses and so much more! Try Windows > > Live OneCare! Try now!> > > > s_cid=wl_hotmailnews>> > >> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> >> >> > Boo! Scare away worms, viruses and so much more! Try Windows Live > > OneCare! Try now!> _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:54:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:54:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: <430632D5-F522-4B12-BED7-FB65291896BD@darko.org> M3 doesn't have class methods or what have you but you can give v a method which isn't instance specific which is the same diff and doesn't really cost anything. If you read "How M3 Got Its Spots" I think the chapter is called they make a reference to this, and not a very kind one. I don't think they liked the idea. On 15/11/2007, at 8:40 PM, Jay wrote: > But if I don't want to pay for heap allocation, I can't say: > > VAR T: v; > > v.DoSomething(); > > Only IMPORT T FROM M; > > VAR T: v; > > M.DoSomething(v); > > Right? > > SPIN I think you mean. > Anyone build it and bring it up? I was long curious but never did.. > > - Jay > > > > > CC: m3devel at elegosoft.com > > From: darko at darko.org > > Subject: Re: [M3devel] small array in modula-3? > > Date: Thu, 15 Nov 2007 20:29:06 -0800 > > To: jay.krell at cornell.edu > > > > Not sure what the problem is with modules. If you want to avoid the > > dot you can name the type something unique then import that type > > name. You can create an interface with all the nice type names and > > import all those names in modules by adding an EXPORTS clause too. > > > > Personally I think M3, with a couple of extensions, wouldn't need > > unsafe anything. The unsafe features are there mostly because of > > legacy interfaces. I forget the name but the folk who wrote an OS in > > M3 found it very effective with only couple of minor points with > > regards to interfacing to C code they built on top of, I think > one of > > them was being able to pass NIL to a VAR parameter, which is a > common > > C idiom (and an annoying one for M3 users who then can't use VAR). > > > > > > On 15/11/2007, at 8:08 PM, Jay wrote: > > > > > Rodney, thank you, this is interesting. > > > I definitely don't want to pay for heap allocation for a tiny > array. > > > I don't know about "subarray". It looks like it takes and returns > > > arrays. It's not a type. I ordered another copy of the Nelson book > > > so I don't have to find mine. > > > > > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > > > > > The record and array I propose are not all that different really. > > > I just heard of something new. Have you heard of it? "Duck > typing". > > > If it acts/quacks/walks like a duck, it is a duck. > > > This is in very dynamic languages like Ruby. > > > You apply object.method and if object defines something named > > > "method", then it "must" have "the" meaning you intend. > > > Kind of like how C++ templates "accept as parameters whatever > > > happens to work". > > > > > > Operator overloading is great for strings and "math". > > > > > > Maybe I should try to have this language debate from scratch > again..? > > > > > > I still am conflcted. > > > > > > Modules seem overly heavyweight. > > > I don't want Module1.T, Module2.T, I want T1, T2. > > > > > > C++ stack structs with non virtual member functions: > > > class Rect_t > > > { > > > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > > > > > int Height() { return bottom - top; } > > > int Width() { return right - left; } > > > int top, left, bottom, right; > > > }; > > > > > > seems "good". > > > > > > And it seems not really all that complicated for the compiler to > > > flow the static type information around to resolve the functions.. > > > > > > Rect_t r; > > > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > > > > > I do find some compelling features in Modula-3. Mainly that it > > > compiles to native code and has OPTIONAL safety, optional garbage > > > collection, and that the syntax of modules/interfaces allows fast > > > compilation -- no longer reparsing the same headers over and over > > > and over and over. > > > > > > Operator overloading btw..have seen "template SafeInt"? It acts > > > like a primitive integer, but raises exceptions upon overflow. > > > For this to work very much requires operator overloading. > > > > > > A point, of course, is to be able to have user defined types that > > > can act like the built in types.. > > > > > > - Jay > > > > > > > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > > > From: rodney.bates at wichita.edu > > > > To: m3devel at elegosoft.com > > > > Subject: Re: [M3devel] small array in modula-3? > > > > > > > > Jay wrote: > > > > > > > > > What is the right way to have a variably sized but always > small > > > array in Modula-3? > > > > > My array will only ever have 1 or 2 elements. > > > > > I'd like to always allocate room for 2 elements, and have > there > > > be a size. > > > > > > > > > > It seems I have a choice of > > > > > > > > > > a) an "open" array > > > > > > > > Heap allocated, I presume? If the max size is only 2 elements, > > > > this is pretty extravagant, as a heap allocated open array will > > > > have 4 extra behind-the-scenes words of space overhead, plus > > > > maybe heap fragmentation, and time overhead of allocation, > > > > collection, and maybe reduced locality of reference. > > > > > > > > > b) wrap it up in a record > > > > > > > > > > I'd like so have, like: > > > > > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > > > > > And be able to say: > > > > > > > > > > VAR > > > > > a : A; > > > > > > > > > > .. > > > > > a.size > > > > > FOR i := 0 TO a.size DO > > > > > do something with a[i] > > > > > > > > > > It seems I have no option but, like: > > > > > > > > > > TYPE A = RECORD > > > > > a: ARRAY[0..1] OF FOO; > > > > > size := 1; (* usually of size 1, sometimes 2 *) > > > > > END > > > > > > > > > > and then > > > > > FOR i := 0 TO a.size DO > > > > > do something with a.a[i]; > > > > > > > > > > That is "ok". Not great -- what to call the inner a? > > > > > But then furthermore, I'd like to construct constants. > > > > > It seems I am stuck with either the verbose: > > > > > > > > > > PROCEDURE F(a:A); > > > > > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > > > > > OR I have to come up with a name for the embedded array. > > > > > But of course, its type is really "the same" as the outer > type. > > > > > > > > > > > > Ignoring the fact that the types are different linguistically > > > > (one a record type, the other an array), the types are different > > > > at a deep semantic level too. The inner array has static > > > > size, the outer one (call it a "variable array", perhaps) > > > > has dynamically changeable size, even more easily changed > > > > after it is created than a heap-allocated open array. This > > > > is a significant semantic difference, so it also makes program > > > > design sense to view them as different types. > > > > > > > > > > > > > > To wit: > > > > > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > > > > > TYPE FooArray = RECORD > > > > > a : FooArray; > > > > > size := 1; > > > > > END; > > > > > > > > > > F( FooArray { FooArray { .. } ); > > > > > > > > > > But I have to come up with different names. > > > > > > > > > > And I don't think I can leave out the name for the > constructor, > > > like: > > > > > > > > > > F( FooArray { { .. } ); > > > > > > > > > > > > Yes, this is a limitation in Modula-3. Ada allows value > constructors > > > > to omit inner type names in cases like this, and it is > > > convenient. But > > > > it also crosses a really major line on complexity of the > language > > > semantics, > > > > since type analysis information now flows not only upward, but > > > also downward > > > > in expression typing. I am mostly content to live with this as > > > one bit of > > > > the price of avoiding a horribly over complex language. > > > > > > > > Ordinary procedures can do pretty much all of the things done by > > > exotic > > > > and complex language stuff like C++ constructors. If you don't > > > want to write > > > > the ponderous nested value constructor, write a constructor > > > procedure and > > > > call it. As Antony suggested, you can make it accept an open > > > array formal, > > > > which then codes just like a simple array value constructor. You > > > could even > > > > make it elaborate and general, e.g.: > > > > > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > > > > > = VAR LSize : CARDINAL > > > > ; VAR LResult : A > > > > > > > > ; BEGIN > > > > LSize := NUMBER ( Val ) > > > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > > > ; LResult . size := LSize > > > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > > > ; RETURN LResult > > > > END MakeF > > > > > > > > Alternatively, since your maximum element count is so small, you > > > could > > > > write a constructor procedure that took two formals of type FOO, > > > with > > > > at least the second one optional. (This would require a > > > distinguished > > > > value of type FOO that would be used to mean "omitted".) > > > > > > > > And, of course, if you want to use abstraction, you can put the > > > types, > > > > constructor procedures, and various other procedures for > > > manipulating > > > > the variable sized array in a module, behind an interface. > > > > > > > > An additional limitation of Modula-3 in this regard, is that you > > > can't > > > > make the type F opaque, unless you heap allocate it, which we > > > were trying > > > > to avoid. Ada would allow you to do this, but it's another > > > example of > > > > a convenience with high cost. It forces the equivalent of the > > > revelation > > > > to be located in the equivalent of the interface, but makes it > > > illegal > > > > to write client code that depends on what the revelation is. > > > > > > > > This in turn creates a source code control nightmare in a large > > > project, > > > > because now someone who wants to make what is really a purely > > > internal, > > > > implementation change, nevertheless has to check out the > > > interface, and > > > > if you aren't in denial mode, that means implementers of all the > > > client > > > > code have to go to extra trouble to somehow find out that what > > > appears > > > > to be an interface change actually doesn't affect them after > all. > > > > > > > > > > > > > > Though that might seem nice. > > > > > > > > > > Am I understanding everything? > > > > > > > > > > Have folks hit this before and there's a set of names that > > > don't seem too lame > > > > > that folks use? > > > > > > > > > > Also -- language documentation? > > > > > Nelson's green book is excellent. > > > > > The stuff in the doc directory is very dry and scientific. > > > > > The tutorial seems more like a reference. Or maybe I didn't > > > read it enough. > > > > > Is there better, in case I need a refresher? > > > > > I think I got it, via Nelson's book from memory (wonder if I > > > can find mine..) and the reference, > > > > > but I don't think anyone could learn from the current online > > > docs in the source tree. > > > > > > > > > > Maybe it's me, some combination of laziness and short > attention > > > span > > > > > as I age.. > > > > > > > > > > Btw, C doesn't offer a great solution here, though it offers > > > leaving out some type names. > > > > > In C++ I could have both .size and operator[]. > > > > > Modula-3 seems to be missing operator overloading. > > > > > It's got some builtin stuff, even array assignment and > equality > > > and I think > > > > > even record assignment and equality, but it is still a bit > > > limiting. > > > > > > > > > > > > I have raved on this before, but, having had lots of painful > > > experience with > > > > user-defined overloading in Ada and C++, I can say with > > > authority, that it is > > > > a programming language disaster. It interacts with just about > > > everything > > > > else in the language, in very complicated ways, and all it buys > > > you is saving > > > > time/energy thinking up distinct names for procedures/functions. > > > Even this, > > > > aside from the effects on the language, is a net loss, by the > > > time you consider > > > > readability along with writability. > > > > > > > > User-defined overloaded operators provide a slight readability > > > benefit, _if_ > > > > used with great restraint and discipline, something you can rely > > > on not happening. > > > > Meanwhile, the language complexity can easily double or worse. > > > And, with the > > > > exception of compiler writers and language lawyers who spend > > > hundreds of hours > > > > on just this, programmers don't understand the rules, not even > > > close. > > > > > > > > > > > > > > Also, if I understand things correctly, this has long bothered > > > me about Modula-3, > > > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > > for lighter wieght > > > > > objects. Like, small stack allocated structs with member > > > functions. You seem to have > > > > > to chose between heap allocated garbage collected virtual > > > member functions full > > > > > featured objects, or featureless dumb structs. It's nice > how C+ > > > + allow hybrids -- > > > > > objects don't have to be heap allocated and member functions > > > don't have be virtual. > > > > > Or am I missing something? > > > > > > > > > > > > C++'s supposedly lighter weight forms of classes/structs with > > > their special > > > > member functions buy nothing that plain records, plain > > > procedures, and > > > > interfaces/modules don't already provide, again, at significant > > > and gratuitous > > > > language complexity. Except when methods/member functions > > > actually dispatch > > > > dynamically, there is nothing that the above won't do, and when > > > you create a > > > > class instance as a local variable (i.e., on the stack), it is > > > necessarily > > > > not polymorphic, that is, it can't change its "allocated" or > > > dynamic type > > > > among various subtypes at runtime. This in turn means it can't > > > dispatch. > > > > > > > > So, just use plain procedures, an interface and a module, and > you > > > will get > > > > everything a lighter-weight C++ class would give you. > > > > > > > > > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > > deal with > > > > > t: Type; > > > > > Type_DoSomething(t); > > > > > > > > > > in place of: > > > > > t.DoSomething(); > > > > > > > > > > > > Exactly. The special "receiver object" in a true method call has > > > significant > > > > semantic differences from an ordinary parameter and introduces > > > new complexities > > > > and non-orthogonalities. It has some very valuable uses too. > > > > > > > > But to then create degenerate forms of it that still carry a lot > > > of these > > > > complexities, but are equivalent in programing power to plain > old > > > > parameters is just bad program design and bad language design. > > > Objects and > > > > methods are indeed cool for situations that utilize their > > > semantic complexity. > > > > But it's deeply uncool to try to look superficially cool by > using an > > > > inappropriately sophisticated construct when the problem doesn't > > > justify it. > > > > Some OO proponents have gone way over the deep end here. > > > > > > > > > > > > > > - Jay > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > -- > > > > > Boo! Scare away worms, viruses and so much more! Try Windows > > > Live OneCare! Try now! > > > > > > s_cid=wl_hotmailnews> > > > > > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > > > OneCare! Try now! > > > > > Climb to the top of the charts! Play Star Shuffle: the word > scramble challenge with star power. Play Now! From lemming at henning-thielemann.de Fri Nov 16 09:42:26 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 09:42:26 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Jay wrote: > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. This way generic modules would not work. They require that the parameter modules have exactly the same interface. 'T' everywhere looked strange to me at first, but I get used to it and now I also use that naming in other languages (namely Haskell). Btw. Haskell has a restricted kind of operator overloading by so called type classes. Although sometimes useful, people tend to overuse it. From rodney.bates at wichita.edu Fri Nov 16 22:42:35 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:42:35 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <473E0ECB.504@wichita.edu> Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book so I > don't have to find mine. SUBARRAY is an expression. It accesses a subrange of the elements of an array. You can use it on the left of assignment or on the right. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". If > it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named "method", > then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever happens to > work". This kind of thinking about software will work sometimes, but it's a recipe for disaster overall. It's quite too hard already to get the bugs out of software without people invoking things with only a guess what they mean. "If it looks like a duck ..." is absolutely not reliable in software. That's also the problem with over complex languages: people write massive amounts of code with only guesses about what the language constructs mean. > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. ; IMPORT Module1 ; IMPORT Module2 ... ; TYPE T1 = Module1 . T ; TYPE T2 = Module2 . T Now you can use T1 and T2 all over the place. Of course, if it weren't for two modules each having a different T, you could just say FROM Module1 IMPORT T, so T is available without qualification, but unlike above, is not renamed. (This is pasted in from Jay's other post on this topic) >But if I don't want to pay for heap allocation, I can't say: >VAR T: v; >v.DoSomething(); >Only IMPORT T FROM M; >VAR T: v; >M.DoSomething(v); > Right? If you don't want to have to write the module name as a qualifier, you can rename a procedure too, with a constant declaration (Procedures in Modula-3 are actually the same thing a constants of procedure type.) CONST DoSomething = M.DoSomething ... DoSomething ( v ) Having been almost forced (for other reasons I'll skip for now) in Ada to consistently use qualified references like M.DoSomething, I've come to believe that is the right way to code, even though it's more writing. It makes old code/somebody else's code _much_ easier to read. Using unqualified names is turning the priorities upside-down and saying writability trumps readability. Only if it's referred to _very_ often, do I use unqualified names (in which case, I also make them short). One limitation in Modula-3 is that you can't rename an exception or (well, not in the most general way) a variable from an imported module. I discussed this once in a list of language wants, but expressed ambivalence, particularly about variable renames. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; The nonvirtual member functions greatly complicate the language, and provide nothing that plain, nonmember functions don't provide. -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From lemming at henning-thielemann.de Fri Nov 16 22:24:15 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 22:24:15 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: <473E0ECB.504@wichita.edu> References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Rodney M. Bates wrote: > If you don't want to have to write the module name as a qualifier, you can > rename a procedure too, with a constant declaration (Procedures in Modula-3 > are actually the same thing a constants of procedure type.) > > CONST DoSomething = M.DoSomething > ... > DoSomething ( v ) It would have been nice if PROCEDURE declarations would reflect this, like in functional languages. Say CONST Sin = PROCEDURE (x: LONGREAL;): LONGREAL BEGIN ... RETURN y; END; This would also be the key for anonymous functions or loops as higher order functions. Just an idea, it's certainly simpler just to use a functional language. :-) From rodney.bates at wichita.edu Fri Nov 16 22:54:56 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:54:56 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> References: <473CE6B6.3030402@wichita.edu> <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Message-ID: <473E11B0.3060103@wichita.edu> Darko wrote: > Is it really four words? I would have thought it might need a type > reference and a size, what are the others for? > One word for the pointer in the stack variable or wherever the real data would be, if not heap allocated. One word at negative offset in the heap object for the allocator/collector to keep track of memory. This is as low as heap manager space overhead gets, as far as I know. In any case, unless somebody figured out how to get it down to zero, there would still just about have to be a full word because of alignment. One word of "shape" for each open dimension, when the object is an open array. This example is one-dimensional, so it's one word total. One word (actually appears before the shape (which varies in size), so its location is consistent for all open array heap objects). This is a pointer to the zero-th actual array element. For a heap allocated open array, this is redundant, as it always points to the word following the shape. I presume the implementors did this because open array formal parameters need a consistent representation, regardless of whether the formal is an open array, a fixed array, or a SUBARRAY. It should be possible to implement less extravagantly, but it would complicate the compiler with more combinations of cases to handle. > > On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > >> Jay wrote: >> >> > What is the right way to have a variably sized but always small >> array in Modula-3? >> > My array will only ever have 1 or 2 elements. >> > I'd like to always allocate room for 2 elements, and have there be >> a size. >> > >> > It seems I have a choice of >> > >> > a) an "open" array >> >> Heap allocated, I presume? If the max size is only 2 elements, >> this is pretty extravagant, as a heap allocated open array will >> have 4 extra behind-the-scenes words of space overhead, plus >> maybe heap fragmentation, and time overhead of allocation, >> collection, and maybe reduced locality of reference. >> -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From mika at async.caltech.edu Fri Nov 16 23:07:13 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Fri, 16 Nov 2007 14:07:13 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: Your message of "Fri, 16 Nov 2007 16:39:44 GMT." Message-ID: <200711162207.lAGM7D2N050225@camembert.async.caltech.edu> Naw, it's DoSomething(x); DoSomethingElse(y) It's not the same function. Not even in C++! It's just another example of overloading... Jay writes: >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >> VAR v : T;> DoSomething(v);> > What's the big deal if it's DoSomething(v)= > or v.DoSomething()? VAR x : T1; VAR y : T2; DoSomething(x); DoSomething(y)= >; >isn't legal, right? >=20 >So I have to: > M1.DoSomething(x); M2.DoSomething(y); >right? Constantly repeating types, or modules, on function names? >=20 > - Jay >=20 > > > >> To: jay.krell at cornell.edu> Subject: Re: [M3devel] small array in modula-3= >? > Date: Thu, 15 Nov 2007 21:00:13 -0800> From: mika at async.caltech.edu> > = >Why not > > FROM M IMPORT T, DoSomething;> > VAR v : T;> DoSomething(v);> >= > What's the big deal if it's DoSomething(v) or v.DoSomething()?> > If anyth= >ing, "DoSomething(v)" tells me that the call can be statically> resolved, w= >hereas v.DoSomething() tells me that something odd can> happen at runtime--= >-that is, I cannot be sure I understand this> code simply by looking for a = >routine called "DoSomething" and reading> that, but have to be more careful= >. This distinction is unclear in> C++. What, in fact, is the distinction in= > C++ between DoSomething(v)> and v.DoSomething()? None, right? Just two way= >s of saying the> same thing... why?> > The Modula-2+ work on the Firefly is= > also close enough to be "almost"> Modula-3...> > Regarding UNSAFE: most in= >terfaces to C code are (or should be)> UNSAFE because there are ways of cal= >ling them that can lead to> unchecked runtime errors. I don't see how you c= >an live without> UNSAFE if you ever want to link with other people's C libr= >aries...> > Mika> > Jay writes:> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_>= > >Content-Type: text/plain; charset=3D"iso-8859-1"> >Content-Transfer-Encod= >ing: quoted-printable> >> >But if I don't want to pay for heap allocation, = >I can't say:> >=3D20> >VAR T: v;> >=3D20> >v.DoSomething();> >=3D20> >Only = >IMPORT T FROM M;> >=3D20> >VAR T: v;> >=3D20> >M.DoSomething(v);> >=3D20> >= >Right?> >SPIN I think you mean.> >Anyone build it and bring it up? I was lo= >ng curious but never did..> >=3D20> > - Jay> >> >> >> >> CC: m3devel at elegos= >oft.com> From: darko at darko.org> Subject: Re: [M3devel] =3D> >small array in= > modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.kr=3D> >ell at corn= >ell.edu> > Not sure what the problem is with modules. If you want t=3D> >o = >avoid the > dot you can name the type something unique then import that t= >=3D> >ype > name. You can create an interface with all the nice type names = >and > =3D> >import all those names in modules by adding an EXPORTS clause t= >oo.> > Perso=3D> >nally I think M3, with a couple of extensions, wouldn't n= >eed > unsafe anyth=3D> >ing. The unsafe features are there mostly because o= >f > legacy interfaces. I=3D> > forget the name but the folk who wrote an OS= > in > M3 found it very effecti=3D> >ve with only couple of minor points wit= >h > regards to interfacing to C code=3D> > they built on top of, I think on= >e of > them was being able to pass NIL to =3D> >a VAR parameter, which is a= > common > C idiom (and an annoying one for M3 us=3D> >ers who then can't us= >e VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > =3D> >> Rodney, thank= > you, this is interesting.> > I definitely don't want to pay=3D> > for heap= > allocation for a tiny array.> > I don't know about "subarray". It=3D> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered ano=3D= >> >ther copy of the Nelson book > > so I don't have to find mine.> >> > Goo= >d i=3D> >dea "MakeT" I forgot about that pattern. I'll try it out.> >> > Th= >e record =3D> >and array I propose are not all that different really.> > I = >just heard of s=3D> >omething new. Have you heard of it? "Duck typing". > >= > If it acts/quacks/wa=3D> >lks like a duck, it is a duck.> > This is in ver= >y dynamic languages like Ru=3D> >by.> > You apply object.method and if obje= >ct defines something named > > "m=3D> >ethod", then it "must" have "the" me= >aning you intend.> > Kind of like how C=3D> >++ templates "accept as parame= >ters whatever > > happens to work".> >> > Ope=3D> >rator overloading is gre= >at for strings and "math".> >> > Maybe I should try=3D> > to have this lang= >uage debate from scratch again..?> >> > I still am conflc=3D> >ted.> >> > M= >odules seem overly heavyweight.> > I don't want Module1.T, Modu=3D> >le2.T,= > I want T1, T2.> >> > C++ stack structs with non virtual member funct=3D> >= >ions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(= >=3D> >0) { }> >> > int Height() { return bottom - top; }> > int Width() { r= >eturn =3D> >right - left; }> > int top, left, bottom, right;> > };> >> > se= >ems "good".>=3D> > >> > And it seems not really all that complicated for th= >e compiler to > > =3D> >flow the static type information around to resolve = >the functions..> >> > Re=3D> >ct_t r;> > r.Height() =3D3D> Rect_Height(&r);= > ..and would be inlined anyway.>=3D> > >> > I do find some compelling featu= >res in Modula-3. Mainly that it > > co=3D> >mpiles to native code and has O= >PTIONAL safety, optional garbage > > collect=3D> >ion, and that the syntax = >of modules/interfaces allows fast > > compilation =3D> >-- no longer repars= >ing the same headers over and over > > and over and over=3D> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D> > like a= > primitive integer, but raises exceptions upon overflow.> > For this=3D> > = >to work very much requires operator overloading.> >> > A point, of course,= >=3D> > is to be able to have user defined types that > > can act like the b= >uilt i=3D> >n types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:1= >8 -0600> > >=3D> > From: rodney.bates at wichita.edu> > > To: m3devel at elegosof= >t.com> > > Subject=3D> >: Re: [M3devel] small array in modula-3?> > >> > > = >Jay wrote:> > >> > > > W=3D> >hat is the right way to have a variably sized= > but always small > > array in=3D> > Modula-3?> > > > My array will only ev= >er have 1 or 2 elements.> > > > I'd =3D> >like to always allocate room for = >2 elements, and have there > > be a size.>=3D> > > > >> > > > It seems I ha= >ve a choice of> > > >> > > > a) an "open" array>=3D> > > >> > > Heap alloca= >ted, I presume? If the max size is only 2 elements,> >=3D> > > this is pret= >ty extravagant, as a heap allocated open array will> > > hav=3D> >e 4 extra= > behind-the-scenes words of space overhead, plus> > > maybe heap f=3D> >rag= >mentation, and time overhead of allocation,> > > collection, and maybe r=3D= >> >educed locality of reference.> > >> > > > b) wrap it up in a record> > >= > >>=3D> > > > > I'd like so have, like:> > > >> > > > TYPE A =3D3D ARRAY [0= >..1] OF FOO=3D> >;> > > >> > > > And be able to say:> > > >> > > > VAR> > >= > > a : A;> > > >>=3D> > > > > ..> > > > a.size> > > > FOR i :=3D3D 0 TO a.s= >ize DO> > > > do somethin=3D> >g with a[i]> > > >> > > > It seems I have no= > option but, like:> > > >> > > =3D> >> TYPE A =3D3D RECORD> > > > a: ARRAY[= >0..1] OF FOO;> > > > size :=3D3D 1; (* us=3D> >ually of size 1, sometimes 2= > *)> > > > END> > > >> > > > and then> > > > FO=3D> >R i :=3D3D 0 TO a.size= > DO> > > > do something with a.a[i];> > > >> > > > That=3D> > is "ok". Not = >great -- what to call the inner a?> > > > But then furthermor=3D> >e, I'd l= >ike to construct constants.> > > > It seems I am stuck with either =3D> >th= >e verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..= >=3D> >1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name fo= >r the =3D> >embedded array.> > > > But of course, its type is really "the s= >ame" as the =3D> >outer type.> > >> > >> > > Ignoring the fact that the typ= >es are different l=3D> >inguistically> > > (one a record type, the other an= > array), the types are d=3D> >ifferent> > > at a deep semantic level too. T= >he inner array has static> > >=3D> > size, the outer one (call it a "variab= >le array", perhaps)> > > has dynamic=3D> >ally changeable size, even more e= >asily changed> > > after it is created tha=3D> >n a heap-allocated open arr= >ay. This> > > is a significant semantic differen=3D> >ce, so it also makes = >program> > > design sense to view them as different ty=3D> >pes.> > >> > > = >>> > > > To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[0..1]=3D> > OF Foo= >;> > > >> > > > TYPE FooArray =3D3D RECORD> > > > a : FooArray;> > > >=3D> = >> size :=3D3D 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );= >> >=3D> > > >> > > > But I have to come up with different names.> > > >> > = >> > And I=3D> > don't think I can leave out the name for the constructor, >= > > like:> > > >=3D> >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, th= >is is a limitation in=3D> > Modula-3. Ada allows value constructors> > > to= > omit inner type names in c=3D> >ases like this, and it is > > convenient. = >But> > > it also crosses a really=3D> > major line on complexity of the lan= >guage > > semantics,> > > since type an=3D> >alysis information now flows n= >ot only upward, but > > also downward> > > in=3D> > expression typing. I am= > mostly content to live with this as > > one bit of=3D> >> > > the price of= > avoiding a horribly over complex language.> > >> > > Ord=3D> >inary proced= >ures can do pretty much all of the things done by > > exotic> >=3D> > > and= > complex language stuff like C++ constructors. If you don't > > want =3D> >= >to write> > > the ponderous nested value constructor, write a constructor >= >=3D> > > procedure and> > > call it. As Antony suggested, you can make it a= >ccept =3D> >an open > > array formal,> > > which then codes just like a sim= >ple array va=3D> >lue constructor. You > > could even> > > make it elaborat= >e and general, e.g=3D> .:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) = >: F> > >> > > =3D3D VAR L=3D> >Size : CARDINAL> > > ; VAR LResult : A> > >>= > > > ; BEGIN> > > LSize :=3D3D NU=3D> >MBER ( Val )> > > <* ASSERT LSize <= >=3D3D NUMBER ( FooArray ) *>> > > ; LResul=3D> >t . size :=3D3D LSize> > > = >; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S=3D> >UBARRAY ( Val , F= >IRST ( Val ) , LSize )> > > ; RETURN LResult> > > END Make=3D> >F> > >> > >= > Alternatively, since your maximum element count is so small, yo=3D> >u > >= > could> > > write a constructor procedure that took two formals of typ=3D> = >>e FOO, > > with> > > at least the second one optional. (This would require= > =3D> >a > > distinguished> > > value of type FOO that would be used to mea= >n "omit=3D> >ted".)> > >> > > And, of course, if you want to use abstractio= >n, you can pu=3D> >t the > > types,> > > constructor procedures, and variou= >s other procedures =3D> >for > > manipulating> > > the variable sized array= > in a module, behind an i=3D> >nterface.> > >> > > An additional limitation= > of Modula-3 in this regard, is=3D> > that you > > can't> > > make the type= > F opaque, unless you heap allocate i=3D> >t, which we > > were trying> > >= > to avoid. Ada would allow you to do this, =3D> >but it's another > > examp= >le of> > > a convenience with high cost. It force=3D> >s the equivalent of = >the > > revelation> > > to be located in the equivalent=3D> > of the interf= >ace, but makes it > > illegal> > > to write client code that =3D> >depends = >on what the revelation is.> > >> > > This in turn creates a source =3D> >co= >de control nightmare in a large > > project,> > > because now someone who= >=3D> > wants to make what is really a purely > > internal,> > > implementat= >ion ch=3D> >ange, nevertheless has to check out the > > interface, and> > >= > if you aren=3D> >'t in denial mode, that means implementers of all the > >= > client> > > code =3D> >have to go to extra trouble to somehow find out tha= >t what > > appears> > > =3D> >to be an interface change actually doesn't af= >fect them after all.> > >> > >=3D> > >> > > > Though that might seem nice.>= > > > >> > > > Am I understanding eve=3D> >rything?> > > >> > > > Have folks= > hit this before and there's a set of name=3D> >s that > > don't seem too l= >ame> > > > that folks use?> > > >> > > > Also --=3D> > language documentati= >on?> > > > Nelson's green book is excellent.> > > > Th=3D> >e stuff in the = >doc directory is very dry and scientific.> > > > The tutoria=3D> >l seems m= >ore like a reference. Or maybe I didn't > > read it enough.> > > >=3D> > Is= > there better, in case I need a refresher?> > > > I think I got it, via =3D= >> >Nelson's book from memory (wonder if I > > can find mine..) and the refe= >ren=3D> >ce,> > > > but I don't think anyone could learn from the current o= >nline > >=3D> > docs in the source tree.> > > >> > > > Maybe it's me, some = >combination of =3D> >laziness and short attention > > span> > > > as I age.= >.> > > >> > > > Btw, =3D> >C doesn't offer a great solution here, though it= > offers > > leaving out som=3D> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D> >Modula-3 seems to be missing operato= >r overloading.> > > > It's got some bui=3D> >ltin stuff, even array assignm= >ent and equality > > and I think> > > > even =3D> >record assignment and eq= >uality, but it is still a bit > > limiting.> > >> >=3D> > >> > > I have rav= >ed on this before, but, having had lots of painful > > ex=3D> >perience wit= >h> > > user-defined overloading in Ada and C++, I can say with =3D> >> > au= >thority, that it is> > > a programming language disaster. It interact=3D> >= >s with just about > > everything> > > else in the language, in very complic= >=3D> >ated ways, and all it buys > > you is saving> > > time/energy thinkin= >g up d=3D> >istinct names for procedures/functions. > > Even this,> > > asi= >de from the =3D> >effects on the language, is a net loss, by the > > time y= >ou consider> > > r=3D> >eadability along with writability.> > >> > > User-d= >efined overloaded operat=3D> >ors provide a slight readability > > benefit,= > _if_> > > used with great res=3D> >traint and discipline, something you ca= >n rely > > on not happening.> > > Me=3D> >anwhile, the language complexity = >can easily double or worse. > > And, with =3D> >the> > > exception of compi= >ler writers and language lawyers who spend > > h=3D> >undreds of hours> > >= > on just this, programmers don't understand the rules,=3D> > not even > > c= >lose.> > >> > > >> > > > Also, if I understand things correc=3D> >tly, this= > has long bothered > > me about Modula-3,> > > > though I'm more t=3D> >ole= >rant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > >=3D= >> > objects. Like, small stack allocated structs with member > > functions.= > Yo=3D> >u seem to have> > > > to chose between heap allocated garbage coll= >ected vir=3D> >tual > > member functions full> > > > featured objects, or f= >eatureless dumb=3D> > structs. It's nice how C+ > > + allow hybrids --> > >= > > objects don't have=3D> > to be heap allocated and member functions > > d= >on't have be virtual.> > > =3D> >> Or am I missing something?> > >> > >> > = >> C++'s supposedly lighter weight=3D> > forms of classes/structs with > > t= >heir special> > > member functions buy =3D> >nothing that plain records, pl= >ain > > procedures, and> > > interfaces/modul=3D> >es don't already provide= >, again, at significant > > and gratuitous> > > lan=3D> >guage complexity. = >Except when methods/member functions > > actually dispatc=3D> >h> > > dynam= >ically, there is nothing that the above won't do, and when > > =3D> >you cr= >eate a> > > class instance as a local variable (i.e., on the stack), =3D> >= >it is > > necessarily> > > not polymorphic, that is, it can't change its "a= >=3D> >llocated" or > > dynamic type> > > among various subtypes at runtime.= > This =3D> >in turn means it can't > > dispatch.> > >> > > So, just use pla= >in procedure=3D> >s, an interface and a module, and you > > will get> > > e= >verything a lighte=3D> >r-weight C++ class would give you.> > >> > >> > > >= >> > > > Anyway, I've got=3D> >ten to accept C a bit more vs. C++ so I can >= > > deal with> > > > t: Type;> =3D> >> > > Type_DoSomething(t);> > > >> > > = >> in place of:> > > > t.DoSomething(=3D> >);> > >> > >> > > Exactly. The sp= >ecial "receiver object" in a true method c=3D> >all has > > significant> > = >> semantic differences from an ordinary paramete=3D> >r and introduces > > = >new complexities> > > and non-orthogonalities. It has =3D> >some very valua= >ble uses too.> > >> > > But to then create degenerate forms =3D> >of it tha= >t still carry a lot > > of these> > > complexities, but are equiva=3D> >len= >t in programing power to plain old> > > parameters is just bad program d=3D= >> >esign and bad language design. > > Objects and> > > methods are indeed c= >ool=3D> > for situations that utilize their > > semantic complexity.> > > B= >ut it's d=3D> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D> >tely sophisticated construct when the problem doesn't = >> > justify it.> > > =3D> >Some OO proponents have gone way over the deep e= >nd here.> > >> > > >> > > >=3D> > - Jay> > > >> > > >> > > > > > ----------= >---------------------------------=3D> >--------------------------- > > --> = >> > > Boo! Scare away worms, viruses an=3D> >d so much more! Try Windows > = >> Live OneCare! Try now!> > > >.live.com/standard/en-us= >/purchase/trial.aspx? > > s_cid=3D3Dwl_hotmailnews>> =3D> >> >> > >> > > --= >> > > -----------------------------------------------------=3D> >--------> = >> > Rodney M. Bates, retired assistant professor> > > Dept. of Co=3D> >mput= >er Science, Wichita State University> > > Wichita, KS 67260-0083> > > 3=3D>= > >16-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------= >--=3D> >----------------------------------------------> > > Rodney M. Bates= >, retire=3D> >d assistant professor> > > Dept. of Computer Science, Wichita= > State Univers=3D> >ity> > > Wichita, KS 67260-0083> > > 316-978-3922> > > = >rodney.bates at wichita=3D> >.edu> >> >> > Boo! Scare away worms, viruses and = >so much more! Try Windows =3D> >Live > > OneCare! Try now!>=3D20> >________= >_________________________________________________________> >Climb to the to= >p of the charts!=3DA0 Play Star Shuffle:=3DA0 the word scramble =3D> >chall= >enge with star power.> >http://club.live.com/star_shuffle.aspx?icid=3D3Dsta= >rshuffle_wlmailtextlink_oc=3D> >t=3D> >> >--_0109391c-2ffe-4cfe-9165-c2a246= >28c3c7_> >Content-Type: text/html; charset=3D"iso-8859-1"> >Content-Transfe= >r-Encoding: quoted-printable> >> >> >> >> >> >'>But if I don't want to pay for heap allocation, I=3D> > can't say:
> >= > 
> >VAR T: v;
> > 
> >v.DoSomething();
> > 
= >> >Only IMPORT T FROM M;
> > 
> >VAR T: v;
> > 
> >M.= >DoSomething(v);
> > 
> >Right?

> >SPIN I think you mean.<= >BR>> >Anyone build it and bring it up? I was long curious but never did..R>> > 
> > - Jay


> >> >
> ><= >BR>> >> CC: m3devel at elegosoft.com
> From: darko at darko.org
> = >Subjec=3D> >t: Re: [M3devel] small array in modula-3?
> Date: Thu, 15= > Nov 2007 20=3D> >:29:06 -0800
> To: jay.krell at cornell.edu
> R>> Not sure wh=3D> >at the problem is with modules. If you want to avoi= >d the
> dot you c=3D> >an name the type something unique then import= > that type
> name. You =3D> >can create an interface with all the ni= >ce type names and
> import al=3D> >l those names in modules by addin= >g an EXPORTS clause too.
>
> =3D> >Personally I think M3, with= > a couple of extensions, wouldn't need
> =3D> >unsafe anything. The = >unsafe features are there mostly because of
> l=3D> >egacy interface= >s. I forget the name but the folk who wrote an OS in
>=3D> >; M3 foun= >d it very effective with only couple of minor points with
>=3D> > re= >gards to interfacing to C code they built on top of, I think one of
=3D= >> >> them was being able to pass NIL to a VAR parameter, which is a comm= >on =3D> >
> C idiom (and an annoying one for M3 users who then can't = >use VAR).=3D> >
>
>
> On 15/11/2007, at 8:08 PM, Jay wr= >ote:
> >R>> > Rodney, thank you, this is interesting.>> > I definite=3D> >ly don't want to pay for heap allocation for a t= >iny array.
> > I d=3D> >on't know about "subarray". It looks like = >it takes and returns
> >=3D> >; arrays. It's not a type. I ordered= > another copy of the Nelson book
&g=3D> >t; > so I don't have to fin= >d mine.
> >
> > Good idea "=3D> >MakeT" I forgot about th= >at pattern. I'll try it out.
> >
> &=3D> >gt; The record and= > array I propose are not all that different really.
&g=3D> >t; > I ju= >st heard of something new. Have you heard of it? "Duck typing".=3D> >
&= >gt; > If it acts/quacks/walks like a duck, it is a duck.
> &=3D> >= >gt; This is in very dynamic languages like Ruby.
> > You apply obj= >=3D> >ect.method and if object defines something named
> > "metho= >d", th=3D> >en it "must" have "the" meaning you intend.
> > Kind o= >f like how C=3D> >++ templates "accept as parameters whatever
> >= > happens to work".=3D> >
> >
> > Operator overloading is = >great for strings and "m=3D> >ath".
> >
> > Maybe I shoul= >d try to have this language de=3D> >bate from scratch again..?
> >= >
> > I still am conflcted.<=3D> >BR>> >
> > Modules= > seem overly heavyweight.
> > I d=3D> >on't want Module1.T, Module= >2.T, I want T1, T2.
> >
> > C+=3D> >+ stack structs with = >non virtual member functions:
> > class Rect_=3D> >t
> > = >{
> > Rect_t() : top(0), left(0), right(0), bottom(=3D> >0) { }>> >
> > int Height() { return bottom - top; }
&=3D> >gt;= > > int Width() { return right - left; }
> > int top, left, b=3D= >> >ottom, right;
> > };
> >
> > seems "good".>&g=3D> >t; >
> > And it seems not really all that complicated = >for the c=3D> >ompiler to
> > flow the static type information ar= >ound to resolve=3D> > the functions..
> >
> > Rect_t r;R>> > r.Height(=3D> >) =3D3D> Rect_Height(&r); ..and would be = >inlined anyway.
> ><=3D> >BR>> > I do find some compelling f= >eatures in Modula-3. Mainly that it=3D> >
> > compiles to native = >code and has OPTIONAL safety, optional ga=3D> >rbage
> > collecti= >on, and that the syntax of modules/interfaces a=3D> >llows fast
> &g= >t; compilation -- no longer reparsing the same header=3D> >s over and over = >
> > and over and over.
> >
> > =3D> >Operator o= >verloading btw..have seen "template SafeInt"? It acts
> &g=3D> >t; l= >ike a primitive integer, but raises exceptions upon overflow.
> &=3D>= > >gt; For this to work very much requires operator overloading.
> >= >;<=3D> >BR>> > A point, of course, is to be able to have user defined= > types t=3D> >hat
> > can act like the built in types..
> &= >gt;
> &g=3D> >t; - Jay
> >
> >
> > > Da= >te: Thu, 15 Nov 2007=3D> > 18:39:18 -0600
> > > From: rodney.ba= >tes at wichita.edu
> &g=3D> >t; > To: m3devel at elegosoft.com
> &= >gt; > Subject: Re: [M3devel] =3D> >small array in modula-3?
> >= > >
> > > Jay wrote:
=3D> >> > >
> > >= >; > What is the right way to have a varia=3D> >bly sized but always smal= >l
> > array in Modula-3?
> > &g=3D> >t; > My array wi= >ll only ever have 1 or 2 elements.
> > > >=3D> >; I'd like to= > always allocate room for 2 elements, and have there
> =3D> >> be= > a size.
> > > >
> > > > It seems I ha=3D> >v= >e a choice of
> > > >
> > > > a) an "open" a= >=3D> >rray
> > >
> > > Heap allocated, I presume? I= >f the =3D> >max size is only 2 elements,
> > > this is pretty e= >xtravagant, =3D> >as a heap allocated open array will
> > > hav= >e 4 extra behind-t=3D> >he-scenes words of space overhead, plus
> >= >; > maybe heap fragme=3D> >ntation, and time overhead of allocation,
= >> > > collection, and=3D> > maybe reduced locality of reference.R>> > >
> > > &=3D> >gt; b) wrap it up in a record
= >> > > >
> > > >=3D> > I'd like so have, like:>> > > >
> > > > TYPE=3D> > A =3D3D ARRAY [0..1]= > OF FOO;
> > > >
> > > > A=3D> >nd be able to= > say:
> > > >
> > > > VAR
>=3D> >; > = >> > a : A;
> > > >
> > > > .. >>= >> > > > a.size
> > > > FOR i :=3D3D 0 TO a.size = >D=3D> >O
> > > > do something with a[i]
> > > &g= >t;
&=3D> >gt; > > > It seems I have no option but, like:
>= >; > > &=3D> >gt;
> > > > TYPE A =3D3D RECORD
> &= >gt; > > a: ARRA=3D> >Y[0..1] OF FOO;
> > > > size :=3D= >3D 1; (* usually of size 1, s=3D> >ometimes 2 *)
> > > > END= >
> > > >
> >=3D> >; > > and then
> > = >> > FOR i :=3D3D 0 TO a.size DO
&g=3D> >t; > > > do somet= >hing with a.a[i];
> > > >
> =3D> >> > > That = >is "ok". Not great -- what to call the inner a?
>=3D> > > > >= >; But then furthermore, I'd like to construct constants.
&=3D> >gt; >= > > > It seems I am stuck with either the verbose:
> >=3D> >; = >> >
> > > > PROCEDURE F(a:A);
> > > >= >=3D> >
> > > > F( A { ARRAY[0..1] OF FOO { .. } );
> &= >gt; &g=3D> >t; >
> > > > OR I have to come up with a name= > for the emb=3D> >edded array.
> > > > But of course, its ty= >pe is really "the =3D> >same" as the outer type.
> > >
> = >> >
> > &=3D> >gt; Ignoring the fact that the types are diff= >erent linguistically
> &=3D> >gt; > (one a record type, the other = >an array), the types are different >R>> > > at a deep semant= >ic level too. The inner array has static >R>> > > size, the = >outer one (call it a "variable array", perhaps)<=3D> >BR>> > > has= > dynamically changeable size, even more easily changed=3D> >
> > &= >gt; after it is created than a heap-allocated open array. Th=3D> >is
>= >; > > is a significant semantic difference, so it also makes=3D> > pr= >ogram
> > > design sense to view them as different types.> >>> > >
> > > >
> > > > To wit:>&g=3D> >t; > > >
> > > > TYPE FooArray =3D3D ARRAY= >[0..1] OF F=3D> >oo;
> > > >
> > > > TYPE Foo= >Array =3D3D RECORD<=3D> >BR>> > > > a : FooArray;
> > = >> > size :=3D3D 1; >>> > > > END;
> > >= >; >
> > > > F( =3D> >FooArray { FooArray { .. } );
>= >; > > >
> > > >=3D> > But I have to come up with di= >fferent names.
> > > >
>=3D> > > > > And I do= >n't think I can leave out the name for the construc=3D> >tor,
> >= > like:
> > > >
> > > > F( F=3D> >ooArray { { = >.. } );
> > >
> > >
> > > Y=3D> >es, th= >is is a limitation in Modula-3. Ada allows value constructors
>=3D> >= > > > to omit inner type names in cases like this, and it is
> = >=3D> >> convenient. But
> > > it also crosses a really major= > line =3D> >on complexity of the language
> > semantics,
> = >> > si=3D> >nce type analysis information now flows not only upward, = >but
> > =3D> >also downward
> > > in expression typin= >g. I am mostly content t=3D> >o live with this as
> > one bit of<= >BR>> > > the price of=3D> > avoiding a horribly over complex langu= >age.
> > >
> > =3D> >> Ordinary procedures can do p= >retty much all of the things done by
&=3D> >gt; > exotic
> >= >; > and complex language stuff like C++ const=3D> >ructors. If you don't= >
> > want to write
> > > the pon=3D> >derous nested v= >alue constructor, write a constructor
> > procedur=3D> >e and
= >> > > call it. As Antony suggested, you can make it accep=3D> >t a= >n open
> > array formal,
> > > which then codes ju=3D= >> >st like a simple array value constructor. You
> > could evenR>&=3D> >gt; > > make it elaborate and general, e.g.:
> > &g= >t;
>=3D> >; > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F
&g= >t; > > >>> > > =3D3D VAR LSize : CARDINAL
> >= >; > ; VAR LResult : =3D> >A
> > >
> > > ; BEGIN<= >BR>> > > LSize :=3D3D =3D> >NUMBER ( Val )
> > > <*= > ASSERT LSize <=3D3D NUMBER ( FooArr=3D> >ay ) *>
> > > ;= > LResult . size :=3D3D LSize
> > > =3D> >; SUBARRAY ( LResult .= > a , 0 , LSize )
> > > :=3D3D SUBARRAY ( Va=3D> >l , FIRST ( Va= >l ) , LSize )
> > > ; RETURN LResult
> >=3D> > > EN= >D MakeF
> > >
> > > Alternatively, since yo=3D> >ur= > maximum element count is so small, you
> > could
> > = >=3D> >> write a constructor procedure that took two formals of type FOO,= >
&=3D> >gt; > with
> > > at least the second one optiona= >l. (This wou=3D> >ld require a
> > distinguished
> > >= >; value of type FO=3D> >O that would be used to mean "omitted".)
> &g= >t; >
> > >=3D> >; And, of course, if you want to use abstract= >ion, you can put the
> =3D> >> types,
> > > construct= >or procedures, and various other pro=3D> >cedures for
> > manipul= >ating
> > > the variable sized=3D> > array in a module, behind = >an interface.
> > >
> > >=3D> >; An additional limit= >ation of Modula-3 in this regard, is that you
>=3D> > > can't
= >> > > make the type F opaque, unless you heap alloc=3D> >ate it, w= >hich we
> > were trying
> > > to avoid. Ada =3D> >wou= >ld allow you to do this, but it's another
> > example of
&g=3D= >> >t; > > a convenience with high cost. It forces the equivalent of t= >he =3D> >
> > revelation
> > > to be located in the eq= >uivalent =3D> >of the interface, but makes it
> > illegal
>= > > > to w=3D> >rite client code that depends on what the revelation i= >s.
> > ><=3D> >BR>> > > This in turn creates a source = >code control nightmare in a=3D> > large
> > project,
> >= > > because now someone who wan=3D> >ts to make what is really a purely <= >BR>> > internal,
> > >=3D> >; implementation change, never= >theless has to check out the
> > in=3D> >terface, and
> >= >; > if you aren't in denial mode, that means imp=3D> >lementers of all t= >he
> > client
> > > code have to go=3D> > to extra tr= >ouble to somehow find out that what
> > appears
&g=3D> >t; >= >; > to be an interface change actually doesn't affect them after a=3D> >= >ll.
> > >
> > > >
> > > > Though = >=3D> >that might seem nice.
> > > >
> > > > A= >m I un=3D> >derstanding everything?
> > > >
> > >= >; > Have =3D> >folks hit this before and there's a set of names that >> > don't s=3D> >eem too lame
> > > > that folks use?= >
> > > ><=3D> >BR>> > > > Also -- language docum= >entation?
> > > &g=3D> >t; Nelson's green book is excellent.>> > > > The stuff in th=3D> >e doc directory is very dry and s= >cientific.
> > > > The tuto=3D> >rial seems more like a refe= >rence. Or maybe I didn't
> > read it e=3D> >nough.
> > &= >gt; > Is there better, in case I need a refresher?<=3D> >BR>> > &g= >t; > I think I got it, via Nelson's book from memory (won=3D> >der if I = >
> > can find mine..) and the reference,
> > >=3D> >; &= >gt; but I don't think anyone could learn from the current online
>=3D= >> >; > docs in the source tree.
> > > >
> > >= > &g=3D> >t; Maybe it's me, some combination of laziness and short attention= >
>=3D> > > span
> > > > as I age..
> > &g= >t; >
>=3D> > > > > Btw, C doesn't offer a great solution = >here, though it offer=3D> >s
> > leaving out some type names.
= >> > > > In C++ =3D> >I could have both .size and operator[].>> > > > Modula-3 see=3D> >ms to be missing operator overloadin= >g.
> > > > It's got some=3D> > builtin stuff, even array ass= >ignment and equality
> > and I thin=3D> >k
> > > >= > even record assignment and equality, but it is sti=3D> >ll a bit
> = >> limiting.
> > >
> > >
>=3D> >; > > = >I have raved on this before, but, having had lots of painful >R>>= > > experience with
> > > user-defined overloading in A=3D> >= >da and C++, I can say with
> > authority, that it is
> >= >=3D> > > a programming language disaster. It interacts with just about <= >BR>>=3D> >; > everything
> > > else in the language, in ve= >ry complicat=3D> >ed ways, and all it buys
> > you is saving
&= >gt; > > time=3D> >/energy thinking up distinct names for procedures/f= >unctions.
> > =3D> >Even this,
> > > aside from the e= >ffects on the language, is a n=3D> >et loss, by the
> > time you = >consider
> > > readabili=3D> >ty along with writability.
>= >; > >
> > > User-defined=3D> > overloaded operators provi= >de a slight readability
> > benefit, _=3D> >if_
> > >= > used with great restraint and discipline, something y=3D> >ou can rely >> > on not happening.
> > > Meanwhile, th=3D> >e languag= >e complexity can easily double or worse.
> > And, with t=3D> >he<= >BR>> > > exception of compiler writers and language lawyers who=3D= >> > spend
> > hundreds of hours
> > > on just this, p= >rog=3D> >rammers don't understand the rules, not even
> > close.<= >BR>> &=3D> >gt; >
> > > >
> > > > Also,= > if I understan=3D> >d things correctly, this has long bothered
> &g= >t; me about Modula-3,=3D> >
> > > > though I'm more tolerant= > now -- Modula-3 doesn't se=3D> >em to allow
> > for lighter wieg= >ht
> > > > objects=3D> >. Like, small stack allocated struct= >s with member
> > functions. =3D> >You seem to have
> > = >> > to chose between heap allocated gar=3D> >bage collected virtual <= >BR>> > member functions full
> > >=3D> >; > featured ob= >jects, or featureless dumb structs. It's nice how C+
=3D> >> > + = >allow hybrids --
> > > > objects don't have to b=3D> >e heap= > allocated and member functions
> > don't have be virtual.<=3D> >= >BR>> > > > Or am I missing something?
> > >
>= >=3D> > > >
> > > C++'s supposedly lighter weight forms of= > class=3D> >es/structs with
> > their special
> > > m= >ember functi=3D> >ons buy nothing that plain records, plain
> > p= >rocedures, and
=3D> >> > > interfaces/modules don't already pro= >vide, again, at signific=3D> >ant
> > and gratuitous
> >= > > language complexity. Exc=3D> >ept when methods/member functions
&= >gt; > actually dispatch
> &=3D> >gt; > dynamically, there is no= >thing that the above won't do, and when >R>> > you create a>> > > class instance as a local variab=3D> >le (i.e., on the stac= >k), it is
> > necessarily
> > > =3D> >not polymorphic= >, that is, it can't change its "allocated" or
> > =3D> >dynamic t= >ype
> > > among various subtypes at runtime. This in t=3D> >urn= > means it can't
> > dispatch.
> > >
> > &=3D= >> >gt; So, just use plain procedures, an interface and a module, and you R>&=3D> >gt; > will get
> > > everything a lighter-weight C+= >+ class w=3D> >ould give you.
> > >
> > >
> &= >gt; > > >R>> > > > Anyway, I've gotten to accept C = >a bit more vs. C++ so=3D> > I can
> > deal with
> > >= > > t: Type;
> >=3D> > > > Type_DoSomething(t);
> &g= >t; > >
> > > &g=3D> >t; in place of:
> > > &g= >t; t.DoSomething();
> > > >R>> > >
> > = >> Exactly. The special "receiver object" i=3D> >n a true method call has= >
> > significant
> > > semant=3D> >ic differences fro= >m an ordinary parameter and introduces
> > new =3D> >complexities= >
> > > and non-orthogonalities. It has some very va=3D> >luable= > uses too.
> > >
> > > But to then create deg=3D> >= >enerate forms of it that still carry a lot
> > of these
> &= >=3D> >gt; > complexities, but are equivalent in programing power to plai= >n old<=3D> >BR>> > > parameters is just bad program design and bad= > language de=3D> sign.
> > Objects and
> > > methods = >are indeed cool f=3D> >or situations that utilize their
> > seman= >tic complexity.
>=3D> > > > But it's deeply uncool to try to lo= >ok superficially cool by usin=3D> >g an
> > > inappropriately s= >ophisticated construct when the pro=3D> >blem doesn't
> > justify= > it.
> > > Some OO proponents=3D> > have gone way over the deep= > end here.
> > >
> > > =3D> >>
> > >= > > - Jay
> > > >
> > > =3D> >>
> >= >; > >
> > ---------------------------------=3D> >----------= >---------------------------
> > --
> > > &g=3D> >t; B= >oo! Scare away worms, viruses and so much more! Try Windows
> &g=3D>= > >t; Live OneCare! Try now!
> > > <http://onecare.live.com/s= >ta=3D> >ndard/en-us/purchase/trial.aspx?
> > s_cid=3D3Dwl_hotmail= >news> >R>> > >
> > >
> > > --
= >> > > -=3D> >-----------------------------------------------------= >-------
> > &=3D> >gt; Rodney M. Bates, retired assistant professo= >r
> > > Dept. of=3D> > Computer Science, Wichita State Universi= >ty
> > > Wichita, KS 6=3D> >7260-0083
> > > 316-978= >-3922
> > > rodney.bates at wic=3D> >hita.edu
> > >>> > > --
> > > ---------=3D> >-----------------------= >-----------------------------
> > > Rodn=3D> >ey M. Bates, reti= >red assistant professor
> > > Dept. of Compute=3D> >r Science, = >Wichita State University
> > > Wichita, KS 67260-008=3D> >3
= >> > > 316-978-3922
> > > rodney.bates at wichita.edu=3D> = >>
> >
> >
> > Boo! Scare away worms, viruses and= =3D> >so much more! Try Windows Live
> > OneCare! Try now!
&g= >t;
=3D> >


Climb to the top of the charts!=3DA0 Play Star= > Shuffle:=3DA0 th=3D> >e word scramble challenge with star power. =3D3D'http://club.live.com/=3D> >star_shuffle.aspx?icid=3D3Dstarshuffle_wlm= >ailtextlink_oct' target=3D3D'_new'>Pl=3D> >ay Now!> >=3D>= > >> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_-- >_________________________________________________________________ >Help yourself to FREE treats served up daily at the Messenger Caf=E9. Stop = >by today. >http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=3DTXT_TAGLM_Oc= >tWLtagline= > >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > > >> VAR v : T;
> DoSomething(v);
> <= >BR>> What's the big deal if it's DoSomething(v) or v.NT face=3D"">DoSomething()?

 VAR x : T1;
= > VAR y : T2;
 DoSomething(x);
 DoSomething(y);>
>isn't legal, right?

>So I have to:
>
 M1.DoSomething(x);
 M2.DoSomething(y);

>right? Constantly repeating types, or modules, on function names?

> - Jay

> >
>
>> To: jay.krell at cornell.edu
> Subject: Re: [M3devel] small array i= >n modula-3?
> Date: Thu, 15 Nov 2007 21:00:13 -0800
> From: mi= >ka at async.caltech.edu
>
> Why not
>
> FROM M IMPO= >RT T, DoSomething;
>
> VAR v : T;
> DoSomething(v);
&= >gt;
> What's the big deal if it's DoSomething(v) or = >v.DoSomething()?
>
> If anything= >, "DoSomething(v)" tells me that the call can be statically
> resolve= >d, whereas v.DoSomething() te= >lls me that something odd can
> happen at runtime---that is, I cannot= > be sure I understand this
> code simply by looking for a routine cal= >led "DoSomething" and reading
> that, but have to be more careful. Th= >is distinction is unclear in
> C++. What, in fact, is the distinction= > in C++ between DoSomething(v)
> and v.">DoSomething()? None, right? Just two ways of saying the
= >> same thing... why?
>
> The Modula-2+ work on the Firefly = >is also close enough to be "almost"
> Modula-3...
>
> Re= >garding UNSAFE: most interfaces to C code are (or should be)
> UNSAFE= > because there are ways of calling them that can lead to
> unchecked = >runtime errors. I don't see how you can live without
> UNSAFE if you = >ever want to link with other people's C libraries...
>
> Mika<= >BR>>
> Jay writes:
> >--_0109391c-2ffe-4cfe-9165-c2a2462= >8c3c7_
> >Content-Type: text/plain; charset=3D"iso-8859-1"
>= > >Content-Transfer-Encoding: quoted-printable
> >
> >B= >ut if I don't want to pay for heap allocation, I can't say:
> >=3D= >20
> >VAR T: v;
> >=3D20
> >v.ONT face=3D"">DoSomething();
> >=3D20
> >On= >ly IMPORT T FROM M;
> >=3D20
> >VAR T: v;
> >=3D= >20
> >M.DoSomething(v);
> >=3D20
> >Right?
&g= >t; >SPIN I think you mean.
> >Anyone build it and bring it up? = >I was long curious but never did..
> >=3D20
> > - Jay
= >> >
> >
> >
> >> CC: m3devel at elegosoft.= >com> From: darko at darko.org> Subject: Re: [M3devel] =3D
> >sm= >all array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: ja= >y.kr=3D
> >ell at cornell.edu> > Not sure what the problem is w= >ith modules. If you want t=3D
> >o avoid the > dot you can name= > the type something unique then import that t=3D
> >ype > name.= > You can create an interface with all the nice type names and > =3D
&= >gt; >import all those names in modules by adding an EXPORTS clause too.&= >gt; > Perso=3D
> >nally I think M3, with a couple of extensions= >, wouldn't need > unsafe anyth=3D
> >ing. The unsafe features a= >re there mostly because of > legacy interfaces. I=3D
> > forget= > the name but the folk who wrote an OS in > M3 found it very effecti=3D<= >BR>> >ve with only couple of minor points with > regards to interf= >acing to C code=3D
> > they built on top of, I think one of > t= >hem was being able to pass NIL to =3D
> >a VAR parameter, which is= > a common > C idiom (and an annoying one for M3 us=3D
> >ers wh= >o then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:&= >gt; > =3D
> >> Rodney, thank you, this is interesting.> &= >gt; I definitely don't want to pay=3D
> > for heap allocation for = >a tiny array.> > I don't know about "subarray". It=3D
> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered = >ano=3D
> >ther copy of the Nelson book > > so I don't have t= >o find mine.> >> > Good i=3D
> >dea "MakeT" I forgot a= >bout that pattern. I'll try it out.> >> > The record =3D
>= >; >and array I propose are not all that different really.> > I jus= >t heard of s=3D
> >omething new. Have you heard of it? "Duck typin= >g". > > If it acts/quacks/wa=3D
> >lks like a duck, it is a = >duck.> > This is in very dynamic languages like Ru=3D
> >by.= >> > You apply object.method and if object defines something named >= >; > "m=3D
> >ethod", then it "must" have "the" meaning you inte= >nd.> > Kind of like how C=3D
> >++ templates "accept as para= >meters whatever > > happens to work".> >> > Ope=3D
>= >; >rator overloading is great for strings and "math".> >> > = >Maybe I should try=3D
> > to have this language debate from scratc= >h again..?> >> > I still am conflc=3D
> >ted.> >= >> > Modules seem overly heavyweight.> > I don't want Module1.T,= > Modu=3D
> >le2.T, I want T1, T2.> >> > C++ stack stru= >cts with non virtual member funct=3D
> >ions:> > class Rect_= >t> > {> > Rect_t() : top(0), left(0), right(0), bottom(=3D
&= >gt; >0) { }> >> > int Height() { return bottom - top; }> = >> int Width() { return =3D
> >right - left; }> > int top,= > left, bottom, right;> > };> >> > seems "good".>=3D>> > >> > And it seems not really all that complicated for t= >he compiler to > > =3D
> >flow the static type information a= >round to resolve the functions..> >> > Re=3D
> >ct_t r= >;> > r.Height() =3D3D> Rect_Height(&r); ..and would be inlined= > anyway.>=3D
> > >> > I do find some compelling featur= >es in Modula-3. Mainly that it > > co=3D
> >mpiles to native= > code and has OPTIONAL safety, optional garbage > > collect=3D
>= >; >ion, and that the syntax of modules/interfaces allows fast > > = >compilation =3D
> >-- no longer reparsing the same headers over an= >d over > > and over and over=3D
> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D
= >> > like a primitive integer, but raises exceptions upon overflow.>= >; > For this=3D
> > to work very much requires operator overloa= >ding.> >> > A point, of course,=3D
> > is to be able t= >o have user defined types that > > can act like the built i=3D
>= >; >n types..> >> > - Jay> >> >> > > Dat= >e: Thu, 15 Nov 2007 18:39:18 -0600> > >=3D
> > From: rodn= >ey.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > = >Subject=3D
> >: Re: [M3devel] small array in modula-3?> > &g= >t;> > > Jay wrote:> > >> > > > W=3D
> &= >gt;hat is the right way to have a variably sized but always small > >= > array in=3D
> > Modula-3?> > > > My array will only e= >ver have 1 or 2 elements.> > > > I'd =3D
> >like to al= >ways allocate room for 2 elements, and have there > > be a size.>= >=3D
> > > > >> > > > It seems I have a choice= > of> > > >> > > > a) an "open" array>=3D
>= > > > >> > > Heap allocated, I presume? If the max size is= > only 2 elements,> >=3D
> > > this is pretty extravagant,= > as a heap allocated open array will> > > hav=3D
> >e 4 e= >xtra behind-the-scenes words of space overhead, plus> > > maybe he= >ap f=3D
> >ragmentation, and time overhead of allocation,> >= > > collection, and maybe r=3D
> >educed locality of reference.&= >gt; > >> > > > b) wrap it up in a record> > > &g= >t;>=3D
> > > > > I'd like so have, like:> > >= > >> > > > TYPE A =3D3D ARRAY [0..1] OF FOO=3D
> >;&= >gt; > > >> > > > And be able to say:> > > >= >;> > > > VAR> > > > a : A;> > > >>= >=3D
> > > > > ..> > > > a.size> > > = >> FOR i :=3D3D 0 TO a.size DO> > > > do somethin=3D
> = >>g with a[i]> > > >> > > > It seems I have no op= >tion but, like:> > > >> > > =3D
> >> TYPE = >A =3D3D RECORD> > > > a: ARRAY[0..1] OF FOO;> > > >= > size :=3D3D 1; (* us=3D
> >ually of size 1, sometimes 2 *)> &g= >t; > > END> > > >> > > > and then> > &g= >t; > FO=3D
> >R i :=3D3D 0 TO a.size DO> > > > do s= >omething with a.a[i];> > > >> > > > That=3D
>= > > is "ok". Not great -- what to call the inner a?> > > > Bu= >t then furthermor=3D
> >e, I'd like to construct constants.> &g= >t; > > It seems I am stuck with either =3D
> >the verbose:&g= >t; > > >> > > > PROCEDURE F(a:A);> > > >&g= >t; > > > F( A { ARRAY[0..=3D
> >1] OF FOO { .. } );> &= >gt; > >> > > > OR I have to come up with a name for the = >=3D
> >embedded array.> > > > But of course, its type = >is really "the same" as the =3D
> >outer type.> > >> &= >gt; >> > > Ignoring the fact that the types are different l=3D<= >BR>> >inguistically> > > (one a record type, the other an ar= >ray), the types are d=3D
> >ifferent> > > at a deep seman= >tic level too. The inner array has static> > >=3D
> > siz= >e, the outer one (call it a "variable array", perhaps)> > > has dy= >namic=3D
> >ally changeable size, even more easily changed> >= >; > after it is created tha=3D
> >n a heap-allocated open array= >. This> > > is a significant semantic differen=3D
> >ce, = >so it also makes program> > > design sense to view them as differe= >nt ty=3D
> >pes.> > >> > > >> > > &g= >t; To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[= >0..1]=3D
> > OF Foo;> > > >> > > > TYPE Fo= >oArray =3D3D RECORD> > > > a : FooArray;> > > >=3D<= >BR>> > size :=3D3D 1;> > > > END;> > > >> = >> > > F( FooArray { FooArray { .. } );> >=3D
> > &g= >t; >> > > > But I have to come up with different names.> = >> > >> > > > And I=3D
> > don't think I can l= >eave out the name for the constructor, > > like:> > > >= >=3D
> >> > > > F( FooArray { { .. } );> > >&g= >t; > >> > > Yes, this is a limitation in=3D
> > Mod= >ula-3. Ada allows value constructors> > > to omit inner type names= > in c=3D
> >ases like this, and it is > > convenient. But>= >; > > it also crosses a really=3D
> > major line on complexi= >ty of the language > > semantics,> > > since type an=3D
&= >gt; >alysis information now flows not only upward, but > > also do= >wnward> > > in=3D
> > expression typing. I am mostly cont= >ent to live with this as > > one bit of=3D
> >> > >= > the price of avoiding a horribly over complex language.> > >> = >> > Ord=3D
> >inary procedures can do pretty much all of the= > things done by > > exotic> >=3D
> > > and complex = >language stuff like C++ constructors. If you don't > > want =3D
&g= >t; >to write> > > the ponderous nested value constructor, write= > a constructor >=3D
> > > procedure and> > > call i= >t. As Antony suggested, you can make it accept =3D
> >an open >= > array formal,> > > which then codes just like a simple array= > va=3D
> >lue constructor. You > > could even> > > = >make it elaborate and general, e.g=3D
> .:> > >> > >= >; PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = >=3D3D VAR L=3D
> >Size : CARDINAL> > > ; VAR LResult : A&= >gt; > >> > > ; BEGIN> > > LSize :=3D3D NU=3D
>= >; >MBER ( Val )> > > <* ASSERT LSize <=3D3D NUMBER ( FooA= >rray ) *>> > > ; LResul=3D
> >t . size :=3D3D LSize>= >; > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S= >=3D
> >UBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RET= >URN LResult> > > END Make=3D
> >F> > >> > = >> Alternatively, since your maximum element count is so small, yo=3D
= >> >u > > could> > > write a constructor procedure that= > took two formals of typ=3D
> >e FOO, > > with> > >= > at least the second one optional. (This would require =3D
> >a &g= >t; > distinguished> > > value of type FOO that would be used to= > mean "omit=3D
> >ted".)> > >> > > And, of cours= >e, if you want to use abstraction, you can pu=3D
> >t the > >= >; types,> > > constructor procedures, and various other procedures= > =3D
> >for > > manipulating> > > the variable size= d array in a module, behind an i=3D
> >nterface.> > >>= > > > An additional limitation of Modula-3 in this regard, is=3D
&g= >t; > that you > > can't> > > make the type F opaque, unle= >ss you heap allocate i=3D
> >t, which we > > were trying>= > > > to avoid. Ada would allow you to do this, =3D
> >but it= >'s another > > example of> > > a convenience with high cost.= > It force=3D
> >s the equivalent of the > > revelation> &= >gt; > to be located in the equivalent=3D
> > of the interface, = >but makes it > > illegal> > > to write client code that =3D<= >BR>> >depends on what the revelation is.> > >> > > = >This in turn creates a source =3D
> >code control nightmare in a l= >arge > > project,> > > because now someone who=3D
> &g= >t; wants to make what is really a purely > > internal,> > > = >implementation ch=3D
> >ange, nevertheless has to check out the &g= >t; > interface, and> > > if you aren=3D
> >'t in denia= >l mode, that means implementers of all the > > client> > > c= >ode =3D
> >have to go to extra trouble to somehow find out that wh= >at > > appears> > > =3D
> >to be an interface chang= >e actually doesn't affect them after all.> > >> > >=3D>> > >> > > > Though that might seem nice.> > &g= >t; >> > > > Am I understanding eve=3D
> >rything?&g= >t; > > >> > > > Have folks hit this before and there's= > a set of name=3D
> >s that > > don't seem too lame> >= > > > that folks use?> > > >> > > > Also --=3D= >
> > language documentation?> > > > Nelson's green boo= >k is excellent.> > > > Th=3D
> >e stuff in the doc dir= >ectory is very dry and scientific.> > > > The tutoria=3D
>= >; >l seems more like a reference. Or maybe I didn't > > read it en= >ough.> > > >=3D
> > Is there better, in case I need a = >refresher?> > > > I think I got it, via =3D
> >Nelson'= >s book from memory (wonder if I > > can find mine..) and the referen= >=3D
> >ce,> > > > but I don't think anyone could learn= > from the current online > >=3D
> > docs in the source tree.= >> > > >> > > > Maybe it's me, some combination of = >=3D
> >laziness and short attention > > span> > > &= >gt; as I age..> > > >> > > > Btw, =3D
> >C= > doesn't offer a great solution here, though it offers > > leaving ou= >t som=3D
> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D
> >Modula-3 seems= > to be missing operator overloading.> > > > It's got some bui= >=3D
> >ltin stuff, even array assignment and equality > > an= >d I think> > > > even =3D
> >record assignment and equ= >ality, but it is still a bit > > limiting.> > >> >=3D<= >BR>> > >> > > I have raved on this before, but, having ha= >d lots of painful > > ex=3D
> >perience with> > > u= >ser-defined overloading in Ada and C++, I can say with =3D
> >>= > > authority, that it is> > > a programming language disaster. = >It interact=3D
> >s with just about > > everything> > = >> else in the language, in very complic=3D
> >ated ways, and al= >l it buys > > you is saving> > > time/energy thinking up d= >=3D
> >istinct names for procedures/functions. > > Even this= >,> > > aside from the =3D
> >effects on the language, is = >a net loss, by the > > time you consider> > > r=3D
> &= >gt;eadability along with writability.> > >> > > User-defi= >ned overloaded operat=3D
> >ors provide a slight readability > = >> benefit, _if_> > > used with great res=3D
> >traint = >and discipline, something you can rely > > on not happening.> >= > > Me=3D
> >anwhile, the language complexity can easily double = >or worse. > > And, with =3D
> >the> > > exception o= >f compiler writers and language lawyers who spend > > h=3D
> &g= >t;undreds of hours> > > on just this, programmers don't understand= > the rules,=3D
> > not even > > close.> > >> >= >; > >> > > > Also, if I understand things correc=3D
&g= >t; >tly, this has long bothered > > me about Modula-3,> > &g= >t; > though I'm more t=3D
> >olerant now -- Modula-3 doesn't se= >em to allow > > for lighter wieght> > > >=3D
> >= > objects. Like, small stack allocated structs with member > > functio= >ns. Yo=3D
> >u seem to have> > > > to chose between he= >ap allocated garbage collected vir=3D
> >tual > > member fun= >ctions full> > > > featured objects, or featureless dumb=3D
= >> > structs. It's nice how C+ > > + allow hybrids --> > &= >gt; > objects don't have=3D
> > to be heap allocated and member= > functions > > don't have be virtual.> > > =3D
> >&= >gt; Or am I missing something?> > >> > >> > > C+= >+'s supposedly lighter weight=3D
> > forms of classes/structs with= > > > their special> > > member functions buy =3D
> >= >;nothing that plain records, plain > > procedures, and> > > = >interfaces/modul=3D
> >es don't already provide, again, at signifi= >cant > > and gratuitous> > > lan=3D
> >guage comple= >xity. Except when methods/member functions > > actually dispatc=3D>> >h> > > dynamically, there is nothing that the above won'= >t do, and when > > =3D
> >you create a> > > class i= >nstance as a local variable (i.e., on the stack), =3D
> >it is >= >; > necessarily> > > not polymorphic, that is, it can't change = >its "a=3D
> >llocated" or > > dynamic type> > > amo= >ng various subtypes at runtime. This =3D
> >in turn means it can't= > > > dispatch.> > >> > > So, just use plain procedu= >re=3D
> >s, an interface and a module, and you > > will get&= >gt; > > everything a lighte=3D
> >r-weight C++ class would g= >ive you.> > >> > >> > > >> > > > = >Anyway, I've got=3D
> >ten to accept C a bit more vs. C++ so I can= > > > deal with> > > > t: Type;> =3D
> >> &= >gt; > Type_DoSomething(t);> > > >> > > > in plac= >e of:> > > > t.DoSomething(=3D
> >);> > >>= > > >> > > Exactly. The special "receiver object" in a true m= >ethod c=3D
> >all has > > significant> > > semantic= > differences from an ordinary paramete=3D
> >r and introduces >= > > new complexities> > > and non-orthogonalities. It has =3D>> >some very valuable uses too.> > >> > > But to t= >hen create degenerate forms =3D
> >of it that still carry a lot &g= >t; > of these> > > complexities, but are equiva=3D
> >= >lent in programing power to plain old> > > parameters is just bad = >program d=3D
> >esign and bad language design. > > Objects a= >nd> > > methods are indeed cool=3D
> > for situations tha= >t utilize their > > semantic complexity.> > > But it's d=3D<= >BR>> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D
> >tely sophisticated construct when the = >problem doesn't > > justify it.> > > =3D
> >Some OO= > proponents have gone way over the deep end here.> > >> > &g= >t; >> > > >=3D
> > - Jay> > > >> >= >; > >> > > > > > ----------------------------------= >---------=3D
> >--------------------------- > > --> > = >> > Boo! Scare away worms, viruses an=3D
> >d so much more! = >Try Windows > > Live OneCare! Try now!> > > <http://oneca= >re=3D
> >.live.com/standard/en-us/purchase/trial.aspx? > > s= >_cid=3D3Dwl_hotmailnews>> =3D
> >> >> > >>= > > > --> > > -----------------------------------------------= >------=3D
> >--------> > > Rodney M. Bates, retired assis= >tant professor> > > Dept. of Co=3D
> >mputer Science, Wic= >hita State University> > > Wichita, KS 67260-0083> > > 3= >=3D
> >16-978-3922> > > rodney.bates at wichita.edu> >= > >> > > --> > > ---------------=3D
> >-------= >---------------------------------------> > > Rodney M. Bates, reti= >re=3D
> >d assistant professor> > > Dept. of Computer Sci= >ence, Wichita State Univers=3D
> >ity> > > Wichita, KS 67= >260-0083> > > 316-978-3922> > > rodney.bates at wichita=3DR>> >.edu> >> >> > Boo! Scare away worms, viruses a= >nd so much more! Try Windows =3D
> >Live > > OneCare! Try no= >w!>=3D20
> >___________________________________________________= >______________
> >Climb to the top of the charts!=3DA0 Play Star S= >huffle:=3DA0 the word scramble =3D
> >challenge with star power.R>> >http://club.live.com/star_shuffle.aspx?icid=3D3Dstarshuffle_wlma= >iltextlink_oc=3D
> >t=3D
> >
> >--_0109391c-2ffe= >-4cfe-9165-c2a24628c3c7_
> >Content-Type: text/html; charset=3D"is= >o-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> &= >gt;
> ><html>
> ><head>
> ><style= >>
> >.hmmessage P
> >{
> >margin:0px;
>= > >padding:0px
> >}
> >body.hmmessage
> >{
= >> >FONT-SIZE: 10pt;
> >FONT-FAMILY:Tahoma
> >}
&= >gt; ></style>
> ></head>
> ><body class= >=3D3D'hmmessage'>But if I don't want to pay for heap allocation, I=3D>> > can't say:<BR>
> >&nbsp;<BR>
> &g= >t;VAR T: v;<BR>
> >&nbsp;<BR>
> >ce=3D"">v.DoSomething();<BR>
> &g= >t;&nbsp;<BR>
> >Only IMPORT T FROM M;<BR>
> = >>&nbsp;<BR>
> >VAR T: v;<BR>
> >&n= >bsp;<BR>
> >M.DoSomething(v);<BR>
> >&nbs= >p;<BR>
> >Right?<BR><BR>
> >SPIN I thin= >k you mean.<BR>
> >Anyone build it and bring it up? I was lo= >ng curious but never did..<BR>
> >&nbsp;<BR>
&g= >t; >&nbsp;- Jay<BR><BR><BR>
> >
> &= >gt;<HR id=3D3DstopSpelling>
> ><BR>
> >&g= >t; CC: m3devel at elegosoft.com<BR>&gt; From: darko at darko.org<BR&= >gt;&gt; Subjec=3D
> >t: Re: [M3devel] small array in modula-3?= ><BR>&gt; Date: Thu, 15 Nov 2007 20=3D
> >:29:06 -0800<= >;BR>&gt; To: jay.krell at cornell.edu<BR>&gt; <BR>&= >gt; Not sure wh=3D
> >at the problem is with modules. If you want = >to avoid the <BR>&gt; dot you c=3D
> >an name the type s= >omething unique then import that type <BR>&gt; name. You =3D
&= >gt; >can create an interface with all the nice type names and <BR>= >&gt; import al=3D
> >l those names in modules by adding an EXP= >ORTS clause too.<BR>&gt; <BR>&gt; =3D
> >Perso= >nally I think M3, with a couple of extensions, wouldn't need <BR>&= >;gt; =3D
> >unsafe anything. The unsafe features are there mostly = >because of <BR>&gt; l=3D
> >egacy interfaces. I forget t= >he name but the folk who wrote an OS in <BR>&gt=3D
> >; = >M3 found it very effective with only couple of minor points with <BR>= >&gt;=3D
> > regards to interfacing to C code they built on top= > of, I think one of <BR>=3D
> >&gt; them was being able = >to pass NIL to a VAR parameter, which is a common =3D
> ><BR>= >;&gt; C idiom (and an annoying one for M3 users who then can't use VAR)= >.=3D
> ><BR>&gt; <BR>&gt; <BR>&gt; O= >n 15/11/2007, at 8:08 PM, Jay wrote:<BR>&gt; <B=3D
> >= >;R>&gt; &gt; Rodney, thank you, this is interesting.<BR>&a= >mp;gt; &gt; I definite=3D
> >ly don't want to pay for heap all= >ocation for a tiny array.<BR>&gt; &gt; I d=3D
> >on'= >t know about "subarray". It looks like it takes and returns <BR>&= >gt; &gt=3D
> >; arrays. It's not a type. I ordered another cop= >y of the Nelson book <BR>&g=3D
> >t; &gt; so I don't= > have to find mine.<BR>&gt; &gt;<BR>&gt; &gt; G= >ood idea "=3D
> >MakeT" I forgot about that pattern. I'll try it o= >ut.<BR>&gt; &gt;<BR>&gt; &=3D
> >gt; T= >he record and array I propose are not all that different really.<BR>&= >amp;g=3D
> >t; &gt; I just heard of something new. Have you he= >ard of it? "Duck typing".=3D
> > <BR>&gt; &gt; If it= > acts/quacks/walks like a duck, it is a duck.<BR>&gt; &=3D>> >gt; This is in very dynamic languages like Ruby.<BR>&gt= >; &gt; You apply obj=3D
> >ect.method and if object defines so= >mething named <BR>&gt; &gt; "method", th=3D
> >en it= > "must" have "the" meaning you intend.<BR>&gt; &gt; Kind of l= >ike how C=3D
> >++ templates "accept as parameters whatever <BR= >>&gt; &gt; happens to work".=3D
> ><BR>&gt; &= >amp;gt;<BR>&gt; &gt; Operator overloading is great for string= >s and "m=3D
> >ath".<BR>&gt; &gt;<BR>&gt; = >&gt; Maybe I should try to have this language de=3D
> >bate fr= >om scratch again..?<BR>&gt; &gt;<BR>&gt; &gt; I= > still am conflcted.<=3D
> >BR>&gt; &gt;<BR>&a= >mp;gt; &gt; Modules seem overly heavyweight.<BR>&gt; &gt;= > I d=3D
> >on't want Module1.T, Module2.T, I want T1, T2.<BR>= >;&gt; &gt;<BR>&gt; &gt; C+=3D
> >+ stack str= >ucts with non virtual member functions:<BR>&gt; &gt; class Re= >ct_=3D
> >t<BR>&gt; &gt; {<BR>&gt; &gt= >; Rect_t() : top(0), left(0), right(0), bottom(=3D
> >0) { }<BR= >>&gt; &gt;<BR>&gt; &gt; int Height() { return bott= >om - top; }<BR>&=3D
> >gt; &gt; int Width() { return= > right - left; }<BR>&gt; &gt; int top, left, b=3D
> >= >;ottom, right;<BR>&gt; &gt; };<BR>&gt; &gt;<= >BR>&gt; &gt; seems "good".<BR>&g=3D
> >t; &am= >p;gt;<BR>&gt; &gt; And it seems not really all that complicat= >ed for the c=3D
> >ompiler to <BR>&gt; &gt; flow the= > static type information around to resolve=3D
> > the functions..&= >lt;BR>&gt; &gt;<BR>&gt; &gt; Rect_t r;<BR>&a= >mp;gt; &gt; r.Height(=3D
> >) =3D3D&gt; Rect_Height(&a= >mp;r); ..and would be inlined anyway.<BR>&gt; &gt;<=3D
= >> >BR>&gt; &gt; I do find some compelling features in Modu= >la-3. Mainly that it=3D
> > <BR>&gt; &gt; compiles t= >o native code and has OPTIONAL safety, optional ga=3D
> >rbage <= >;BR>&gt; &gt; collection, and that the syntax of modules/interfa= >ces a=3D
> >llows fast <BR>&gt; &gt; compilation -- = >no longer reparsing the same header=3D
> >s over and over <BR&g= >t;&gt; &gt; and over and over.<BR>&gt; &gt;<BR>= >&gt; &gt; =3D
> >Operator overloading btw..have seen "temp= >late SafeInt"? It acts <BR>&gt; &g=3D
> >t; like a p= >rimitive integer, but raises exceptions upon overflow.<BR>&gt; &a= >mp;=3D
> >gt; For this to work very much requires operator overloa= >ding.<BR>&gt; &gt;<=3D
> >BR>&gt; &gt;= > A point, of course, is to be able to have user defined types t=3D
> = >>hat <BR>&gt; &gt; can act like the built in types..<BR= >>&gt; &gt;<BR>&gt; &g=3D
> >t; - Jay<B= >R>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt= >; &gt; Date: Thu, 15 Nov 2007=3D
> > 18:39:18 -0600<BR>&= >amp;gt; &gt; &gt; From: rodney.bates at wichita.edu<BR>&gt; = >&g=3D
> >t; &gt; To: m3devel at elegosoft.com<BR>&g= >t; &gt; &gt; Subject: Re: [M3devel] =3D
> >small array in = >modula-3?<BR>&gt; &gt; &gt;<BR>&gt; &gt; &a= >mp;gt; Jay wrote:<BR>=3D
> >&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &gt; What is the right way to have a var= >ia=3D
> >bly sized but always small <BR>&gt; &gt; ar= >ray in Modula-3?<BR>&gt; &gt; &g=3D
> >t; &g= >t; My array will only ever have 1 or 2 elements.<BR>&gt; &gt;= > &gt; &gt=3D
> >; I'd like to always allocate room for 2 e= >lements, and have there <BR>&gt; =3D
> >&gt; be a si= >ze.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt;= > &gt; &gt; It seems I ha=3D
> >ve a choice of<BR>&am= >p;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t; a) an "open" a=3D
> >rray<BR>&gt; &gt; &gt;&l= >t;BR>&gt; &gt; &gt; Heap allocated, I presume? If the =3D>> >max size is only 2 elements,<BR>&gt; &gt; &gt; = >this is pretty extravagant, =3D
> >as a heap allocated open array = >will<BR>&gt; &gt; &gt; have 4 extra behind-t=3D
> &= >gt;he-scenes words of space overhead, plus<BR>&gt; &gt; &= >gt; maybe heap fragme=3D
> >ntation, and time overhead of allocati= >on,<BR>&gt; &gt; &gt; collection, and=3D
> > may= >be reduced locality of reference.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &=3D
> >gt; b) wrap it up in a = >record<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &gt;=3D
> > I'd like so have, like:<BR>&= >;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt= >; TYPE=3D
> > A =3D3D ARRAY [0..1] OF FOO;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; A=3D
= >> >nd be able to say:<BR>&gt; &gt; &gt; &gt;<= >;BR>&gt; &gt; &gt; &gt; VAR<BR>&gt=3D
> = >>; &gt; &gt; &gt; a : A;<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; ..<BR=3D
> = >>>&gt; &gt; &gt; &gt; a.size<BR>&gt; &g= >t; &gt; &gt; FOR i :=3D3D 0 TO a.size D=3D
> >O<BR>&= >amp;gt; &gt; &gt; &gt; do something with a[i]<BR>&gt;= > &gt; &gt; &gt;<BR>&=3D
> >gt; &gt; &= >;gt; &gt; It seems I have no option but, like:<BR>&gt; &g= >t; &gt; &=3D
> >gt;<BR>&gt; &gt; &gt; &a= >mp;gt; TYPE A =3D3D RECORD<BR>&gt; &gt; &gt; &gt; a: = >ARRA=3D
> >Y[0..1] OF FOO;<BR>&gt; &gt; &gt; &am= >p;gt; size :=3D3D 1; (* usually of size 1, s=3D
> >ometimes 2 *)&l= >t;BR>&gt; &gt; &gt; &gt; END<BR>&gt; &gt; = >&gt; &gt;<BR>&gt; &gt=3D
> >; &gt; &= >gt; and then<BR>&gt; &gt; &gt; &gt; FOR i :=3D3D 0 TO= > a.size DO<BR>&g=3D
> >t; &gt; &gt; &gt; do = >something with a.a[i];<BR>&gt; &gt; &gt; &gt;<BR&g= >t;&gt; =3D
> >&gt; &gt; &gt; That is "ok". Not gre= >at -- what to call the inner a?<BR>&gt;=3D
> > &gt; = >&gt; &gt; But then furthermore, I'd like to construct constants.<= >;BR>&=3D
> >gt; &gt; &gt; &gt; It seems I am st= >uck with either the verbose:<BR>&gt; &gt=3D
> >; &am= >p;gt; &gt;<BR>&gt; &gt; &gt; &gt; PROCEDURE F(a:A= >);<BR>&gt; &gt; &gt; &gt;=3D
> ><BR>&a= >mp;gt; &gt; &gt; &gt; F( A { ARRAY[0..1] OF FOO { .. } );<BR= >>&gt; &gt; &g=3D
> >t; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; OR I have to come up with a name for the emb=3DR>> >edded array.<BR>&gt; &gt; &gt; &gt; But of= > course, its type is really "the =3D
> >same" as the outer type.&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<B= >R>&gt; &gt; &=3D
> >gt; Ignoring the fact that the = >types are different linguistically<BR>&gt; &=3D
> >g= >t; &gt; (one a record type, the other an array), the types are differen= >t<B=3D
> >R>&gt; &gt; &gt; at a deep semantic le= >vel too. The inner array has static<B=3D
> >R>&gt; &= >gt; &gt; size, the outer one (call it a "variable array", perhaps)<= >=3D
> >BR>&gt; &gt; &gt; has dynamically changeable= > size, even more easily changed=3D
> ><BR>&gt; &gt; = >&gt; after it is created than a heap-allocated open array. Th=3D
>= >; >is<BR>&gt; &gt; &gt; is a significant semantic diff= >erence, so it also makes=3D
> > program<BR>&gt; &gt;= > &gt; design sense to view them as different types.<BR=3D
> &g= >t;>&gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t;<BR>&gt; &gt; &gt; &gt; To wit:<BR>&g=3D<= >BR>> >t; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &gt; TYPE FooArray =3D3D ARRAY[0..1] OF F=3D
> >oo;<BR&g= >t;&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &= >amp;gt; TYPE FooArray =3D3D RECORD<=3D
> >BR>&gt; &g= >t; &gt; &gt; a : FooArray;<BR>&gt; &gt; &gt; &= >;gt; size :=3D3D 1;<BR=3D
> >>&gt; &gt; &gt; &am= >p;gt; END;<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; F( =3D
> >FooArray { FooArray { .. } );&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &am= >p;gt; &gt;=3D
> > But I have to come up with different names.&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt;=3D
> &= >gt; &gt; &gt; &gt; And I don't think I can leave out the name f= >or the construc=3D
> >tor, <BR>&gt; &gt; like:<BR= >>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt;= > &gt; F( F=3D
> >ooArray { { .. } );<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &= >amp;gt; Y=3D
> >es, this is a limitation in Modula-3. Ada allows v= >alue constructors<BR>&gt;=3D
> > &gt; &gt; to om= >it inner type names in cases like this, and it is <BR>&gt; =3D>> >&gt; convenient. But<BR>&gt; &gt; &gt; it a= >lso crosses a really major line =3D
> >on complexity of the langua= >ge <BR>&gt; &gt; semantics,<BR>&gt; &gt; &g= >t; si=3D
> >nce type analysis information now flows not only upwar= >d, but <BR>&gt; &gt; =3D
> >also downward<BR>&= >amp;gt; &gt; &gt; in expression typing. I am mostly content t=3D>> >o live with this as <BR>&gt; &gt; one bit of<BR&= >gt;&gt; &gt; &gt; the price of=3D
> > avoiding a horri= >bly over complex language.<BR>&gt; &gt; &gt;<BR>&am= >p;gt; &gt; =3D
> >&gt; Ordinary procedures can do pretty m= >uch all of the things done by <BR>&=3D
> >gt; &gt; e= >xotic<BR>&gt; &gt; &gt; and complex language stuff like C= >++ const=3D
> >ructors. If you don't <BR>&gt; &gt; w= >ant to write<BR>&gt; &gt; &gt; the pon=3D
> >der= >ous nested value constructor, write a constructor <BR>&gt; &g= >t; procedur=3D
> >e and<BR>&gt; &gt; &gt; call i= >t. As Antony suggested, you can make it accep=3D
> >t an open <= >BR>&gt; &gt; array formal,<BR>&gt; &gt; &gt; w= >hich then codes ju=3D
> >st like a simple array value constructor.= > You <BR>&gt; &gt; could even<BR>&=3D
> >g= >t; &gt; &gt; make it elaborate and general, e.g.:<BR>&gt;= > &gt; &gt;<BR>&gt=3D
> >; &gt; &gt; PROC= >EDURE MakeF ( Val : ARRAY OF FOO ) : F<BR>&gt; &gt; &gt;&= >lt;BR=3D
> >>&gt; &gt; &gt; =3D3D VAR LSize : CARDI= >NAL<BR>&gt; &gt; &gt; ; VAR LResult : =3D
> >A&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; ; BE= >GIN<BR>&gt; &gt; &gt; LSize :=3D3D =3D
> >NUMBER= > ( Val )<BR>&gt; &gt; &gt; &lt;* ASSERT LSize &lt= >;=3D3D NUMBER ( FooArr=3D
> >ay ) *&gt;<BR>&gt; &= >;gt; &gt; ; LResult . size :=3D3D LSize<BR>&gt; &gt; &= >;gt; =3D
> >; SUBARRAY ( LResult . a , 0 , LSize )<BR>&g= >t; &gt; &gt; :=3D3D SUBARRAY ( Va=3D
> >l , FIRST ( Val ) = >, LSize )<BR>&gt; &gt; &gt; ; RETURN LResult<BR>&am= >p;gt; &gt;=3D
> > &gt; END MakeF<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt; Alternatively, since yo=3DR>> >ur maximum element count is so small, you <BR>&gt; &am= >p;gt; could<BR>&gt; &gt; =3D
> >&gt; write a con= >structor procedure that took two formals of type FOO, <BR>&=3D>> >gt; &gt; with<BR>&gt; &gt; &gt; at least th= >e second one optional. (This wou=3D
> >ld require a <BR>&= >;gt; &gt; distinguished<BR>&gt; &gt; &gt; value of ty= >pe FO=3D
> >O that would be used to mean "omitted".)<BR>&= >;gt; &gt; &gt;<BR>&gt; &gt; &gt=3D
> >; = >And, of course, if you want to use abstraction, you can put the <BR>&= >amp;gt; =3D
> >&gt; types,<BR>&gt; &gt; &gt;= > constructor procedures, and various other pro=3D
> >cedures for &= >lt;BR>&gt; &gt; manipulating<BR>&gt; &gt; &gt;= > the variable sized=3D
> > array in a module, behind an interface.= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt=3D<= >BR>> >; An additional limitation of Modula-3 in this regard, is that = >you <BR>&gt;=3D
> > &gt; can't<BR>&gt; &am= >p;gt; &gt; make the type F opaque, unless you heap alloc=3D
> >= >;ate it, which we <BR>&gt; &gt; were trying<BR>&gt;= > &gt; &gt; to avoid. Ada =3D
> >would allow you to do this= >, but it's another <BR>&gt; &gt; example of<BR>&g= >=3D
> >t; &gt; &gt; a convenience with high cost. It force= >s the equivalent of the =3D
> ><BR>&gt; &gt; revelat= >ion<BR>&gt; &gt; &gt; to be located in the equivalent =3D= >
> >of the interface, but makes it <BR>&gt; &gt; ill= >egal<BR>&gt; &gt; &gt; to w=3D
> >rite client co= >de that depends on what the revelation is.<BR>&gt; &gt; &= >gt;<=3D
> >BR>&gt; &gt; &gt; This in turn create= >s a source code control nightmare in a=3D
> > large <BR>&= >;gt; &gt; project,<BR>&gt; &gt; &gt; because now some= >one who wan=3D
> >ts to make what is really a purely <BR>&am= >p;gt; &gt; internal,<BR>&gt; &gt; &gt=3D
> >= >; implementation change, nevertheless has to check out the <BR>&g= >t; &gt; in=3D
> >terface, and<BR>&gt; &gt; &= >gt; if you aren't in denial mode, that means imp=3D
> >lementers o= >f all the <BR>&gt; &gt; client<BR>&gt; &gt; &am= >p;gt; code have to go=3D
> > to extra trouble to somehow find out = >that what <BR>&gt; &gt; appears<BR>&g=3D
> &g= >t;t; &gt; &gt; to be an interface change actually doesn't affect th= >em after a=3D
> >ll.<BR>&gt; &gt; &gt;<BR>= >&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &am= >p;gt; Though =3D
> >that might seem nice.<BR>&gt; &g= >t; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Am I un= >=3D
> >derstanding everything?<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; Have =3D
> >= >;folks hit this before and there's a set of names that <BR>&gt; &= >amp;gt; don't s=3D
> >eem too lame<BR>&gt; &gt; &= >;gt; &gt; that folks use?<BR>&gt; &gt; &gt; &gt;&= >lt;=3D
> >BR>&gt; &gt; &gt; &gt; Also -- langua= >ge documentation?<BR>&gt; &gt; &gt; &g=3D
> >= >;t; Nelson's green book is excellent.<BR>&gt; &gt; &gt; &= >amp;gt; The stuff in th=3D
> >e doc directory is very dry and scie= >ntific.<BR>&gt; &gt; &gt; &gt; The tuto=3D
> &g= >t;rial seems more like a reference. Or maybe I didn't <BR>&gt; &a= >mp;gt; read it e=3D
> >nough.<BR>&gt; &gt; &gt; = >&gt; Is there better, in case I need a refresher?<=3D
> >BR= >>&gt; &gt; &gt; &gt; I think I got it, via Nelson's book= > from memory (won=3D
> >der if I <BR>&gt; &gt; can f= >ind mine..) and the reference,<BR>&gt; &gt; &gt=3D
>= >; >; &gt; but I don't think anyone could learn from the current onli= >ne <BR>&gt=3D
> >; &gt; docs in the source tree.<= >BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &g=3D
> >t; Maybe it's me, some combination of laziness and= > short attention <BR>&gt;=3D
> > &gt; span<BR>= >&gt; &gt; &gt; &gt; as I age..<BR>&gt; &gt; &= >amp;gt; &gt;<BR>&gt;=3D
> > &gt; &gt; &g= >t; Btw, C doesn't offer a great solution here, though it offer=3D
> &= >gt;s <BR>&gt; &gt; leaving out some type names.<BR>&= >;gt; &gt; &gt; &gt; In C++ =3D
> >I could have both .s= >ize and operator[].<BR>&gt; &gt; &gt; &gt; Modula-3 s= >ee=3D
> >ms to be missing operator overloading.<BR>&gt; = >&gt; &gt; &gt; It's got some=3D
> > builtin stuff, eve= >n array assignment and equality <BR>&gt; &gt; and I thin=3DR>> >k<BR>&gt; &gt; &gt; &gt; even record assig= >nment and equality, but it is sti=3D
> >ll a bit <BR>&gt= >; &gt; limiting.<BR>&gt; &gt; &gt;<BR>&gt; = >&gt; &gt;<BR>&gt=3D
> >; &gt; &gt; I hav= >e raved on this before, but, having had lots of painful <B=3D
> &g= >t;R>&gt; &gt; experience with<BR>&gt; &gt; &gt= >; user-defined overloading in A=3D
> >da and C++, I can say with &= >lt;BR>&gt; &gt; authority, that it is<BR>&gt; &gt;= >=3D
> > &gt; a programming language disaster. It interacts wit= >h just about <BR>&gt=3D
> >; &gt; everything<BR&g= >t;&gt; &gt; &gt; else in the language, in very complicat=3D
= >> >ed ways, and all it buys <BR>&gt; &gt; you is saving= ><BR>&gt; &gt; &gt; time=3D
> >/energy thinking u= >p distinct names for procedures/functions. <BR>&gt; &gt; =3D<= >BR>> >Even this,<BR>&gt; &gt; &gt; aside from the e= >ffects on the language, is a n=3D
> >et loss, by the <BR>&am= >p;gt; &gt; time you consider<BR>&gt; &gt; &gt; readab= >ili=3D
> >ty along with writability.<BR>&gt; &gt; &a= >mp;gt;<BR>&gt; &gt; &gt; User-defined=3D
> > ove= >rloaded operators provide a slight readability <BR>&gt; &gt; = >benefit, _=3D
> >if_<BR>&gt; &gt; &gt; used with= > great restraint and discipline, something y=3D
> >ou can rely <= >;BR>&gt; &gt; on not happening.<BR>&gt; &gt; &= >gt; Meanwhile, th=3D
> >e language complexity can easily double or= > worse. <BR>&gt; &gt; And, with t=3D
> >he<BR>= >&gt; &gt; &gt; exception of compiler writers and language lawye= >rs who=3D
> > spend <BR>&gt; &gt; hundreds of hours&= >lt;BR>&gt; &gt; &gt; on just this, prog=3D
> >ramme= >rs don't understand the rules, not even <BR>&gt; &gt; close.&= >lt;BR>&gt; &=3D
> >gt; &gt;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Also, if= > I understan=3D
> >d things correctly, this has long bothered <= >BR>&gt; &gt; me about Modula-3,=3D
> ><BR>&gt= >; &gt; &gt; &gt; though I'm more tolerant now -- Modula-3 doesn= >'t se=3D
> >em to allow <BR>&gt; &gt; for lighter wi= >eght<BR>&gt; &gt; &gt; &gt; objects=3D
> >. = >Like, small stack allocated structs with member <BR>&gt; &gt;= > functions. =3D
> >You seem to have<BR>&gt; &gt; &am= >p;gt; &gt; to chose between heap allocated gar=3D
> >bage coll= >ected virtual <BR>&gt; &gt; member functions full<BR>&a= >mp;gt; &gt; &gt=3D
> >; &gt; featured objects, or feat= >ureless dumb structs. It's nice how C+ <BR>=3D
> >&gt; &= >amp;gt; + allow hybrids --<BR>&gt; &gt; &gt; &gt; obj= >ects don't have to b=3D
> >e heap allocated and member functions &= >lt;BR>&gt; &gt; don't have be virtual.<=3D
> >BR>= >&gt; &gt; &gt; &gt; Or am I missing something?<BR>&am= >p;gt; &gt; &gt;<BR>&gt;=3D
> > &gt; &gt;= ><BR>&gt; &gt; &gt; C++'s supposedly lighter weight forms = >of class=3D
> >es/structs with <BR>&gt; &gt; their s= >pecial<BR>&gt; &gt; &gt; member functi=3D
> >ons= > buy nothing that plain records, plain <BR>&gt; &gt; procedur= >es, and<BR>=3D
> >&gt; &gt; &gt; interfaces/modu= >les don't already provide, again, at signific=3D
> >ant <BR>= >&gt; &gt; and gratuitous<BR>&gt; &gt; &gt; langua= >ge complexity. Exc=3D
> >ept when methods/member functions <BR&= >gt;&gt; &gt; actually dispatch<BR>&gt; &=3D
> &= >gt;gt; &gt; dynamically, there is nothing that the above won't do, and = >when <B=3D
> >R>&gt; &gt; you create a<BR>&= >;gt; &gt; &gt; class instance as a local variab=3D
> >le (= >i.e., on the stack), it is <BR>&gt; &gt; necessarily<BR>= >;&gt; &gt; &gt; =3D
> >not polymorphic, that is, it ca= >n't change its "allocated" or <BR>&gt; &gt; =3D
> >d= >ynamic type<BR>&gt; &gt; &gt; among various subtypes at r= >untime. This in t=3D
> >urn means it can't <BR>&gt; &= >;gt; dispatch.<BR>&gt; &gt; &gt;<BR>&gt; &g= >t; &=3D
> >gt; So, just use plain procedures, an interface and= > a module, and you <BR>&=3D
> >gt; &gt; will get<= >BR>&gt; &gt; &gt; everything a lighter-weight C++ class w=3D= >
> >ould give you.<BR>&gt; &gt; &gt;<BR>&a= >mp;gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt;<B= >=3D
> >R>&gt; &gt; &gt; &gt; Anyway, I've gotte= >n to accept C a bit more vs. C++ so=3D
> > I can <BR>&gt= >; &gt; deal with<BR>&gt; &gt; &gt; &gt; t: Type;&= >lt;BR>&gt; &gt;=3D
> > &gt; &gt; Type_DoSomethi= >ng(t);<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &g=3D
> >t; in place of:<BR>&gt; &g= >t; &gt; &gt; t.DoSomething();<BR>&gt; &gt; &gt;&l= >t;B=3D
> >R>&gt; &gt; &gt;<BR>&gt; &g= >t; &gt; Exactly. The special "receiver object" i=3D
> >n a tru= >e method call has <BR>&gt; &gt; significant<BR>&gt;= > &gt; &gt; semant=3D
> >ic differences from an ordinary pa= >rameter and introduces <BR>&gt; &gt; new =3D
> >comp= >lexities<BR>&gt; &gt; &gt; and non-orthogonalities. It ha= >s some very va=3D
> >luable uses too.<BR>&gt; &gt; &= >amp;gt;<BR>&gt; &gt; &gt; But to then create deg=3D
&g= >t; >enerate forms of it that still carry a lot <BR>&gt; &g= >t; of these<BR>&gt; &=3D
> >gt; &gt; complexitie= >s, but are equivalent in programing power to plain old<=3D
> >B= >R>&gt; &gt; &gt; parameters is just bad program design and b= >ad language de=3D
> sign. <BR>&gt; &gt; Objects and<= >BR>&gt; &gt; &gt; methods are indeed cool f=3D
> >o= >r situations that utilize their <BR>&gt; &gt; semantic comple= >xity.<BR>&gt;=3D
> > &gt; &gt; But it's deeply u= >ncool to try to look superficially cool by usin=3D
> >g an<BR&g= >t;&gt; &gt; &gt; inappropriately sophisticated construct when t= >he pro=3D
> >blem doesn't <BR>&gt; &gt; justify it.&= >lt;BR>&gt; &gt; &gt; Some OO proponents=3D
> > have= > gone way over the deep end here.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; =3D
> >&gt;<BR>&gt; &= >amp;gt; &gt; &gt; - Jay<BR>&gt; &gt; &gt; &gt= >;<BR>&gt; &gt; &gt; =3D
> >&gt;<BR>&am= >p;gt; &gt; &gt; &gt; <BR>&gt; &gt; --------------= >-------------------=3D
> >------------------------------------- &l= >t;BR>&gt; &gt; --<BR>&gt; &gt; &gt; &g=3D<= >BR>> >t; Boo! Scare away worms, viruses and so much more! Try Windows= > <BR>&gt; &g=3D
> >t; Live OneCare! Try now!<BR&g= >t;&gt; &gt; &gt; &lt;http://onecare.live.com/sta=3D
>= > >ndard/en-us/purchase/trial.aspx? <BR>&gt; &gt; s_cid=3D3= >Dwl_hotmailnews&gt;<B=3D
> >R>&gt; &gt; &gt;= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; --= ><BR>&gt; &gt; &gt; -=3D
> >---------------------= >---------------------------------------<BR>&gt; &gt; &=3D= >
> >gt; Rodney M. Bates, retired assistant professor<BR>&= >;gt; &gt; &gt; Dept. of=3D
> > Computer Science, Wichita S= >tate University<BR>&gt; &gt; &gt; Wichita, KS 6=3D
>= >; >7260-0083<BR>&gt; &gt; &gt; 316-978-3922<BR>&= >amp;gt; &gt; &gt; rodney.bates at wic=3D
> >hita.edu<BR>= >;&gt; &gt; &gt;<BR>&gt; &gt; &gt; --<BR>= >;&gt; &gt; &gt; ---------=3D
> >----------------------= >------------------------------<BR>&gt; &gt; &gt; Rodn=3D<= >BR>> >ey M. Bates, retired assistant professor<BR>&gt; &= >;gt; &gt; Dept. of Compute=3D
> >r Science, Wichita State Univ= >ersity<BR>&gt; &gt; &gt; Wichita, KS 67260-008=3D
>= > >3<BR>&gt; &gt; &gt; 316-978-3922<BR>&gt; &= >amp;gt; &gt; rodney.bates at wichita.edu=3D
> ><BR>&gt;= > &gt;<BR>&gt; &gt;<BR>&gt; &gt; Boo! Scare = >away worms, viruses and =3D
> >so much more! Try Windows Live <= >BR>&gt; &gt; OneCare! Try now!<BR>&gt; <BR>=3DR>> ><BR><br /><hr />Climb to the top of the charts= >!=3DA0 Play Star Shuffle:=3DA0 th=3D
> >e word scramble challenge = >with star power. <a href=3D3D'http://club.live.com/=3D
> >star_= >shuffle.aspx?icid=3D3Dstarshuffle_wlmailtextlink_oct' target=3D3D'_new'>= >Pl=3D
> >ay Now!</a></body>
> ></html>= >=3D
> >
> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_--
= >


Help yourself to FREE treats served up daily at the Messeng= >er Caf=E9. ml?ocid=3DTXT_TAGLM_OctWLtagline' target=3D'_new'>Stop by today! >= > >--_85b6c041-9539-4614-b541-8813489e58bb_-- From jay.krell at cornell.edu Sat Nov 17 09:35:10 2007 From: jay.krell at cornell.edu (Jay) Date: Sat, 17 Nov 2007 08:35:10 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: I forgot to point out something I half agree with -- overloading...We have a plain text index over a very large code base. Look for "Close", and hypothetically, I'm making up names here, you find File::Close, Window::Close, Session::Close -- not too bad for the implementations, if you can look for "File::Close", but if you want to find the callers, f.Close, w.Close, s.Close, etc... A "problem" with C++ is that the compiler implements it very well, and nothing else comes close. Good luck evaluating expressions in a debugger, search, "refactoring editors", "wizards" that can change code, etc. It's neat that Modula-3 is simple enough that the remoting feature can be a separate parser over the one language, instead of having a seperate interface language.. But still it is super tempting to have function names qualified by at least the static types of their first parameter or all parameters, if not the dynamic types. Qualification by the dynamic type of the first parameter is if course super common, super popular, even supported in Modula-3.. and maybe in C via function pointers..though at least in C it is obvious when such "switching" is being used (except, even then, it is often hidden by an upper layer -- like, I call ReadFile/WriteFile and then way down under the covers there are drivers to switch between FAT, NTFS, SMB, etc.) As to looseness and "duck typing", well, I see both sides here really.. And I am well aware of how buggy code is.. - Jay > Date: Fri, 16 Nov 2007 22:24:15 +0100> From: lemming at henning-thielemann.de> To: rodney.bates at wichita.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > > On Fri, 16 Nov 2007, Rodney M. Bates wrote:> > > If you don't want to have to write the module name as a qualifier, you can> > rename a procedure too, with a constant declaration (Procedures in Modula-3> > are actually the same thing a constants of procedure type.)> >> > CONST DoSomething = M.DoSomething> > ...> > DoSomething ( v )> > It would have been nice if PROCEDURE declarations would reflect this, like> in functional languages. Say> > CONST> Sin => PROCEDURE (x: LONGREAL;): LONGREAL> BEGIN> ...> RETURN y;> END;> > This would also be the key for anonymous functions or loops as higher> order functions. Just an idea, it's certainly simpler just to use a> functional language. :-) _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Nov 19 13:36:00 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 19 Nov 2007 04:36:00 -0800 Subject: [M3devel] write access to CM3 repository? Message-ID: <200711191236.lAJCa0YE051000@camembert.async.caltech.edu> Hello, Not sure who to write to these days... but it seems I lost my write access to the source repository? I just made the little "sharedboard" demo work on my machine and thought it'd be nice if it were committed. Mika From hosking at cs.purdue.edu Wed Nov 21 21:22:55 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Wed, 21 Nov 2007 15:22:55 -0500 Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <817267.35735.qm@web27105.mail.ukl.yahoo.com> References: <817267.35735.qm@web27105.mail.ukl.yahoo.com> Message-ID: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Have you tried this lately? It seems to work fine for me on Fedora Core. On Oct 30, 2007, at 12:48 PM, Daniel Alejandro Benavides D. wrote: > Hi: > LINUXLIBC6 32 bits, ubuntu dapper > > >Hmm. showheap works fine for me on my I386_DARWIN box. What > >platform are you on? > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro Benavides D. wrote: > > > Hi: > > About this last changes, the runtime can not properly > > feed shownew, with a @M3shownew=shownew. > > The program 'a' is just not started as it seems here, > > altough the window (shownew) does appear, start > > doesn't respond, and it stays there until aborted. > > > > Thanks > > > > --- "Daniel Alejandro Benavides D." > > escribi?: > > > >> Hi: > >> Yes it's working very well. I'm sorry for the delay. > >> Thanks. > >> --- Tony Hosking escribi?: > >> > >>> Please try the latest CVS head. > >>> > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > >>> Benavides D. wrote: > >>> > >>>> Hi: > >>>> Im trying to execute the following program with > >>> the Pthread cvs > >>>> head implementation and I got this when > >> executing > >>> the program: > >>>> > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>> LINUXLIBC6/Main > >>>> Entre dos enteros6 7 > >>>> Estadisticas del Heap > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > >>>> > >>>> > >>>> *** > >>>> *** runtime error: > >>>> *** <*ASSERT*> failed. > >>>> *** file > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line 992 > >>>> *** > >>>> > >>>> Aborted > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>>> > >>>> The assert violated in > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is this: > >>>> PROCEDURE ProcessOther (act: Activation; p: > >>> PROCEDURE (start, > >>>> stop: ADDRESS)) = > >>>> (* LL=activeMu *) > >>>> VAR > >>>> sp: ADDRESS; > >>>> state: RTMachine.ThreadState; > >>>> BEGIN > >>>> <*ASSERT act.state = ActState.Stopped*> > >>>> > >>>> > >>>> The source code of the little program is this: > >>>> > >>>> MODULE Main; > >>>> > >>>> IMPORT SIO; > >>>> IMPORT RTHeapStats; > >>>> IMPORT RTutils; > >>>> IMPORT RTHeapDebug; > >>>> VAR > >>>> varA, varB, varC: INTEGER; > >>>> > >>>> > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > >>>> VAR > >>>> varC: INTEGER; > >>>> BEGIN > >>>> varC:=a*b; > >>>> RETURN varC; > >>>> END multiplicar; > >>>> > >>>> > >>>> BEGIN > >>>> > >>>> SIO.PutText("Entre dos enteros"); > >>>> varA:=SIO.GetInt(); > >>>> varB:=SIO.GetInt(); > >>>> varC:=multiplicar(varA,varB); > >>>> SIO.PutText("Estadisticas del Heap"); > >>>> RTHeapDebug.CheckHeap(); > >>>> RTHeapStats.ReportReachable(); > >>>> (* RTutils.Heap > >>>> > >>> > >> > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > >>>> SIO.PutInt(varC); > >>>> > >>>> END Main. > >>>> > >>>> According to the draft book of Michael Dagenais > >>> Building > >>>> Distributed OO Applications: Modula-3 Objects > >> at > >>> Work, > >>>> RTHeapStats.ReportReachable() > >>>> " ... is called to determine the number > >>>> of active, reachable, objects (i.e. those which > >>> would not be > >>>> garbage collected). Of the 1980 objects on the > >>> heap, only slightly > >>>> more than half are still alive." > >>>> > >>>> According to the interface documentation: > >>>> "reports the number of reachable objects and > >>> bytes from each > >>>> compilation unit, thread stack, and the > >> individual > >>> roots that reach > >>>> the most bytes. The report is written to stderr. > >>> The Modula-3 > >>>> process is frozen during the scanning and > >>> reporting." > >>>> > >>>> Obviously with the previous version of pthread > >> the > >>> things were > >>>> working fine, also with user level > >> implementation > >>>> > >>>> Thanks, > >>>> > >>>> Daniel Benavides > > > ?Descubre una nueva forma de obtener respuestas a tus preguntas! > Entra en Yahoo! Respuestas. From dabenavidesd at yahoo.es Thu Nov 22 20:56:04 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 22 Nov 2007 20:56:04 +0100 (CET) Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Message-ID: <645186.51518.qm@web27114.mail.ukl.yahoo.com> Hi: Yes, it is working; shownew and also the test program. Thanks. --- Tony Hosking wrote: > Have you tried this lately? It seems to work fine > for me on Fedora > Core. > > On Oct 30, 2007, at 12:48 PM, Daniel Alejandro > Benavides D. wrote: > > > Hi: > > LINUXLIBC6 32 bits, ubuntu dapper > > > > >Hmm. showheap works fine for me on my I386_DARWIN > box. What > > >platform are you on? > > > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro > Benavides D. wrote: > > > > > Hi: > > > About this last changes, the runtime can not > properly > > > feed shownew, with a @M3shownew=shownew. > > > The program 'a' is just not started as it seems > here, > > > altough the window (shownew) does appear, start > > > doesn't respond, and it stays there until > aborted. > > > > > > Thanks > > > > > > --- "Daniel Alejandro Benavides D." > > > escribi?: > > > > > >> Hi: > > >> Yes it's working very well. I'm sorry for the > delay. > > >> Thanks. > > >> --- Tony Hosking escribi?: > > >> > > >>> Please try the latest CVS head. > > >>> > > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > > >>> Benavides D. wrote: > > >>> > > >>>> Hi: > > >>>> Im trying to execute the following program > with > > >>> the Pthread cvs > > >>>> head implementation and I got this when > > >> executing > > >>> the program: > > >>>> > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>> LINUXLIBC6/Main > > >>>> Entre dos enteros6 7 > > >>>> Estadisticas del Heap > > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > > >>>> > > >>>> > > >>>> *** > > >>>> *** runtime error: > > >>>> *** <*ASSERT*> failed. > > >>>> *** file > > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line > 992 > > >>>> *** > > >>>> > > >>>> Aborted > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>>> > > >>>> The assert violated in > > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is > this: > > >>>> PROCEDURE ProcessOther (act: Activation; p: > > >>> PROCEDURE (start, > > >>>> stop: ADDRESS)) = > > >>>> (* LL=activeMu *) > > >>>> VAR > > >>>> sp: ADDRESS; > > >>>> state: RTMachine.ThreadState; > > >>>> BEGIN > > >>>> <*ASSERT act.state = ActState.Stopped*> > > >>>> > > >>>> > > >>>> The source code of the little program is > this: > > >>>> > > >>>> MODULE Main; > > >>>> > > >>>> IMPORT SIO; > > >>>> IMPORT RTHeapStats; > > >>>> IMPORT RTutils; > > >>>> IMPORT RTHeapDebug; > > >>>> VAR > > >>>> varA, varB, varC: INTEGER; > > >>>> > > >>>> > > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > > >>>> VAR > > >>>> varC: INTEGER; > > >>>> BEGIN > > >>>> varC:=a*b; > > >>>> RETURN varC; > > >>>> END multiplicar; > > >>>> > > >>>> > > >>>> BEGIN > > >>>> > > >>>> SIO.PutText("Entre dos enteros"); > > >>>> varA:=SIO.GetInt(); > > >>>> varB:=SIO.GetInt(); > > >>>> varC:=multiplicar(varA,varB); > > >>>> SIO.PutText("Estadisticas del Heap"); > > >>>> RTHeapDebug.CheckHeap(); > > >>>> RTHeapStats.ReportReachable(); > > >>>> (* RTutils.Heap > > >>>> > > >>> > > >> > > > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > > >>>> SIO.PutInt(varC); > > >>>> > > >>>> END Main. > > >>>> > > >>>> According to the draft book of Michael > Dagenais > > >>> Building > > >>>> Distributed OO Applications: Modula-3 Objects > > >> at > > >>> Work, > > >>>> RTHeapStats.ReportReachable() > > >>>> " ... is called to determine the number > > >>>> of active, reachable, objects (i.e. those > which > > >>> would not be > > >>>> garbage collected). Of the 1980 objects on > the > > >>> heap, only slightly > > >>>> more than half are still alive." > > >>>> > > >>>> According to the interface documentation: > > >>>> "reports the number of reachable objects and > > >>> bytes from each > > >>>> compilation unit, thread stack, and the > > >> individual > > >>> roots that reach > > >>>> the most bytes. The report is written to > stderr. > > >>> The Modula-3 > > >>>> process is frozen during the scanning and > > >>> reporting." > > >>>> > > >>>> Obviously with the previous version of > pthread > > >> the > > >>> things were > > >>>> working fine, also with user level > > >> implementation > > >>>> > > >>>> Thanks, > > >>>> > > >>>> Daniel Benavides > > > > > > ?Descubre una nueva forma de obtener respuestas a > tus preguntas! > > Entra en Yahoo! Respuestas. > > ______________________________________________ ?Chef por primera vez? S? un mejor Cocinillas. http://es.answers.yahoo.com/info/welcome From lemming at henning-thielemann.de Thu Nov 29 08:08:03 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 08:08:03 +0100 (MET) Subject: [M3devel] Disabling runtime checks Message-ID: I remember that it was already discussed. I found this one: http://groups.google.de/group/comp.lang.modula3/browse_thread/thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check but it seems to be out of date. So once again: How can I disable checks on overflow, array bound violation, NIL pointer etc. in cm3 for the sake of speed? I hoped that '-A' (disable code generation for assertions) would do it, since these checks are like built-in ASSERTs, but I was wrong. From lemming at henning-thielemann.de Thu Nov 29 10:14:21 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 10:14:21 +0100 (MET) Subject: [M3devel] Disabling runtime checks In-Reply-To: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: On Thu, 29 Nov 2007, Mika Nystrom wrote: > For PM3/m3build you can check > > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet! cm3 supports m3_option quake command, but it accepts only the command line options. > Counter-question: does anyone have CM3 working well on Windows? I > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on > Windows 2k/Cygwin. By "well" I mean that everything (including > Network Objects) has to work... I don't know about all the M3 libraries but I could get my stuff to work, including three foreign libraries. http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip From jay.krell at cornell.edu Thu Nov 29 10:23:31 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 09:23:31 +0000 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: I also don't know about all the M3 libraries either, but it can build itself, repeatedly. I know I can start some of the netobj stuff but I don't have a "real" test case. I have the following built from source, should be "easy" for anyone to do so: C:\cm3\bin>dir /b *.exe *.dll /wCalculator.execm3-d5.5.0.execm3.execmpdir.exeCube.exeDeckScape.exedirfp.exefisheye.exefix_nl.exeformsedit.exeJuno.exem3browser.exem3bundle.exem3tohtml.exem3totex.exem3zume.exementor.exemklib.exenetobjd.exeobliq-anim.exeobliq-min.exeobliq-std.exeobliq-ui.exeobliqsrv-std.exeobliqsrv-ui.exeRehearseCode.exereplayheap.exeshobjcodegen.exeshowheap.exeshownew.exeshowthread.exestablegen.exestubgen.exevisobliq.exevocgi.exevoquery.exevorun.exeWebScape.exeanim3D.dllbinIO.dllBitVector.dllcmvbt.dlldb.dlldebug.dlldeepcopy.dllDiGraph.dllembutils.dllevents.dllGeometry.dllhttp.dlljuno-compiler.dlljuno-machine.dlljvideo.dlllibbuf.dlllibsio.dlllistfuncs.dllm3.dllm3codeview.dllm3core.dllm3formsvbt.dllm3formsvbtpixmaps.dllm3markup.dllm3mg.dllm3mgkit.dllm3netobj.dllm3parseparams.dllm3scan.dllm3slisp.dllm3smalldb.dllm3tcl.dllm3tcp.dllm3tk-misc.dllm3tk.dllm3ui.dllm3vbtkit.dllm3zeus.dllmetasyn.dllobliq.dllobliqlibanim.dllobliqlibemb.dllobliqlibm3.dllobliqlibui.dllobliqparse.dllobliqprint.dllobliqrt.dllodbc.dllopengl.dllpatternmatching.dllrdwr.dllserialio.dllset.dllsgml.dllsharedobj.dllSortedTableExtras.dllstable.dllsynex.dllsynwr.dlltable-list.dllTempFiles.dllUDP.dllvideovbt.dllweb.dllwebvbt.dll Bolded what /think/ is relevant. I'm /still/ looking into the int64 stuff... - Jay > Date: Thu, 29 Nov 2007 10:14:21 +0100> From: lemming at henning-thielemann.de> To: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] Disabling runtime checks> > > On Thu, 29 Nov 2007, Mika Nystrom wrote:> > > For PM3/m3build you can check> >> > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html> >> > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet!> > cm3 supports m3_option quake command, but it accepts only the command line> options.> > > Counter-question: does anyone have CM3 working well on Windows? I> > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on> > Windows 2k/Cygwin. By "well" I mean that everything (including> > Network Objects) has to work...> > I don't know about all the M3 libraries but I could get my stuff to work,> including three foreign libraries.> > http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 12:15:34 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 11:15:34 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: please confirm my understanding I don't feel great being a lone reader/changer of code esp. that I didn't write and that lacks sufficient documentation for my small brain/confidence. (I'm not stupid, but this isn't trivial stuff either.) I am bound to make mistakes. In the context of Modula-3 code gen interfaces, and the word interfaces, which apparently are identical/analogous/whatever: There is: Shift (aka, my bad naming, "generic" shift)LeftShiftRightShift LeftShift and RightShift allow only positive shift counts, 0 .. 31 or 0 .. 63 (given particular word sizes and depending on types..) The "front end" checks constants against these.The "front end" inserts checks for variables against these.The back end can assume 0 .. 31 or 0 .. 63. It looks like the x86 back end does redundant masks against 31, at least when shifting by a constant, only in its own data, not in the codegen. Just a small waste of time in the compiler, no negative affect on codegen. "generic" Shift accepts any number for a shift count.Negative numbers mean a right shift.Positive numbers mean a left shift.If the shift count is >31|63 or <-31|63, the result is not an error, but zero. In all cases, right shifts are unsigned, zero filling. There is no shift operation that propagates the sign bit.In the Modula-3 language even. Perhaps, yes, integer division. But the frontend does not optimizethere and turn multiplication or division into shifts, I think, haven't read much of the frontend. The backend could. Rotate is presumably similar, but I have not looked at it.(LeftRotate, RightRotate, Rotate...) m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, very redundanty code, could be combined. The layering is /roughly/ m3x86 on top stackx86 in the middle codex86 at the bottom However m3x86 does call through to codex86 directly.They are largely one layer. There is no strict division."stack" is a simple way to implement some optimizations and stategiesaround constant propagation and register allocation. It is a stack of "operands", which may be constants, globals, or locals.If something is needed in a register, a register will be freed up.If something is later needed and the register hasn't been spilled, it will be reused. If not, not. Presently the operands are assumed to be of word size, 32 bits, register size.That is largely a convenience, and very convenient.I will expand it to allow two word operands.It could be expanded to arbitrarily, at least to "fill" "all" the registers, for some not particularly interesting but theoretically useful scenarios -- passing "medium" sized structs around by value or such. There are ABI concerns though, this could only be amongst local functions that aren't visible/used externally (aka "custom calling conventions"). The "generic" shift (vs. left_shift, right_shift) is implemented in stackx86while left_shift, right_shift are in m3x86. All three functions are very similar,could be combined, and there is no good reason for some to be in one layervs. the other and it's a just a pointless inconsistency. Granted, "generic" shift is a good bit different, it has to check the sign and the magnitude,whereas left and right can just blindly do the operation with no comparisons or branches. Some of this I gather from attempting to compile code with shifts -- esp. the frontend checking of stuff, which then lead me to look at word.i3which declares subranges for the parameters. Is Bill Kalsow around?Or the other original authors?Everyone just figured stuff out from the code, comments, and "literature" (I ordered another copy of Nelson's good book. :) ) - Jay _________________________________________________________________ Connect and share in new ways with Windows Live. http://www.windowslive.com/connect.html?ocid=TXT_TAGLM_Wave2_newways_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 13:41:12 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 12:41:12 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: At one point Linux/x86 didn't use gcc, right? It used the same as the Win32/x86 backend? Anyway, on Win32/x86, small functions like: PROCEDURE F5(b : INTEGER) : INTEGER =BEGIN RETURN Word.Shift(0, b);END F5; result in: _T__F5: 004010C2: 55 push ebp 004010C3: 8B EC mov ebp,esp 004010C5: 81 EC 04 00 00 00 sub esp,4 004010CB: 53 push ebx 004010CC: 56 push esi 004010CD: 57 push edi 004010CE: 33 C0 xor eax,eax 004010D0: 5F pop edi 004010D1: 5E pop esi 004010D2: 5B pop ebx 004010D3: C9 leave 004010D4: C3 ret Now, I can grant that having a consistent frame is nice for stack walkability in a debugger in the absence of symbols, so I won't argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure leave is the state of the art, need to compare to current compiler output). But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. Doesn't it? Looking at the code, and how it avoids having multiple passes, it should be easy to at least track which registers are used, and go back and nop out the pushes, and avoid the pops entirely. Or possibly to move the function ahead up to three bytes, leaving three bytes of padding -- being sure to test recursive code..except anything with a function call, maybe leave alone. I ASSUME nop is faster than push, esp. when combined with saving the pops entirely, ESP. when there are presumably two and three byte nops, so the instruction count can be dropped, even if the byte count cannot easily. Thoughts? Nobody cares 'cause everyone else is using gcc and it handles these things well? - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Nov 29 16:47:40 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:47:40 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <7670DE57-26E8-4A2B-9169-1B77E80C610A@cs.purdue.edu> m3_option("-NoChecks") should do it. For assertions use m3_option("-NoAsserts"). On Nov 29, 2007, at 2:08 AM, Henning Thielemann wrote: > > I remember that it was already discussed. I found this one: > http://groups.google.de/group/comp.lang.modula3/browse_thread/ > thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check > but it seems to be out of date. So once again: How can I disable > checks > on overflow, array bound violation, NIL pointer etc. in cm3 for the > sake > of speed? I hoped that '-A' (disable code generation for assertions) > would do it, since these checks are like built-in ASSERTs, but I was > wrong. From hosking at cs.purdue.edu Thu Nov 29 16:59:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:59:26 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 6:15 AM, Jay wrote: > please confirm my understanding > > I don't feel great being a lone reader/changer of code esp. that I > didn't write and that lacks > sufficient documentation for my small brain/confidence. (I'm not > stupid, but this isn't trivial stuff either.) If you are talking about the native x86 (non-gcc) backend then I concur that it is pretty unreadable. Hence my lack of enthusiasm in working on it myself. > I am bound to make mistakes. We all do! > In the context of Modula-3 code gen interfaces, and the word > interfaces, which apparently are identical/analogous/whatever: > > There is: > > Shift (aka, my bad naming, "generic" shift) Yes, shift by n>0 is shift left. n<0 is shift right. > LeftShift > RightShift > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > or 0 .. 63 (given > particular word sizes and depending on types..) > The "front end" checks constants against these. > The "front end" inserts checks for variables against these. > The back end can assume 0 .. 31 or 0 .. 63. Yes, depending on word-size. > It looks like the x86 back end does redundant masks against 31, at > least when shifting by a constant, > only in its own data, not in the codegen. Just a small waste of > time in the compiler, no negative affect on codegen. > > "generic" Shift accepts any number for a shift count. > Negative numbers mean a right shift. > Positive numbers mean a left shift. > If the shift count is >31|63 or <-31|63, the result is not an > error, but zero. Yes. > In all cases, right shifts are unsigned, zero filling. Yes. > There is no shift operation that propagates the sign bit. > In the Modula-3 language even. Perhaps, yes, integer division. But > the frontend does not optimize > there and turn multiplication or division into shifts, I think, > haven't read much of the frontend. The backend could. Correct. I think the thinking was that a decent back-end would turn integer division by a power of 2 into an arithmetic right shift (the gcc backend certainly does). > Rotate is presumably similar, but I have not looked at it. > (LeftRotate, RightRotate, Rotate...) Weird thing with these is the way the high/low bits are rotated around, so sign can change! > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > very redundanty code, could be combined. > > The layering is /roughly/ > m3x86 on top > stackx86 in the middle > codex86 at the bottom > > However m3x86 does call through to codex86 directly. > They are largely one layer. There is no strict division. > "stack" is a simple way to implement some optimizations and stategies > around constant propagation and register allocation. > > It is a stack of "operands", which may be constants, globals, or > locals. > If something is needed in a register, a register will be freed up. > If something is later needed and the register hasn't been spilled, > it will be > reused. If not, not. > > Presently the operands are assumed to be of word size, 32 bits, > register size. > That is largely a convenience, and very convenient. > I will expand it to allow two word operands. > It could be expanded to arbitrarily, at least to "fill" "all" the > registers, for some > not particularly interesting but theoretically useful scenarios -- > passing "medium" > sized structs around by value or such. There are ABI concerns > though, this could > only be amongst local functions that aren't visible/used > externally (aka "custom calling conventions"). You can make some assumptions about how the front-end uses the middle- end interfaces. For example, it only ever stacks integer things as 32 or 64 bits, even if the integers have a memory representation that is 8 bits, etc. > The "generic" shift (vs. left_shift, right_shift) is implemented in > stackx86 > while left_shift, right_shift are in m3x86. All three functions are > very similar, > could be combined, and there is no good reason for some to be in > one layer > vs. the other and it's a just a pointless inconsistency. > > Granted, "generic" shift is a good bit different, it has to check > the sign and the magnitude, > whereas left and right can just blindly do the operation with no > comparisons or branches. > > Some of this I gather from attempting to compile code with shifts > -- esp. the frontend checking of stuff, which then lead me to look > at word.i3 > which declares subranges for the parameters. > > Is Bill Kalsow around? Good question. Farshad Nayeri may know where he ended up. > Or the other original authors? I know Michel Dagenais had a student who adapted the native x86 backend for use on Linux with PM3. I don't remember the student's name. > Everyone just figured stuff out from the code, comments, and > "literature" (I ordered another copy of Nelson's good book. :) ) > > > - Jay > > > Connect and share in new ways with Windows Live. Connect now! From hosking at cs.purdue.edu Thu Nov 29 17:02:42 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 11:02:42 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> On Nov 29, 2007, at 7:41 AM, Jay wrote: > At one point Linux/x86 didn't use gcc, right? It used the same as > the Win32/x86 backend? > > Anyway, on Win32/x86, small functions like: > > PROCEDURE F5(b : INTEGER) : INTEGER = > BEGIN > RETURN Word.Shift(0, b); > END F5; > > result in: > > _T__F5: > 004010C2: 55 push ebp > 004010C3: 8B EC mov ebp,esp > 004010C5: 81 EC 04 00 00 00 sub esp,4 > 004010CB: 53 push ebx > 004010CC: 56 push esi > 004010CD: 57 push edi > 004010CE: 33 C0 xor eax,eax > 004010D0: 5F pop edi > 004010D1: 5E pop esi > 004010D2: 5B pop ebx > 004010D3: C9 leave > 004010D4: C3 ret > > Now, I can grant that having a consistent frame is nice for stack > walkability in a debugger in the absence of symbols, so I won't > argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure > leave is the state of the art, need to compare to current compiler > output). > > But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. > Doesn't it? > > Looking at the code, and how it avoids having multiple passes, it > should be easy to at least track which registers are used, and go > back and nop out the pushes, and avoid the pops entirely. > > Or possibly to move the function ahead up to three bytes, leaving > three bytes of padding -- being sure to test recursive code..except > anything with a function call, maybe leave alone. I ASSUME nop is > faster than push, esp. when combined with saving the pops entirely, > ESP. when there are presumably two and three byte nops, so the > instruction count can be dropped, even if the byte count cannot > easily. > > Thoughts? Sounds reasonable. Having glanced at the native x86 backend I believe it really needs a good shake-out to bring it up to speed. > Nobody cares 'cause everyone else is using gcc and it handles these > things well? I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. > > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! :-) From rcolebur at scires.com Thu Nov 29 19:30:46 2007 From: rcolebur at scires.com (Randy Coleburn) Date: Thu, 29 Nov 2007 13:30:46 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> Message-ID: <474EBF06.1E75.00D7.1@scires.com> I am willing to help test stuff on the Windows platform, but I won't be much help with low-level stuff like what Jay is doing now. I have a working cm3 v4.1 on Windows. I tried a few weeks ago to get the "current" cm3 working on Windows, but ran into trouble. I say "current" in quotes, because I was downloading the tarballs. I presume there is more recent stuff avail via CVS. Can someone let me know how to check out the latest "stable" sources from CVS? I'll give it another try if someone can point me to the right code. If stuff breaks, I can provide feedback. Also, if I can get the new cm3 working on Windows, I should be able to complete the work on getting the CM3IDE (aka Reactor) ready for release. Regards, Randy Randy C. Coleburn, CISSP Senior Systems Engineer, Communications, Networks, & Electronics Division (CNE) Corporate & Atlanta Information Systems Security Manager (ISSM) Scientific Research Corporation 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) 989-9497 Quality Policy: "SRC CNE Division is committed to delivering continually improving research & engineering excellence that meets or exceeds customer requirements." >>> Tony Hosking 11/29/2007 11:02 AM >>> > At one point Linux/x86 didn't use gcc, right? It used the same as I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 4492 bytes Desc: S/MIME Cryptographic Signature URL: From hosking at cs.purdue.edu Thu Nov 29 21:11:59 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 15:11:59 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <474EBF06.1E75.00D7.1@scires.com> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> Message-ID: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote: > I am willing to help test stuff on the Windows platform, but I > won't be much help with low-level stuff like what Jay is doing now. > > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > get the "current" cm3 working on Windows, but ran into trouble. I > say "current" in quotes, because I was downloading the tarballs. I > presume there is more recent stuff avail via CVS. > > Can someone let me know how to check out the latest "stable" > sources from CVS? I'll give it another try if someone can point me > to the right code. If stuff breaks, I can provide feedback. Jay is probably your best resource on this. > Also, if I can get the new cm3 working on Windows, I should be > able to complete the work on getting the CM3IDE (aka Reactor) ready > for release. That would be very cool! > > Regards, > Randy > > Randy C. Coleburn, CISSP > Senior Systems Engineer, Communications, Networks, & Electronics > Division (CNE) > Corporate & Atlanta Information Systems Security Manager (ISSM) > Scientific Research Corporation > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > 989-9497 > > Quality Policy: "SRC CNE Division is committed to delivering > continually improving research & engineering excellence that meets > or exceeds customer requirements." > > >>> Tony Hosking 11/29/2007 11:02 AM >>> > > At one point Linux/x86 didn't use gcc, right? It used the same as > I haven't tried the CygWin (gcc-backend) based build of CM3 for > Windows, but clearly we need a good story for Windows-based CM3. Jay > you have done a great job keeping this branch of the system alive. I > certainly hope you can keep it up. Not being a Windows user myself, > I do lack the incentive (and expertise) to keep things going for > Windows. That's why we need people like you to help out. > From lemming at henning-thielemann.de Thu Nov 29 21:43:49 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 21:43:49 +0100 (CET) Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: On Thu, 29 Nov 2007, Tony Hosking wrote: > m3_option("-NoChecks") should do it. Is this documented somewhere? > For assertions use m3_option("-NoAsserts"). $ cm3 -O -A -keep unsupported m3_option value: "-NoChecks" Sorry, it's not the newest version: $ cm3 -version Critical Mass Modula-3 version 5.2.6 last updated: 2003-06-27 configuration: /usr/local/cm3/bin/cm3.cfg From hosking at cs.purdue.edu Thu Nov 29 22:06:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 16:06:26 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: Hmmm... On Nov 29, 2007, at 3:43 PM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? > >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" > > > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg From wagner at elegosoft.com Thu Nov 29 23:08:58 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Thu, 29 Nov 2007 23:08:58 +0100 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Quoting Henning Thielemann : > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? Actually yes, it is: http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html But I'm afraid that the documentation hasn't been updated for CM3 5.x in this respect, as Critical Mass never release it and Michael and I simply had not the resources to check every detail. So it will be out of date :-( >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" That's what I meant ;-/ > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg Later does not necessary mean better documented. A quick grep through the code does produce this though: .../cm3/m3-sys/m3front/src/misc/Host.m3 ELSIF (Text.Equal (t, "-NoChecks")) THEN doAsserts := FALSE; doNarrowChk := FALSE; doRangeChk := FALSE; doReturnChk := FALSE; doCaseChk := FALSE; doTCaseChk := FALSE; doNilChk := FALSE; doRaisesChk := FALSE; doDebugs := FALSE; So actually it seems like it should work; perhaps only the m3_option embedding is broken. ... It seems to be set from M3_OPTIONS in cm3.cfg: s.m3_options := GetConfigArray (s, "M3_OPTIONS"); So I'd try to set it there. Perhaps cm3 -D'M3_OPTIONS=[ "NoChecks" ]" will work, too. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From hosking at cs.purdue.edu Fri Nov 30 00:19:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 18:19:05 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <9DDF7EB7-803E-4781-8139-06BFCD2D4F78@cs.purdue.edu> On Nov 29, 2007, at 5:08 PM, Olaf Wagner wrote: > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" Ah, yes, that seems to be the trick. I think you can do: cm3 -DM3_OPTIONS="-NoChecks" as well. > > will work, too. > > Olaf > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > From jay.krell at cornell.edu Fri Nov 30 02:22:09 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:22:09 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: I haven't tried this in a few weeks, but the following should work. This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever. It is not particularly current, but it should work, by design and by my latest testing. (Until such time as a newer distribution is available, I assume a need to bootstrap from this, but perhaps not anything older). Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:28:12 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:28:12 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: Thanks! It helps to know I'm understanding things correctly. The backend isn't bad really, it's written by someone who very much knew what they were doing, which is necessary. > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that Understood. Actually, btw, the front/middleend could do more easy optimizations, like some of the ones I already commited, and really, all the constant propagation that m3x86.m3 does, via its stack stuff and remembering if something is "immediate". I should look into that some time....... - Jay > From: hosking at cs.purdue.edu> Date: Thu, 29 Nov 2007 10:59:26 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] "please confirm my understanding"> > > On Nov 29, 2007, at 6:15 AM, Jay wrote:> > > please confirm my understanding> >> > I don't feel great being a lone reader/changer of code esp. that I > > didn't write and that lacks> > sufficient documentation for my small brain/confidence. (I'm not > > stupid, but this isn't trivial stuff either.)> > If you are talking about the native x86 (non-gcc) backend then I > concur that it is pretty unreadable. Hence my lack of enthusiasm in > working on it myself.> > > I am bound to make mistakes.> > We all do!> > > In the context of Modula-3 code gen interfaces, and the word > > interfaces, which apparently are identical/analogous/whatever:> >> > There is:> >> > Shift (aka, my bad naming, "generic" shift)> > Yes, shift by n>0 is shift left. n<0 is shift right.> > > LeftShift> > RightShift> >> > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > or 0 .. 63 (given> > particular word sizes and depending on types..)> > The "front end" checks constants against these.> > The "front end" inserts checks for variables against these.> > The back end can assume 0 .. 31 or 0 .. 63.> > Yes, depending on word-size.> > > It looks like the x86 back end does redundant masks against 31, at > > least when shifting by a constant,> > only in its own data, not in the codegen. Just a small waste of > > time in the compiler, no negative affect on codegen.> >> > "generic" Shift accepts any number for a shift count.> > Negative numbers mean a right shift.> > Positive numbers mean a left shift.> > If the shift count is >31|63 or <-31|63, the result is not an > > error, but zero.> > Yes.> > > In all cases, right shifts are unsigned, zero filling.> > Yes.> > > There is no shift operation that propagates the sign bit.> > In the Modula-3 language even. Perhaps, yes, integer division. But > > the frontend does not optimize> > there and turn multiplication or division into shifts, I think, > > haven't read much of the frontend. The backend could.> > Correct. I think the thinking was that a decent back-end would turn > integer division by a power of 2 into an arithmetic right shift (the > gcc backend certainly does).> > > Rotate is presumably similar, but I have not looked at it.> > (LeftRotate, RightRotate, Rotate...)> > Weird thing with these is the way the high/low bits are rotated > around, so sign can change!> > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift,> > very redundanty code, could be combined.> >> > The layering is /roughly/> > m3x86 on top> > stackx86 in the middle> > codex86 at the bottom> >> > However m3x86 does call through to codex86 directly.> > They are largely one layer. There is no strict division.> > "stack" is a simple way to implement some optimizations and stategies> > around constant propagation and register allocation.> >> > It is a stack of "operands", which may be constants, globals, or > > locals.> > If something is needed in a register, a register will be freed up.> > If something is later needed and the register hasn't been spilled, > > it will be> > reused. If not, not.> >> > Presently the operands are assumed to be of word size, 32 bits, > > register size.> > That is largely a convenience, and very convenient.> > I will expand it to allow two word operands.> > It could be expanded to arbitrarily, at least to "fill" "all" the > > registers, for some> > not particularly interesting but theoretically useful scenarios -- > > passing "medium"> > sized structs around by value or such. There are ABI concerns > > though, this could> > only be amongst local functions that aren't visible/used > > externally (aka "custom calling conventions").> > You can make some assumptions about how the front-end uses the middle- > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that > is 8 bits, etc.> > > The "generic" shift (vs. left_shift, right_shift) is implemented in > > stackx86> > while left_shift, right_shift are in m3x86. All three functions are > > very similar,> > could be combined, and there is no good reason for some to be in > > one layer> > vs. the other and it's a just a pointless inconsistency.> >> > Granted, "generic" shift is a good bit different, it has to check > > the sign and the magnitude,> > whereas left and right can just blindly do the operation with no > > comparisons or branches.> >> > Some of this I gather from attempting to compile code with shifts > > -- esp. the frontend checking of stuff, which then lead me to look > > at word.i3> > which declares subranges for the parameters.> >> > Is Bill Kalsow around?> > Good question. Farshad Nayeri may know where he ended up.> > > Or the other original authors?> > I know Michel Dagenais had a student who adapted the native x86 > backend for use on Linux with PM3. I don't remember the student's name.> > > Everyone just figured stuff out from the code, comments, and > > "literature" (I ordered another copy of Nelson's good book. :) )> >> >> > - Jay> >> >> > Connect and share in new ways with Windows Live. Connect now!> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:31:49 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:31:49 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: oops C:\net\modula3>tar tf cm3-min-WIN32-NT386-5.2.6.tar.bz2 cm3-min-WIN32-NT386-5.2.6/ cm3-min-WIN32-NT386-5.2.6/cminstall.exe cm3-min-WIN32-NT386-5.2.6/COPYRIGHT-CMASS cm3-min-WIN32-NT386-5.2.6/cygwin.dll cm3-min-WIN32-NT386-5.2.6/gzip.exe cm3-min-WIN32-NT386-5.2.6/system.tgz cm3-min-WIN32-NT386-5.2.6/tar.exe It is system.tgz that can be extracted into c:\cm3. You can dispense with the rest. Older versions of tar, such as the one in this distribution, require the z flag. Newer ones do not. - Jay From: jay.krell at cornell.eduTo: hosking at cs.purdue.edu; rcolebur at scires.comDate: Fri, 30 Nov 2007 01:22:09 +0000CC: m3devel at elegosoft.comSubject: Re: [M3devel] win32/x86 prolog/epilog I haven't tried this in a few weeks, but the following should work.This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever.It is not particularly current, but it should work, by design and by my latest testing. (Until suchtime as a newer distribution is available, I assume a need to bootstrap from this, but perhapsnot anything older).Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:48:36 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:48:36 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:59:43 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:59:43 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. x86 only. - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 01:48:36 +0000Subject: [M3devel] some more notes on the win32 system some more notes on the win32 system> setup your C++ compiler/linkerYou can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking.What you need in particular arecl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path.%LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker.msvcrt.lib must be in one of them.Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 08:28:16 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 07:28:16 +0000 Subject: [M3devel] non-gcc backend Message-ID: I thought the last Digital release used the non-gcc backend for Linux x86. My mistake I see. The next thing to look into is the Critical Mass release, which I can't get to at the moment. - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 11:03:46 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 10:03:46 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: <20071130095354.8D45B10D4540@birch.elegosoft.com> References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...) Note that currently you have to use Visual C++ 6.0 or newer. I tested 2.0, 6.0, 8.0. 2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...) I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so. I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 12:50:21 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 11:50:21 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: Older than 6.0 should work now.. I probe the linker in sysinfo.cmd.. 7.1 Express which lacks msvcrt.lib should work now too, I probe for msvcrt.lib. The probing methods may be considered..not great..and "inspired" by autoconf..try stuff, see if it works, or sniff the error message (not sure if autoconf sniffs error messages). The testing remains..light. Stuff like run upgrade or do-pkg-core, not with all VC toolsets, not always going back to cm3 5.2.6. I've got 2.0,4.0,4.1,4.2,5.0,6.0,7.0,7.1, 8.0, sometimes just express, but not patience/time. The oldest officially supported by Microsoft I believe is 7.0. Really this is just a way to procrastinate on the int64 stuff and real work.. :( - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 10:03:46 +0000Subject: [M3devel] FW: fix win32 bootstrapping m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...)Note that currently you have to use Visual C++ 6.0 or newer.I tested 2.0, 6.0, 8.0.2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...)I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so.I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Fri Nov 30 14:25:09 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 30 Nov 2007 14:25:09 +0100 (CET) Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: On Thu, 29 Nov 2007, Olaf Wagner wrote: > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html Aha. > It seems to be set from M3_OPTIONS in cm3.cfg: > > s.m3_options := GetConfigArray (s, "M3_OPTIONS"); > > So I'd try to set it there. Perhaps > > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" > > will work, too. $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: ) Fatal Error: package build failed But, the following works: $ cm3 -O -D'M3_OPTIONS+=-NoChecks' where there must be no space between = and -. Many thanks for the help! I'm trying to read the code that cm3 produces, because I thought that the simple loop I wrote needs too much time. I'm sitting in front of an Intel machine and I do not really understand the Intel assembly code (I'm used to Motorola :-), but according to the line numbering (.loc directive) it seems that 'ROUND' and friends needs lot of time. The count of assembly commands is reduced by -NoChecks but still around 20 commands. It seems that ROUND, FLOOR and CEILING are implemented manually (checks for negative numbers), whereas TRUNC is the shortest, but still about 9 commands. I do not know whether Intel processors have primitives for several rounding modes. From hosking at cs.purdue.edu Fri Nov 30 15:03:39 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:03:39 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Shouldn't Jay's notes go somewhere on the CM3 Web-site? On Nov 29, 2007, at 8:48 PM, Jay wrote: > some more notes on the win32 system > > > setup your C++ compiler/linker > > You can/should "play dumb", skip that, and just run upgrade. > See what errors you get. > I tried to put in the right amount of up front sanity checking. > > What you need in particular are > > cl and link on the %PATH%. > See, cminstall would have you specify full paths, my > configuration uses %PATH%. > If using VS2005 (8) or newer, mt on the path. > > %LIB% is a semicolon delimited list of directories. > That is a feature of the Microsoft linker. > msvcrt.lib must be in one of them. > > Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, > 7.0, 7.1, 8.0 -- should work. > I have tested all of them some and many required small changes in > one particular spot, > that actually is only used by "maintainers" (C:\dev2\cm3\m3-win > \import-libs\src\make-lib-1.cmd). > I use 8.0 the most lately. > I haven't done much with 9.0. > > Another thing, fairly redundant: > > C:\dev2\cm3\m3-win>more vcredist.txt > On computers without Visual C++ 2005 or CLR 2.0 installed, download > and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- > from either > > RTM (release to manufacturing): > http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE- > A3F9-4C13-9C99-220B62A191EE > > or Service Pack 1: > http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9- > ae1a-4a14-984d-389c36f85647 > > You can find those searching the web for vcredist, no real need to > recort the URLs. That's about it. > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! From hosking at cs.purdue.edu Fri Nov 30 15:02:53 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:02:53 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 8:28 PM, Jay wrote: > Thanks! It helps to know I'm understanding things correctly. > > The backend isn't bad really, it's written by someone who very much > knew what they were doing, which is necessary. > > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > Understood. > > Actually, btw, the front/middleend could do more easy > optimizations, like some of the ones I already commited, and > really, all the constant propagation that m3x86.m3 does, via its > stack stuff and remembering if something is "immediate". I should > look into that some time....... I'd be leery of complicating the front/middle-ends with optimizations given that backends can do them (ie, gcc/m3x86). > > > - Jay > > > > From: hosking at cs.purdue.edu > > Date: Thu, 29 Nov 2007 10:59:26 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] "please confirm my understanding" > > > > > > On Nov 29, 2007, at 6:15 AM, Jay wrote: > > > > > please confirm my understanding > > > > > > I don't feel great being a lone reader/changer of code esp. that I > > > didn't write and that lacks > > > sufficient documentation for my small brain/confidence. (I'm not > > > stupid, but this isn't trivial stuff either.) > > > > If you are talking about the native x86 (non-gcc) backend then I > > concur that it is pretty unreadable. Hence my lack of enthusiasm in > > working on it myself. > > > > > I am bound to make mistakes. > > > > We all do! > > > > > In the context of Modula-3 code gen interfaces, and the word > > > interfaces, which apparently are identical/analogous/whatever: > > > > > > There is: > > > > > > Shift (aka, my bad naming, "generic" shift) > > > > Yes, shift by n>0 is shift left. n<0 is shift right. > > > > > LeftShift > > > RightShift > > > > > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > > or 0 .. 63 (given > > > particular word sizes and depending on types..) > > > The "front end" checks constants against these. > > > The "front end" inserts checks for variables against these. > > > The back end can assume 0 .. 31 or 0 .. 63. > > > > Yes, depending on word-size. > > > > > It looks like the x86 back end does redundant masks against 31, at > > > least when shifting by a constant, > > > only in its own data, not in the codegen. Just a small waste of > > > time in the compiler, no negative affect on codegen. > > > > > > "generic" Shift accepts any number for a shift count. > > > Negative numbers mean a right shift. > > > Positive numbers mean a left shift. > > > If the shift count is >31|63 or <-31|63, the result is not an > > > error, but zero. > > > > Yes. > > > > > In all cases, right shifts are unsigned, zero filling. > > > > Yes. > > > > > There is no shift operation that propagates the sign bit. > > > In the Modula-3 language even. Perhaps, yes, integer division. But > > > the frontend does not optimize > > > there and turn multiplication or division into shifts, I think, > > > haven't read much of the frontend. The backend could. > > > > Correct. I think the thinking was that a decent back-end would turn > > integer division by a power of 2 into an arithmetic right shift (the > > gcc backend certainly does). > > > > > Rotate is presumably similar, but I have not looked at it. > > > (LeftRotate, RightRotate, Rotate...) > > > > Weird thing with these is the way the high/low bits are rotated > > around, so sign can change! > > > > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > > > very redundanty code, could be combined. > > > > > > The layering is /roughly/ > > > m3x86 on top > > > stackx86 in the middle > > > codex86 at the bottom > > > > > > However m3x86 does call through to codex86 directly. > > > They are largely one layer. There is no strict division. > > > "stack" is a simple way to implement some optimizations and > stategies > > > around constant propagation and register allocation. > > > > > > It is a stack of "operands", which may be constants, globals, or > > > locals. > > > If something is needed in a register, a register will be freed up. > > > If something is later needed and the register hasn't been spilled, > > > it will be > > > reused. If not, not. > > > > > > Presently the operands are assumed to be of word size, 32 bits, > > > register size. > > > That is largely a convenience, and very convenient. > > > I will expand it to allow two word operands. > > > It could be expanded to arbitrarily, at least to "fill" "all" the > > > registers, for some > > > not particularly interesting but theoretically useful scenarios -- > > > passing "medium" > > > sized structs around by value or such. There are ABI concerns > > > though, this could > > > only be amongst local functions that aren't visible/used > > > externally (aka "custom calling conventions"). > > > > You can make some assumptions about how the front-end uses the > middle- > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > is 8 bits, etc. > > > > > The "generic" shift (vs. left_shift, right_shift) is > implemented in > > > stackx86 > > > while left_shift, right_shift are in m3x86. All three functions > are > > > very similar, > > > could be combined, and there is no good reason for some to be in > > > one layer > > > vs. the other and it's a just a pointless inconsistency. > > > > > > Granted, "generic" shift is a good bit different, it has to check > > > the sign and the magnitude, > > > whereas left and right can just blindly do the operation with no > > > comparisons or branches. > > > > > > Some of this I gather from attempting to compile code with shifts > > > -- esp. the frontend checking of stuff, which then lead me to look > > > at word.i3 > > > which declares subranges for the parameters. > > > > > > Is Bill Kalsow around? > > > > Good question. Farshad Nayeri may know where he ended up. > > > > > Or the other original authors? > > > > I know Michel Dagenais had a student who adapted the native x86 > > backend for use on Linux with PM3. I don't remember the student's > name. > > > > > Everyone just figured stuff out from the code, comments, and > > > "literature" (I ordered another copy of Nelson's good book. :) ) > > > > > > > > > - Jay > > > > > > > > > Connect and share in new ways with Windows Live. Connect now! > > > > > You keep typing, we keep giving. Download Messenger and join the > i?m Initiative now. Join in! From hosking at cs.purdue.edu Fri Nov 30 15:12:23 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:12:23 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: Message-ID: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> CMass (Bill Kalsow) were the ones to do the x86 backend I think. On Nov 30, 2007, at 2:28 AM, Jay wrote: > I thought the last Digital release used the non-gcc backend for > Linux x86. My mistake I see. > The next thing to look into is the Critical Mass release, which I > can't get to at the moment. > > - Jay > > Get the power of Windows + Web with the new Windows Live. Power up! From hosking at cs.purdue.edu Fri Nov 30 15:17:27 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:17:27 -0500 Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <625C608A-B7F8-4F7E-A657-EBE2288B77BB@cs.purdue.edu> On Nov 30, 2007, at 8:25 AM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Olaf Wagner wrote: > >> http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Aha. > >> It seems to be set from M3_OPTIONS in cm3.cfg: >> >> s.m3_options := GetConfigArray (s, "M3_OPTIONS"); >> >> So I'd try to set it there. Perhaps >> >> cm3 -D'M3_OPTIONS=[ "NoChecks" ]" >> >> will work, too. > > > $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' > LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: > ) > Fatal Error: package build failed > > > But, the following works: > $ cm3 -O -D'M3_OPTIONS+=-NoChecks' > > where there must be no space between = and -. > > Many thanks for the help! > > I'm trying to read the code that cm3 produces, because I thought > that the > simple loop I wrote needs too much time. I'm sitting in front of an > Intel > machine and I do not really understand the Intel assembly code (I'm > used > to Motorola :-), but according to the line numbering (.loc > directive) it > seems that 'ROUND' and friends needs lot of time. The count of > assembly > commands is reduced by -NoChecks but still around 20 commands. It > seems > that ROUND, FLOOR and CEILING are implemented manually (checks for > negative numbers), whereas TRUNC is the shortest, but still about 9 > commands. I do not know whether Intel processors have primitives for > several rounding modes. I think the issue here is that GCC's round/trunc/ceiling don't match the M3 spec particularly well. I'd have to look more closely. From jay.krell at cornell.edu Fri Nov 30 15:44:42 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 14:44:42 +0000 Subject: [M3devel] non-gcc backend In-Reply-To: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: Well that I can contradict. Digital (Bill Kalsow) did the x86 backend.Attached is from boot-LINUXELF.tar.bz2 (originally some other compression). 2) Unpack "boot-XYZ.tar.gz": gunzip < boot-XYZ.tar.gz | tar xpof - 3) Inside the boot-XYZ directory that gets created, unpack "m3cc.tar.gz". It's the gcc-based backend. cd boot-XYZ gunzip < ../m3cc.tar.gz | tar xpof - On Windows 95 and Windows NT, m3cc is not used. This step should be skipped. I think a C producing backend would be useful, to quickly get Windows IA64 and AMD64 support... - Jay > From: hosking at cs.purdue.edu> Date: Fri, 30 Nov 2007 09:12:23 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] non-gcc backend> > CMass (Bill Kalsow) were the ones to do the x86 backend I think.> > On Nov 30, 2007, at 2:28 AM, Jay wrote:> > > I thought the last Digital release used the non-gcc backend for > > Linux x86. My mistake I see.> > The next thing to look into is the Critical Mass release, which I > > can't get to at the moment.> >> > - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: NOTES URL: From hosking at cs.purdue.edu Fri Nov 30 17:49:25 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 11:49:25 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: On Nov 30, 2007, at 9:44 AM, Jay wrote: > Well that I can contradict. Digital (Bill Kalsow) did the x86 backend. > Attached is from boot-LINUXELF.tar.bz2 (originally some other > compression). > > 2) Unpack "boot-XYZ.tar.gz": > gunzip < boot-XYZ.tar.gz | tar xpof - > 3) Inside the boot-XYZ directory that gets created, > unpack "m3cc.tar.gz". It's the gcc-based backend. > cd boot-XYZ > gunzip < ../m3cc.tar.gz | tar xpof - > On Windows 95 and Windows NT, m3cc is not used. This step should > be skipped. > > I think a C producing backend would be useful, to quickly get > Windows IA64 and AMD64 support... There was a C-producing backend in the bad old days. Is it still around anywhere? Also, I know there were experimental BURS-based backends too. An alternative to C might be C-- or llvm. > > > - Jay > > > > > From: hosking at cs.purdue.edu > > Date: Fri, 30 Nov 2007 09:12:23 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] non-gcc backend > > > > CMass (Bill Kalsow) were the ones to do the x86 backend I think. > > > > On Nov 30, 2007, at 2:28 AM, Jay wrote: > > > > > I thought the last Digital release used the non-gcc backend for > > > Linux x86. My mistake I see. > > > The next thing to look into is the Critical Mass release, which I > > > can't get to at the moment. > > > > > > - Jay > > > Get the power of Windows + Web with the new Windows Live. Power up! > From wagner at elegosoft.com Fri Nov 30 20:24:12 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 30 Nov 2007 20:24:12 +0100 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Message-ID: <20071130202412.8mewmacdssoso04s@mail.elegosoft.com> Quoting Tony Hosking : > Shouldn't Jay's notes go somewhere on the CM3 Web-site? Sure they should. I would suggest a Windows-specific chapter or link in http://modula3.elegosoft.com/cm3/installation.html, as well as a news item on the first page. Jay, could you extend the HTML documentation on your own and check it into the reporitory, or do you need help? It's all in the cm3/www package. Once it's checked in, we can ship it to our WWW server. Thanks in advance, Olaf > > On Nov 29, 2007, at 8:48 PM, Jay wrote: > >> some more notes on the win32 system >> >>> setup your C++ compiler/linker >> >> You can/should "play dumb", skip that, and just run upgrade. >> See what errors you get. >> I tried to put in the right amount of up front sanity checking. >> >> What you need in particular are >> >> cl and link on the %PATH%. >> See, cminstall would have you specify full paths, my configuration >> uses %PATH%. >> If using VS2005 (8) or newer, mt on the path. >> >> %LIB% is a semicolon delimited list of directories. >> That is a feature of the Microsoft linker. >> msvcrt.lib must be in one of them. >> >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, >> 7.0, 7.1, 8.0 -- should work. >> I have tested all of them some and many required small changes in >> one particular spot, >> that actually is only used by "maintainers" >> (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). >> I use 8.0 the most lately. >> I haven't done much with 9.0. >> >> Another thing, fairly redundant: >> >> C:\dev2\cm3\m3-win>more vcredist.txt >> On computers without Visual C++ 2005 or CLR 2.0 installed, download >> and run the setup for the Visual C++ runtime -- vcredist_x86.exe >> -- from either >> >> RTM (release to manufacturing): >> >> http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE >> >> or Service Pack 1: >> >> http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 >> >> You can find those searching the web for vcredist, no real need to >> recort the URLs. That's about it. >> >> - Jay >> >> Your smile counts. The more smiles you share, the more we donate. Join in! -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From agrj at aes.com.br Fri Nov 30 20:28:42 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:28:42 -0200 Subject: [M3devel] Modula 3 and Mac os X Message-ID: Dear All, this is my first message, sorry for the "beginner" question. is there any Modula 3 distribution that is capable of running in a Mac OS X enviroment? if yes, where can I get it and how to install. thanks in advance, Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 20:42:33 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 14:42:33 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: References: Message-ID: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a daily basis. Unfortunately, the most recent release of CM3 does not support Intel Macs (and is somewhat lacking even for PowerPC Macs). I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from the current CVS head of CM3 following the instructions for CM3. On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > Dear All, > > this is my first message, sorry for the "beginner" question. > > is there any Modula 3 distribution that is capable of running in a > Mac OS X enviroment? if yes, where can I get it and how to install. > > thanks in advance, > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > From agrj at aes.com.br Fri Nov 30 20:48:58 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:48:58 -0200 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Message-ID: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Thanks I will try. I have also a Macbook pro with OS X 10.5.1. would you think it work? thanks again Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a > daily basis. Unfortunately, the most recent release of CM3 does not > support Intel Macs (and is somewhat lacking even for PowerPC Macs). > I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ > hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from > the current CVS head of CM3 following the instructions for CM3. > > On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > >> Dear All, >> >> this is my first message, sorry for the "beginner" question. >> >> is there any Modula 3 distribution that is capable of running in a >> Mac OS X enviroment? if yes, where can I get it and how to install. >> >> thanks in advance, >> >> Aryldo G Russo Jr >> Gerente de Pesquisa e Desenvolvimento >> Grupo AeS >> CRE 6006 - CSSBB 5770 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 21:21:52 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 15:21:52 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Message-ID: <523F0686-A41F-49CB-A89A-E06145AA557F@cs.purdue.edu> I have heard that there may be problems generally with porting software to 10.5 resulting from changes in some of the low-level interfaces. I have not had a chance to try on 10.5 yet. On Nov 30, 2007, at 2:48 PM, Aryldo G Russo Jr wrote: > Thanks > > I will try. > > I have also a Macbook pro with OS X 10.5.1. would you think it work? > > thanks again > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > > Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > >> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a >> daily basis. Unfortunately, the most recent release of CM3 does >> not support Intel Macs (and is somewhat lacking even for PowerPC >> Macs). I have a bootstrap compiler available at ftp:// >> ftp.cs.purdue.edu:pub/hosking/m3/I386_DARWIN/cm3.gz. You can use >> this to bootstrap from the current CVS head of CM3 following the >> instructions for CM3. >> >> On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: >> >>> Dear All, >>> >>> this is my first message, sorry for the "beginner" question. >>> >>> is there any Modula 3 distribution that is capable of running in >>> a Mac OS X enviroment? if yes, where can I get it and how to >>> install. >>> >>> thanks in advance, >>> >>> Aryldo G Russo Jr >>> Gerente de Pesquisa e Desenvolvimento >>> Grupo AeS >>> CRE 6006 - CSSBB 5770 >>> >>> >> > From rcoleburn at scires.com Fri Nov 30 23:24:25 2007 From: rcoleburn at scires.com (Randy Coleburn) Date: Fri, 30 Nov 2007 17:24:25 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <4750474F.1E75.00D7.1@scires.com> Jay: Thanks for all your help. Actually, the last time I tried to install cm3, I used the 5.26 tarballs and tried to build, but ran into some compile errors. I'll try it again and report back the actual errors I get (if any). As for Microsoft Visual Studio, yes I'm familiar with setting it up. Are you saying that the cm3install program should no longer be used? I've used this in the past. The big issue I've run into is making sure to give old style 8.3 pathnames without spaces and to edit the cm3.cfg file to find all the libraries and stuff using paths without spaces. I've also set some environment vars, in particular the TEMP and TMP vars, to use paths without spaces. I will try to be very careful to document everything I do in great detail. Perhaps we can use this to give out a better recipe to folks on how to get cm3 working on Windows. Regards, Randy >>> Jay 11/29/2007 8:48 PM >>> some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade. See what errors you get. I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%. If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories. That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). I use 8.0 the most lately. I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txt On computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! ( about:www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 2 21:37:38 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 2 Nov 2007 20:37:38 +0000 Subject: [M3devel] iterating over sets? In-Reply-To: References: Message-ID: I was asking about Modula-3 syntax and built in mechanisms. Here are the ways to implement this sort of thing. There are two main scenarios: a small set this can be either 0..n or n..m "small" is n or m-n a big set again 0..n or n..m offseting the start is trivial A small set should be represented by an array of some integer type,such as array of 8 bit int, or 16 bit int, or 32 bit, or 64 bit int It should support operations such as: Operations my question needs: FindFirstSetBit FindNextSetBit(start) Operation of course needed: GetBit(offset) Operations other uses of this data structure would want, though maybe not a "set": FindFirstClearBit FindNextClearBit(start) FindClearBits(start,count) FindSetBits(start,count) SetBits(start,count) ClearBits(start,count) You might want to combine some of them -- FindClearBitsAndSet, FindSetBitsAndClear. Operations that Modula-3 already has: union intersect difference symmetric_difference I was asked stuff about this as an interview question years ago. Depending on processor support, one implementation is an array of bytes and youhave roughly the following small tables: typedef unsigned char byte;byte MaximumBitsSet[256];byte MaximumBitsClear[256];byte BitsSetLeft[256];byte BitsClearLeft[256];byte BitsSetRight[256];byte BitsClearRight[256];byte OffsetOfMaximumBitsSet[256];byte OffsetOfMaximumBitsClear[256]; Some of this might be redundant.You could pack them the other way: typedef struct BitInfo_t { byte MaximumBitsSet; // or 3 bit bitfield byte MaximumBitsClear; etc.} BitInfo_t; BitInfo_t BitInfo[256]; >From here you can reasonably easily reasonably efficiently implementthe functions I identified. Now, if your processor supports intructions to compute some of thesefigures efficiently, esp. on a 32 bit or 64 bit integer, that mightbe more efficient. There's a term here "population count" and an instructionin some processors. Maybe also "lzcnt" -- leading zero count. If the set does not start at 0, you just offset things at some point. Easy. For a large set, this will use too much memory.You can use simply a sorted array of integers.And use binary search against that.Not terrible. Or you can use an array of offset, length pairs."extents" perhaps this is called.You would sort this by offset, and again use binary search.This would tend to be more compact. You could be adaptive.You could set some thresholds of size or density at which you would switchthe representation from one to the other.Of course you if I am frequently adding/removing items to a set, you don'twant to frequently change the representation. I'm still pondering 64 bit integer support in the x86 back end.The basic dilemna is a stack of pairs or the existing stack of singletons wheresometimes you'd use two stack items at a time. I'm leaning towarda stack of pairs. After that we can discuss something like: FindFirstMemberInSet FindNextMemberInSet and adding that to the language, etc. FIRST and NEXT seem natural but I believe FIRST already meansthe first possible value, not the first present value. On Windows, run link /dump /exports %windir%\system32\ntdll.dll | findstr /i bit.You'll see some of this stuff and more. - Jay > Date: Wed, 31 Oct 2007 23:09:11 +0100> From: lemming at henning-thielemann.de> Subject: Re: [M3devel] iterating over sets?> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> > > On Wed, 31 Oct 2007, Jay wrote:> > > Let's say I had> >> > TYPE T = SET OF { 0 .. 256 };> >> > Must I say:> >> > VAR t: T;> > FOR i := FIRST(t) TO LAST(t)> > IF i IN t DO> > something with i> > END> > END> > You may speed up search by splitting the set into subsets.> > E.g.> > IF t * T{16..31} = T{} THEN> skip this block completely> ELSE> inspect that block in detail> END; _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Mon Nov 5 16:05:14 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon, 05 Nov 2007 16:05:14 +0100 (MET) Subject: [M3devel] m3.org Message-ID: Does the domain have a new owner? From wagner at elegosoft.com Mon Nov 5 17:06:32 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Mon, 05 Nov 2007 17:06:32 +0100 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: <20071105170632.1cuq7pj8mccgc8w0@mail.elegosoft.com> Quoting Henning Thielemann : > > Does the domain have a new owner? No, it still belongs to Farshad Nayeri, and he wants to keep it. All content has been moved to modula3.org several months ago. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From darko at darko.org Mon Nov 5 18:26:20 2007 From: darko at darko.org (Darko) Date: Mon, 5 Nov 2007 09:26:20 -0800 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: Looks like it. modula3.org is being used instead. On 05/11/2007, at 7:05 AM, Henning Thielemann wrote: > > Does the domain have a new owner? From wagner at elegosoft.com Fri Nov 9 12:45:25 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:45:25 +0100 Subject: [M3devel] Fwd: install problems Message-ID: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Sorry, I'm afraid there's currently no one here at Elego to look into this; perhaps anybody here on m3devel can help out? I myself am busy at a customer. Thanks in advance, Olaf ----- Forwarded message from radugrigore at gmail.com ----- Date: Fri, 9 Nov 2007 10:02:28 +0000 From: Radu Grigore Reply-To: Radu Grigore Subject: install problems To: m3-support at elego.de OK, I stopped trying the CVS and followed the installation notes. It stopes working here: rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship CM3C = /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap rehearsecode replayheap showheap shownew showthread pkl-fonts juno-machine juno-compiler juno-app cube calculator fisheye mentor === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' +++ Segmentation fault (core dumped) *** execution of failed *** -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- A non-text attachment was scrubbed... Name: Install.log Type: text/x-log Size: 9440 bytes Desc: not available URL: From wagner at elegosoft.com Fri Nov 9 12:47:14 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:47:14 +0100 Subject: [M3devel] Fwd: Re: install problems Message-ID: <20071109124714.cocmjgc4pc8c08cw@mail.elegosoft.com> Seem's I've been too pessimistic, Stefan has taken charge :-) Olaf ----- Forwarded message from stsp at elego.de ----- Date: Fri, 9 Nov 2007 11:31:07 +0100 From: Stefan Sperling Reply-To: Stefan Sperling Subject: Re: install problems To: Radu Grigore Cc: m3-support at elego.de On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From stsp at elego.de Fri Nov 9 15:13:11 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 15:13:11 +0100 Subject: [M3devel] [radugrigore@gmail.com: Re: install problems] Message-ID: <20071109141311.GF27811@jack.stsp.lan> Olaf, why did you forward Radu's request to the m3devel list? Is only elego staff on m3-support? If so, why? Just in case people missed his response, here it is. I don't know what his problem could be, may be someone who has an idea could respond and make it clear that further replies should go the m3devel list directly? Thanks. ----- Forwarded message from Radu Grigore ----- Date: Fri, 9 Nov 2007 11:30:42 +0000 From: Radu Grigore To: Stefan Sperling Subject: Re: install problems Cc: m3-support at elego.de Thanks for the reply! On Nov 9, 2007 10:31 AM, Stefan Sperling wrote: > What platform? Ubuntu gutsy. Linux rg-ucd 2.6.22-14-386 #1 Sun Oct 14 22:36:54 GMT 2007 i686 GNU/Linux > Which notes exactly? http://modula3.elegosoft.com/cm3/installation.html (Please note that I am not subscribed to this list. I wasn't even aware that it _is_ a list. I sent an email only because of the note at the end of the webpage linked above. Oh, you should probably know that the web form mentioned in the same paragraph on that webpage insists on "all mandatory fields being filled in" even when _all_ fields are filled in.) > Someone else on the list may have a better idea of what > this could be, I'm not following cm3 development closely. After ./do-cm3-core.sh buildship // seem to work fine ./install-cm3-compiler.sh upgrade running cm3 crashes every time actually. It just so happened that ./do-cm3-std.sh buildship was the next command that was supposed to be run. (Might be relevant: the command "./install-cm3-compiler.sh upgrade" didn't work because I installed cm3 in /homr/rg/tools/cm3 instead of /usr/local/cm3 and the latter is hardcoded in sysinfo.sh. The same for the lib directory. It did seem to work after fixing those.) > In any case, a backtrace would be great to help people > diagnose this. Please run: The backtrace doesn't seem useful: (gdb) where #0 0x9e841069 in ?? () Cannot access memory at address 0x405fcfa2 It crashes quite fast: rg at rg-ucd:src$ strace cm3 execve("/home/rg/tools/cm3/bin/cm3", ["cm3"], [/* 36 vars */]) = 0 uname({sys="Linux", node="rg-ucd", ...}) = 0 brk(0) = 0x8b1f000 brk(0x8b1fcb0) = 0x8b1fcb0 set_thread_area({entry_number:-1 -> 6, base_addr:0x8b1f830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 brk(0x8b40cb0) = 0x8b40cb0 brk(0x8b41000) = 0x8b41000 gettimeofday({1194607166, 865750}, NULL) = 0 gettimeofday({1194607166, 865831}, NULL) = 0 rt_sigaction(SIGHUP, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGINT, {0x820cc21, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGQUIT, {0x820cc81, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGSEGV, {0x820cce6, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTERM, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 mmap2(NULL, 270336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f34000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV (core dumped) +++ Same output with LD_POINTER_GUARD=0. -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From hosking at cs.purdue.edu Fri Nov 9 15:28:28 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 9 Nov 2007 09:28:28 -0500 Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Message-ID: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> WHat's your build target? On Nov 9, 2007, at 6:45 AM, Olaf Wagner wrote: > Sorry, > > I'm afraid there's currently no one here at Elego to look into this; > perhaps anybody here on m3devel can help out? > I myself am busy at a customer. > > Thanks in advance, > > Olaf > > ----- Forwarded message from radugrigore at gmail.com ----- > Date: Fri, 9 Nov 2007 10:02:28 +0000 > From: Radu Grigore > Reply-To: Radu Grigore > Subject: install problems > To: m3-support at elego.de > > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: > > rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship > CM3C = > /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build > -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 > patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen > m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry > set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf > debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex > m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq > netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc > postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt > jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit > codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn > obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui > obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui > obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap > rehearsecode replayheap showheap shownew showthread pkl-fonts > juno-machine juno-compiler juno-app cube calculator fisheye mentor > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** > > > -- > regards, > radu > http://rgrig.blogspot.com/ > > > ----- End forwarded message ----- > > > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > > > Thank you for using Critical Mass CM3. This program > will configure and install the system. > > cminstall_root is set to /home/rg/temp > If this is not correct, please restart the installer with > -root > > The installer will ask you some questions about the locations of > programs > and libraries. Usually it will display a default inside [], which > can be > accepted with . > If the installer has found several choices, you may cycle through them > with `+' or `.' for the next and `-' for the previous one. > You may of course also enter a completely different value. > > > Where would you like the system installed? [/usr/local/cm3] > What should be the default text editor for new Reactor users? > checking for executable with environment variable EDITOR... not found > checking for executable emacsclient... found > checking for executable emacs... found > checking for executable vi... found > checking for executable textedit... not found > checking for executable xedit... not found > checking for executable emacsclient in directory /usr/local/emacs/ > bin... not found > checking for executable emacsclient in directory /usr/local/bin... > not found > checking for executable emacs in directory /usr/local/emacs/bin... > not found > checking for executable emacs in directory /usr/local/bin... not found > checking for executable vi in directory /usr/bin... found > checking for executable xedit in directory /usr/local/X11R5/bin... > not found > checking for executable textedit in directory /usr/openwin/bin... > not found > checking for executable xedit in directory /usr/openwin/bin... not > found > checking for executable xedit in directory /usr/X11/bin... not found > checking for executable xedit in directory /usr/bin/X11... not found > > 1: /usr/bin/emacsclient > 2: /usr/bin/emacs > 3: /usr/bin/vi > What should be the default text editor for new Reactor users? > [/usr/bin/emacsclient](1 of 3) /usr/bin/vi > > Where should Reactor be installed? > setting INSTALL_ROOT to /usr/local/cm3 > Where are the flex/bison libraries? > looking for library file(s): libfl.a > checking for library files in directory /usr/lib... found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the flex/bison libraries? [/usr/lib](1 of 1) > > Where are the Postgres95 libraries? > looking for library file(s): libpq.so > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) > The libraries libpq.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) /home/rg/lib/ > links > > Where are the OpenGL libraries? > looking for library file(s): libGLU.so > looking for library file(s): libGL.so libGLU.so > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) > The libraries libGL.so libGLU.so are not present in the chosen > directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) /home/rg/lib/links > > Where are the ODBC libraries? > looking for library file(s): libodbc.so > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/pgsql/lib... not > found > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for directory /usr/local/lib... found > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) > The libraries libodbc.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) /home/rg/lib/ > links > > Where are the Motif libraries? > looking for library file(s): libXm.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the Motif libraries? [/usr/X11R6/lib](1 of 2) /home/rg/ > lib/links > > Where are the X11 libraries? > looking for library file(s): libXaw.so > looking for library file(s): libXmu.so libXaw.so > looking for library file(s): libXext.so libXmu.so libXaw.so > looking for library file(s): libXt.so libXext.so libXmu.so libXaw.so > looking for library file(s): libSM.so libXt.so libXext.so libXmu.so > libXaw.so > looking for library file(s): libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so > looking for library file(s): libX11.so libICE.so libSM.so libXt.so > libXext.so libXmu.so libXaw.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) > The libraries libX11.so libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) /home/rg/lib/ > links > > Where is your C compiler? > checking for executable gcc... found > checking for executable gcc in directory /bin... not found > checking for executable gcc in directory /usr/bin... found > checking for executable gcc in directory /usr/local... not found > checking for executable gcc in directory /usr/local/bin... not found > checking for executable gcc in directory /usr/local/gnu... not found > checking for executable cc... found > checking for executable cc in directory /bin... not found > checking for executable cc in directory /usr/bin... found > checking for executable cc in directory /usr/local... not found > checking for executable cc in directory /usr/local/bin... not found > checking for executable cc in directory /usr/local/gnu... not found > > 1: /usr/bin/gcc > 2: /usr/bin/cc > Where is your C compiler? [/usr/bin/gcc](1 of 2) > > Where is your library archiver? > checking for executable ar... found > checking for executable ar in directory /usr/bin... found > checking for executable ar in directory /bin... not found > checking for executable ar in directory /usr/local... not found > checking for executable ar in directory /usr/local/bin... not found > checking for executable ar in directory /usr/local/gnu... not found > > 1: /usr/bin/ar > Where is your library archiver? [/usr/bin/ar](1 of 1) > > Where is your assembler? > checking for executable as... found > checking for executable as in directory /usr/bin... found > checking for executable as in directory /bin... not found > checking for executable as in directory /usr/local... not found > checking for executable as in directory /usr/local/bin... not found > checking for executable as in directory /usr/local/gnu... not found > > 1: /usr/bin/as > Where is your assembler? [/usr/bin/as](1 of 1) > > > Installing CM3 in: /usr/local/cm3 > This may take a few minutes... > > CM3 is now installed. > > Before you begin, here's a few reminders: > > 1) The CM3 compiler executable is in: > /usr/local/cm3/bin/cm3 > You may need to modify your PATH environment variable to find it. > And on Unix, you may need to type "rehash" to your shell. > > 2) CM3's shared libraries and any you create and ship are in: > /usr/local/cm3/lib > On most Unix systems you need to set the LD_LIBRARY_PATH > (on Darwin / MacOS X it's called DYLD_LIBRARY_PATH) > environment variable before running programs that use > these shared libraries. > > 3) Your system configuration file is: > /usr/local/cm3/bin/cm3.cfg > At any point in time, you may edit it to modify or update your > installation. > > 4) A copy of this installation dialogue is in: > /usr/local/cm3/Install.log > > 5) If you had trouble with this installation or need more > assistance, > please send us a transcript of this installation via e-mail at > "m3-support at elego.de". > > Thank you. From stsp at elego.de Fri Nov 9 16:42:12 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 16:42:12 +0100 Subject: [M3devel] Fwd: install problems In-Reply-To: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> Message-ID: <20071109154212.GH27811@jack.stsp.lan> On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From dabenavidesd at yahoo.es Sat Nov 10 04:14:37 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 10 Nov 2007 04:14:37 +0100 (CET) Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109154212.GH27811@jack.stsp.lan> Message-ID: <610753.84071.qm@web27102.mail.ukl.yahoo.com> Hi all: Maybe I can help you. After all the help you have gave to me, I can contribute; first Im not sure but maybe Radu has some problem with cm3.cfg file and the way I have used the new cm3 binary is more "manual" than the cminstall process which should adjust the cm3.cfg file. The first thing to do is dowload the appropiate libraries/programs to be able to compile the cm3 standard. The packages I have used for the Ubuntu Feisty are these: http://es.geocities.com/dabenavidesd/cm3Manual.html#SECTION00020000000000000000 The above guide is for users of ubuntu feisty (older than gutsy), but the only version dependant thing are the names of some packages, but normally it should work for the gutsy, I can try it on these weekend as soon as I can. After that tough the instructions are in spanish you can see the line commands I have used, please inform me if there is something worng, and I will take account of that and change the "instructions". I will do a english version if it is really important (I think yes). Bye On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner Stefan Sperling escribi?: --------------------------------- ?Descubre una nueva forma de obtener respuestas a tus preguntas! Entra en Yahoo! Respuestas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sat Nov 10 12:33:03 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 03:33:03 -0800 Subject: [M3devel] leap-second issue with Date.i3 Message-ID: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Hello everyone, I just ... added a workaround for a nasty bug I had in some code of my own. My code used Unix's localtime to convert a Time.T to a Date.T using the zoneinfo files. I'm not sure if there's a "normal" way to do this in M3, so I have some messy stuff involving mutexes, static storage, etc. (Note one has to be careful when linking this stuff into a program with the normal M3 conversion codes---Date.FromTime and Date.ToTime---which also use (other) hidden mutexes to protect some of the same data structures!) The issue is this. I just realized that localtime sometimes returns "60" for the seconds---namely, during a leap second! Just copying this into a Date.T will lead to a range error and a program crash. Do we really want Modula-3 users to have to restart their servers the moment after popping the champagne corks? (Ok, well during New Year's Eve in my time zone, but still...) Does anyone know how Date.T handles/should handle this? As correct as it is, I find it somewhat unsatisfying to change the seconds field to [0..60], because off-by-one errors are so common in programming... it's probably The Right Thing to do, though. Mika From hosking at cs.purdue.edu Sat Nov 10 17:22:21 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Sat, 10 Nov 2007 11:22:21 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: I see no problem with changing seconds to [0..60]. That matches the POSIX spec nicely enough. On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes--- > Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From hendrik at topoi.pooq.com Sat Nov 10 21:11:01 2007 From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com) Date: Sat, 10 Nov 2007 15:11:01 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: <20071110201101.GB1273@topoi.pooq.com> On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes---Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) Does that mean that each time zone, as midnight creeps around the world, will insert the leap second at its own midnight, resulting in time-zone differences of 59 minutes and 59 seconds? -- hendrik > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From mika at async.caltech.edu Sat Nov 10 21:40:33 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 12:40:33 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 15:11:01 EST." <20071110201101.GB1273@topoi.pooq.com> Message-ID: <200711102040.lAAKeXoK067937@camembert.async.caltech.edu> hendrik at topoi.pooq.com writes: >On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: ... >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) > >Does that mean that each time zone, as midnight creeps around the world, >will insert the leap second at its own midnight, resulting in time-zone >differences of 59 minutes and 59 seconds? No, I think it happens at midnight UTC... during New Year's Eve here in California, early New Year's Day in CET. > >-- hendrik ... From jay.krell at cornell.edu Mon Nov 12 01:51:55 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 00:51:55 +0000 Subject: [M3devel] small array in modula-3? Message-ID: What is the right way to have a variably sized but always small array in Modula-3?My array will only ever have 1 or 2 elements.I'd like to always allocate room for 2 elements, and have there be a size. It seems I have a choice of a) an "open" arrayb) wrap it up in a record I'd like so have, like: TYPE A = ARRAY [0..1] OF FOO; And be able to say: VAR a : A; .. a.size FOR i := 0 TO a.size DO do something with a[i] It seems I have no option but, like: TYPE A = RECORD a: ARRAY[0..1] OF FOO; size := 1; (* usually of size 1, sometimes 2 *)END and then FOR i := 0 TO a.size DO do something with a.a[i]; That is "ok". Not great -- what to call the inner a? But then furthermore, I'd like to construct constants.It seems I am stuck with either the verbose: PROCEDURE F(a:A); F( A { ARRAY[0..1] OF FOO { .. } ); OR I have to come up with a name for the embedded array.But of course, its type is really "the same" as the outer type. To wit: TYPE FooArray = ARRAY[0..1] OF Foo; TYPE FooArray = RECORD a : FooArray; size := 1;END; F( FooArray { FooArray { .. } ); But I have to come up with different names. And I don't think I can leave out the name for the constructor, like: F( FooArray { { .. } ); Though that might seem nice. Am I understanding everything? Have folks hit this before and there's a set of names that don't seem too lamethat folks use? Also -- language documentation?Nelson's green book is excellent.The stuff in the doc directory is very dry and scientific.The tutorial seems more like a reference. Or maybe I didn't read it enough.Is there better, in case I need a refresher?I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,but I don't think anyone could learn from the current online docs in the source tree. Maybe it's me, some combination of laziness and short attention span as I age.. Btw, C doesn't offer a great solution here, though it offers leaving out some type names.In C++ I could have both .size and operator[].Modula-3 seems to be missing operator overloading.It's got some builtin stuff, even array assignment and equality and I think even record assignment and equality, but it is still a bit limiting. Also, if I understand things correctly, this has long bothered me about Modula-3, though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght objects. Like, small stack allocated structs with member functions. You seem to have to chose between heap allocated garbage collected virtual member functions full featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- objects don't have to be heap allocated and member functions don't have be virtual. Or am I missing something? Anyway, I've gotten to accept C a bit more vs. C++ so I can deal witht: Type;Type_DoSomething(t); in place of:t.DoSomething(); - Jay _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Mon Nov 12 06:16:32 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 05:16:32 +0000 Subject: [M3devel] test Message-ID: Is this working? - Jay _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sun Nov 11 23:36:39 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sun, 11 Nov 2007 14:36:39 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711112236.lABMad1c028825@camembert.async.caltech.edu> My only problem with it is that it is likely to break some programs, those that depend on the seconds field never exceeding 60. I think it's legitimate to ask whether it is not more reasonable to expect a well-written Modula-3 program(mer) to have used the contents of Date.i3 rather than the POSIX standard to decide how to treat the values of type Date.T.... Which are these "twilight zone" programs? I have no idea.. Mika Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Mon Nov 12 12:42:09 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 03:42:09 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711121142.lACBg95n060864@camembert.async.caltech.edu> Now it's not clear to me that [0..59] was wrong in the first place. The key thing to remember is that the following oft-repeated statement (from the FreeBSD time(3) man page)... The time() function returns the value of time in seconds since 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time. is actually wrong. Today, the "right"(*) specification is that the time() function returns a value that is currently 23 (I think that's the number) less than the number of seconds since the Unix epoch. This is obvious if you've ever noticed that the 0th second of a minute always comes out divisible by 60 in Unix time. The leap seconds are just not representable in Unix time. POSIX localtime can't return 60 for the seconds, because the same POSIX time represents two different seconds. Wikipedia talks about this a bit. They give the example of Unix time 915,148,800, which corresponds to BOTH 23:59:60 UTC on December 31, 1998 and 00:00:00 UTC on January 1, 1999. I am a bit baffled why POSIX bothers to have the 60 in their struct tm definition, if the underlying timeval data structure just can't represent the time in question. That is, when you pass 915,148,800 to Date.FromTime you probably get 00:00:00 UTC, Jan 1, 1999, and NOT 23:59:60 UTC, Dec. 31, 1998, even though both are equally correct. There is however a cryptic comment in my localtime man page that The asctime(), ctime(), difftime(), gmtime(), localtime(), and mktime() functions conform to ISO/IEC 9899:1990 (``ISO C90''), and conform to ISO/IEC 9945-1:1996 (``POSIX.1'') provided the selected local timezone does not contain a leap-second table (see zic(8)). I read the zic man page several times and am none the wiser!!!! ... that is, I don't know if POSIX functions localtime et al. can ever return 60 for the seconds field. Possibly FreeBSD ones may if zic is fed the proper information, but then does that mess up the Unix time values? (One would think it would have to.) I really just want to be sure that my server programs don't crash because they try to do something like s : [0..59] := 60 at an inopportune moment! (And your solution accomplishes that, at least.) Mika (*) actually the correct specification for the Unix time defines it in terms of UTC. Unix time = 86400*(# of days since Jan 1, 1970) + 3600 * UTC.hour + 60 * UTC.minute + UTC.second. It follows from this definition that Unix time maps neither linearly nor single-valuedly to actual time. Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Tue Nov 13 08:06:58 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 23:06:58 -0800 Subject: [M3devel] time conversion re-entrancy issues Message-ID: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Hello everyone, I just ran into this on the program I'm developing. It's a crash in my own code, but I believe that the conversion routines in Date.i3 aren't immune to it either... Program received signal SIGBUS, Bus error. ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 ThreadPosix.m3:126: No such file or directory. (gdb) where #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 #2 16_bfbfff94 in ?? () #3 16_6827e4c0 in tzsetwall () #4 16_6827e789 in localtime_r () #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, _result=RECORD year = 0; month = Jan; day = ; hour = 0; minute = 0; second = 0; offset = 2; zone = ; weekDay = ; END) at TZ.m3:47 #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, t=1194934056.6984761, prec=3, simplified=TRUE) at SafeTZ.m3:23 What's going on is that I'm converting a Time.T to a Date.T using my own conversion routine, which eventually calls the Unix localtime_r function (same procedure, done a bit more elaborately, as in the standard implementation of Date.FromTime). The problem is that localtime apparently under certain circumstances can call tzsetwall, which can take a while to run, as it involves reading timezone info from /usr/share/zoneinfo. My diagnosis is that the thread doing the conversion yielded, and then something in ThreadPosix (OK this is an old version, but the current version works the same) calls gettimeofday. And apparently gettimeofday isn't re-entrant w.r.t. tzsetwall. Is there a portable (i.e., across M3 versions) way of stopping all threadswitching activity while a call into some nasty C code is proceeding? I don't see how one can avoid it here... Mika From lemming at henning-thielemann.de Tue Nov 13 15:31:30 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue, 13 Nov 2007 15:31:30 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Mon, 12 Nov 2007, Jay wrote: > What is the right way to have a variably sized but always small array in > Modula-3?My array will only ever have 1 or 2 elements.I'd like to always > allocate room for 2 elements, and have there be a size. How about SUBARRAY of a two-element array? From hosking at cs.purdue.edu Tue Nov 13 17:57:29 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:57:29 -0500 Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Nov 13, 2007, at 9:31 AM, Henning Thielemann wrote: > > On Mon, 12 Nov 2007, Jay wrote: > >> What is the right way to have a variably sized but always small >> array in >> Modula-3?My array will only ever have 1 or 2 elements.I'd like to >> always >> allocate room for 2 elements, and have there be a size. > > How about SUBARRAY of a two-element array? Yes indeed! From hosking at cs.purdue.edu Tue Nov 13 17:56:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:56:05 -0500 Subject: [M3devel] time conversion re-entrancy issues In-Reply-To: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> References: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Message-ID: <49D06EC8-37FE-4876-A84E-A854E754A749@cs.purdue.edu> On Nov 13, 2007, at 2:06 AM, Mika Nystrom wrote: > Hello everyone, > > I just ran into this on the program I'm developing. It's a crash > in my > own code, but I believe that the conversion routines in Date.i3 aren't > immune to it either... > > > Program received signal SIGBUS, Bus error. > ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = > 1747444928; > END) at ThreadPosix.m3:126 > ThreadPosix.m3:126: No such file or directory. > (gdb) where > #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; > tv_usec = 1747444928; END) at ThreadPosix.m3:126 > #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 > #2 16_bfbfff94 in ?? () > #3 16_6827e4c0 in tzsetwall () > #4 16_6827e789 in localtime_r () > #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, > _result=RECORD year = 0; month = Jan; > day = ; hour = 0; minute > = 0; > second = 0; offset = 2; zone = Bad address>; > weekDay = ; END) at TZ.m3:47 > #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, > t=1194934056.6984761, > prec=3, simplified=TRUE) at SafeTZ.m3:23 > > What's going on is that I'm converting a Time.T to a Date.T using > my own conversion routine, which eventually calls the Unix > localtime_r function (same procedure, done a bit more elaborately, > as in the standard implementation of Date.FromTime). > > The problem is that localtime apparently under certain circumstances > can call tzsetwall, which can take a while to run, as it involves > reading > timezone info from /usr/share/zoneinfo. My diagnosis is that the > thread > doing the conversion yielded, and then something in ThreadPosix > (OK this is an old version, but the current version works the same) > calls gettimeofday. And apparently gettimeofday isn't re-entrant > w.r.t. > tzsetwall. > > Is there a portable (i.e., across M3 versions) way of stopping all > threadswitching activity while a call into some nasty C code is > proceeding? I don't see how one can avoid it here... Not really a portable way to do it. SchedulerPosix.DisableSwitching works when using ThreadPosix. For ThreadPThread SchedulerPosix.DisableSwitching is a no-op but the libraries should be thread-safe anyway so it probably works there too. What you really need is a lock somewhere. From mika at async.caltech.edu Tue Nov 13 21:41:40 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Tue, 13 Nov 2007 12:41:40 -0800 Subject: [M3devel] opening files under Win32 Message-ID: <200711132041.lADKfedp052254@camembert.async.caltech.edu> Hello again everyone, This may be a silly question, but does anyone out there in Modula-3-land know how to get more "Unix-like" semantics in opening files on Windows? I am using an old version of Modula-3 under "NT386GNU"/Cygwin and I'd like to open a file (for reading only) while another process has it open for writing (via FileWr.Open). Ideally, the method wouldn't change the writer at all, because I kind of like the fact that I have exclusive write access to the file (which avoids having to do all kinds of other external locking that is necessary when running the same program on Unix). I know what I'm trying to do is possible, because the Cygwin tools (like less, cp, etc.) can read the contents of the file, no problem, but when I try to open it with FileRd.Open, it doesn't work... Mika From rodney.bates at wichita.edu Fri Nov 16 01:39:18 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Thu, 15 Nov 2007 18:39:18 -0600 Subject: [M3devel] small array in modula-3? Message-ID: <473CE6B6.3030402@wichita.edu> Jay wrote: > What is the right way to have a variably sized but always small array in Modula-3? > My array will only ever have 1 or 2 elements. > I'd like to always allocate room for 2 elements, and have there be a size. > > It seems I have a choice of > > a) an "open" array Heap allocated, I presume? If the max size is only 2 elements, this is pretty extravagant, as a heap allocated open array will have 4 extra behind-the-scenes words of space overhead, plus maybe heap fragmentation, and time overhead of allocation, collection, and maybe reduced locality of reference. > b) wrap it up in a record > > I'd like so have, like: > > TYPE A = ARRAY [0..1] OF FOO; > > And be able to say: > > VAR > a : A; > > .. > a.size > FOR i := 0 TO a.size DO > do something with a[i] > > It seems I have no option but, like: > > TYPE A = RECORD > a: ARRAY[0..1] OF FOO; > size := 1; (* usually of size 1, sometimes 2 *) > END > > and then > FOR i := 0 TO a.size DO > do something with a.a[i]; > > That is "ok". Not great -- what to call the inner a? > But then furthermore, I'd like to construct constants. > It seems I am stuck with either the verbose: > > PROCEDURE F(a:A); > > F( A { ARRAY[0..1] OF FOO { .. } ); > > OR I have to come up with a name for the embedded array. > But of course, its type is really "the same" as the outer type. Ignoring the fact that the types are different linguistically (one a record type, the other an array), the types are different at a deep semantic level too. The inner array has static size, the outer one (call it a "variable array", perhaps) has dynamically changeable size, even more easily changed after it is created than a heap-allocated open array. This is a significant semantic difference, so it also makes program design sense to view them as different types. > > To wit: > > TYPE FooArray = ARRAY[0..1] OF Foo; > > TYPE FooArray = RECORD > a : FooArray; > size := 1; > END; > > F( FooArray { FooArray { .. } ); > > But I have to come up with different names. > > And I don't think I can leave out the name for the constructor, like: > > F( FooArray { { .. } ); Yes, this is a limitation in Modula-3. Ada allows value constructors to omit inner type names in cases like this, and it is convenient. But it also crosses a really major line on complexity of the language semantics, since type analysis information now flows not only upward, but also downward in expression typing. I am mostly content to live with this as one bit of the price of avoiding a horribly over complex language. Ordinary procedures can do pretty much all of the things done by exotic and complex language stuff like C++ constructors. If you don't want to write the ponderous nested value constructor, write a constructor procedure and call it. As Antony suggested, you can make it accept an open array formal, which then codes just like a simple array value constructor. You could even make it elaborate and general, e.g.: PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F = VAR LSize : CARDINAL ; VAR LResult : A ; BEGIN LSize := NUMBER ( Val ) <* ASSERT LSize <= NUMBER ( FooArray ) *> ; LResult . size := LSize ; SUBARRAY ( LResult . a , 0 , LSize ) := SUBARRAY ( Val , FIRST ( Val ) , LSize ) ; RETURN LResult END MakeF Alternatively, since your maximum element count is so small, you could write a constructor procedure that took two formals of type FOO, with at least the second one optional. (This would require a distinguished value of type FOO that would be used to mean "omitted".) And, of course, if you want to use abstraction, you can put the types, constructor procedures, and various other procedures for manipulating the variable sized array in a module, behind an interface. An additional limitation of Modula-3 in this regard, is that you can't make the type F opaque, unless you heap allocate it, which we were trying to avoid. Ada would allow you to do this, but it's another example of a convenience with high cost. It forces the equivalent of the revelation to be located in the equivalent of the interface, but makes it illegal to write client code that depends on what the revelation is. This in turn creates a source code control nightmare in a large project, because now someone who wants to make what is really a purely internal, implementation change, nevertheless has to check out the interface, and if you aren't in denial mode, that means implementers of all the client code have to go to extra trouble to somehow find out that what appears to be an interface change actually doesn't affect them after all. > > Though that might seem nice. > > Am I understanding everything? > > Have folks hit this before and there's a set of names that don't seem too lame > that folks use? > > Also -- language documentation? > Nelson's green book is excellent. > The stuff in the doc directory is very dry and scientific. > The tutorial seems more like a reference. Or maybe I didn't read it enough. > Is there better, in case I need a refresher? > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference, > but I don't think anyone could learn from the current online docs in the source tree. > > Maybe it's me, some combination of laziness and short attention span > as I age.. > > Btw, C doesn't offer a great solution here, though it offers leaving out some type names. > In C++ I could have both .size and operator[]. > Modula-3 seems to be missing operator overloading. > It's got some builtin stuff, even array assignment and equality and I think > even record assignment and equality, but it is still a bit limiting. I have raved on this before, but, having had lots of painful experience with user-defined overloading in Ada and C++, I can say with authority, that it is a programming language disaster. It interacts with just about everything else in the language, in very complicated ways, and all it buys you is saving time/energy thinking up distinct names for procedures/functions. Even this, aside from the effects on the language, is a net loss, by the time you consider readability along with writability. User-defined overloaded operators provide a slight readability benefit, _if_ used with great restraint and discipline, something you can rely on not happening. Meanwhile, the language complexity can easily double or worse. And, with the exception of compiler writers and language lawyers who spend hundreds of hours on just this, programmers don't understand the rules, not even close. > > Also, if I understand things correctly, this has long bothered me about Modula-3, > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght > objects. Like, small stack allocated structs with member functions. You seem to have > to chose between heap allocated garbage collected virtual member functions full > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- > objects don't have to be heap allocated and member functions don't have be virtual. > Or am I missing something? C++'s supposedly lighter weight forms of classes/structs with their special member functions buy nothing that plain records, plain procedures, and interfaces/modules don't already provide, again, at significant and gratuitous language complexity. Except when methods/member functions actually dispatch dynamically, there is nothing that the above won't do, and when you create a class instance as a local variable (i.e., on the stack), it is necessarily not polymorphic, that is, it can't change its "allocated" or dynamic type among various subtypes at runtime. This in turn means it can't dispatch. So, just use plain procedures, an interface and a module, and you will get everything a lighter-weight C++ class would give you. > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with > t: Type; > Type_DoSomething(t); > > in place of: > t.DoSomething(); Exactly. The special "receiver object" in a true method call has significant semantic differences from an ordinary parameter and introduces new complexities and non-orthogonalities. It has some very valuable uses too. But to then create degenerate forms of it that still carry a lot of these complexities, but are equivalent in programing power to plain old parameters is just bad program design and bad language design. Objects and methods are indeed cool for situations that utilize their semantic complexity. But it's deeply uncool to try to look superficially cool by using an inappropriately sophisticated construct when the problem doesn't justify it. Some OO proponents have gone way over the deep end here. > > - Jay > > > ------------------------------------------------------------------------ > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From jay.krell at cornell.edu Fri Nov 16 05:08:22 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:08:22 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: Rodney, thank you, this is interesting. I definitely don't want to pay for heap allocation for a tiny array. I don't know about "subarray". It looks like it takes and returns arrays. It's not a type. I ordered another copy of the Nelson book so I don't have to find mine. Good idea "MakeT" I forgot about that pattern. I'll try it out. The record and array I propose are not all that different really. I just heard of something new. Have you heard of it? "Duck typing". If it acts/quacks/walks like a duck, it is a duck. This is in very dynamic languages like Ruby. You apply object.method and if object defines something named "method", then it "must" have "the" meaning you intend. Kind of like how C++ templates "accept as parameters whatever happens to work". Operator overloading is great for strings and "math". Maybe I should try to have this language debate from scratch again..? I still am conflcted. Modules seem overly heavyweight. I don't want Module1.T, Module2.T, I want T1, T2. C++ stack structs with non virtual member functions: class Rect_t { Rect_t() : top(0), left(0), right(0), bottom(0) { } int Height() { return bottom - top; } int Width() { return right - left; } int top, left, bottom, right; }; seems "good". And it seems not really all that complicated for the compiler to flow the static type information around to resolve the functions.. Rect_t r; r.Height() => Rect_Height(&r); ..and would be inlined anyway. I do find some compelling features in Modula-3. Mainly that it compiles to native code and has OPTIONAL safety, optional garbage collection, and that the syntax of modules/interfaces allows fast compilation -- no longer reparsing the same headers over and over and over and over. Operator overloading btw..have seen "template SafeInt"? It acts like a primitive integer, but raises exceptions upon overflow. For this to work very much requires operator overloading. A point, of course, is to be able to have user defined types that can act like the built in types.. - Jay > Date: Thu, 15 Nov 2007 18:39:18 -0600> From: rodney.bates at wichita.edu> To: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > Jay wrote:> > > What is the right way to have a variably sized but always small array in Modula-3?> > My array will only ever have 1 or 2 elements.> > I'd like to always allocate room for 2 elements, and have there be a size.> >> > It seems I have a choice of> >> > a) an "open" array> > Heap allocated, I presume? If the max size is only 2 elements,> this is pretty extravagant, as a heap allocated open array will> have 4 extra behind-the-scenes words of space overhead, plus> maybe heap fragmentation, and time overhead of allocation,> collection, and maybe reduced locality of reference.> > > b) wrap it up in a record> >> > I'd like so have, like:> >> > TYPE A = ARRAY [0..1] OF FOO;> >> > And be able to say:> >> > VAR> > a : A;> >> > ..> > a.size> > FOR i := 0 TO a.size DO> > do something with a[i]> >> > It seems I have no option but, like:> >> > TYPE A = RECORD> > a: ARRAY[0..1] OF FOO;> > size := 1; (* usually of size 1, sometimes 2 *)> > END> >> > and then> > FOR i := 0 TO a.size DO> > do something with a.a[i];> >> > That is "ok". Not great -- what to call the inner a?> > But then furthermore, I'd like to construct constants.> > It seems I am stuck with either the verbose:> >> > PROCEDURE F(a:A);> >> > F( A { ARRAY[0..1] OF FOO { .. } );> >> > OR I have to come up with a name for the embedded array.> > But of course, its type is really "the same" as the outer type.> > > Ignoring the fact that the types are different linguistically> (one a record type, the other an array), the types are different> at a deep semantic level too. The inner array has static> size, the outer one (call it a "variable array", perhaps)> has dynamically changeable size, even more easily changed> after it is created than a heap-allocated open array. This> is a significant semantic difference, so it also makes program> design sense to view them as different types.> > >> > To wit:> >> > TYPE FooArray = ARRAY[0..1] OF Foo;> >> > TYPE FooArray = RECORD> > a : FooArray;> > size := 1;> > END;> >> > F( FooArray { FooArray { .. } );> >> > But I have to come up with different names.> >> > And I don't think I can leave out the name for the constructor, like:> >> > F( FooArray { { .. } );> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> to omit inner type names in cases like this, and it is convenient. But> it also crosses a really major line on complexity of the language semantics,> since type analysis information now flows not only upward, but also downward> in expression typing. I am mostly content to live with this as one bit of> the price of avoiding a horribly over complex language.> > Ordinary procedures can do pretty much all of the things done by exotic> and complex language stuff like C++ constructors. If you don't want to write> the ponderous nested value constructor, write a constructor procedure and> call it. As Antony suggested, you can make it accept an open array formal,> which then codes just like a simple array value constructor. You could even> make it elaborate and general, e.g.:> > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > = VAR LSize : CARDINAL> ; VAR LResult : A> > ; BEGIN> LSize := NUMBER ( Val )> <* ASSERT LSize <= NUMBER ( FooArray ) *>> ; LResult . size := LSize> ; SUBARRAY ( LResult . a , 0 , LSize )> := SUBARRAY ( Val , FIRST ( Val ) , LSize )> ; RETURN LResult> END MakeF> > Alternatively, since your maximum element count is so small, you could> write a constructor procedure that took two formals of type FOO, with> at least the second one optional. (This would require a distinguished> value of type FOO that would be used to mean "omitted".)> > And, of course, if you want to use abstraction, you can put the types,> constructor procedures, and various other procedures for manipulating> the variable sized array in a module, behind an interface.> > An additional limitation of Modula-3 in this regard, is that you can't> make the type F opaque, unless you heap allocate it, which we were trying> to avoid. Ada would allow you to do this, but it's another example of> a convenience with high cost. It forces the equivalent of the revelation> to be located in the equivalent of the interface, but makes it illegal> to write client code that depends on what the revelation is.> > This in turn creates a source code control nightmare in a large project,> because now someone who wants to make what is really a purely internal,> implementation change, nevertheless has to check out the interface, and> if you aren't in denial mode, that means implementers of all the client> code have to go to extra trouble to somehow find out that what appears> to be an interface change actually doesn't affect them after all.> > >> > Though that might seem nice.> >> > Am I understanding everything?> >> > Have folks hit this before and there's a set of names that don't seem too lame> > that folks use?> >> > Also -- language documentation?> > Nelson's green book is excellent.> > The stuff in the doc directory is very dry and scientific.> > The tutorial seems more like a reference. Or maybe I didn't read it enough.> > Is there better, in case I need a refresher?> > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,> > but I don't think anyone could learn from the current online docs in the source tree.> >> > Maybe it's me, some combination of laziness and short attention span> > as I age..> >> > Btw, C doesn't offer a great solution here, though it offers leaving out some type names.> > In C++ I could have both .size and operator[].> > Modula-3 seems to be missing operator overloading.> > It's got some builtin stuff, even array assignment and equality and I think> > even record assignment and equality, but it is still a bit limiting.> > > I have raved on this before, but, having had lots of painful experience with> user-defined overloading in Ada and C++, I can say with authority, that it is> a programming language disaster. It interacts with just about everything> else in the language, in very complicated ways, and all it buys you is saving> time/energy thinking up distinct names for procedures/functions. Even this,> aside from the effects on the language, is a net loss, by the time you consider> readability along with writability.> > User-defined overloaded operators provide a slight readability benefit, _if_> used with great restraint and discipline, something you can rely on not happening.> Meanwhile, the language complexity can easily double or worse. And, with the> exception of compiler writers and language lawyers who spend hundreds of hours> on just this, programmers don't understand the rules, not even close.> > >> > Also, if I understand things correctly, this has long bothered me about Modula-3,> > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght> > objects. Like, small stack allocated structs with member functions. You seem to have> > to chose between heap allocated garbage collected virtual member functions full> > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids --> > objects don't have to be heap allocated and member functions don't have be virtual.> > Or am I missing something?> > > C++'s supposedly lighter weight forms of classes/structs with their special> member functions buy nothing that plain records, plain procedures, and> interfaces/modules don't already provide, again, at significant and gratuitous> language complexity. Except when methods/member functions actually dispatch> dynamically, there is nothing that the above won't do, and when you create a> class instance as a local variable (i.e., on the stack), it is necessarily> not polymorphic, that is, it can't change its "allocated" or dynamic type> among various subtypes at runtime. This in turn means it can't dispatch.> > So, just use plain procedures, an interface and a module, and you will get> everything a lighter-weight C++ class would give you.> > > >> > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with> > t: Type;> > Type_DoSomething(t);> >> > in place of:> > t.DoSomething();> > > Exactly. The special "receiver object" in a true method call has significant> semantic differences from an ordinary parameter and introduces new complexities> and non-orthogonalities. It has some very valuable uses too.> > But to then create degenerate forms of it that still carry a lot of these> complexities, but are equivalent in programing power to plain old> parameters is just bad program design and bad language design. Objects and> methods are indeed cool for situations that utilize their semantic complexity.> But it's deeply uncool to try to look superficially cool by using an> inappropriately sophisticated construct when the problem doesn't justify it.> Some OO proponents have gone way over the deep end here.> > >> > - Jay> >> >> > ------------------------------------------------------------------------> > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! > > > > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu> > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:15:27 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:15:27 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Is it really four words? I would have thought it might need a type reference and a size, what are the others for? On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > Jay wrote: > > > What is the right way to have a variably sized but always small > array in Modula-3? > > My array will only ever have 1 or 2 elements. > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > It seems I have a choice of > > > > a) an "open" array > > Heap allocated, I presume? If the max size is only 2 elements, > this is pretty extravagant, as a heap allocated open array will > have 4 extra behind-the-scenes words of space overhead, plus > maybe heap fragmentation, and time overhead of allocation, > collection, and maybe reduced locality of reference. > > > b) wrap it up in a record > > > > I'd like so have, like: > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > And be able to say: > > > > VAR > > a : A; > > > > .. > > a.size > > FOR i := 0 TO a.size DO > > do something with a[i] > > > > It seems I have no option but, like: > > > > TYPE A = RECORD > > a: ARRAY[0..1] OF FOO; > > size := 1; (* usually of size 1, sometimes 2 *) > > END > > > > and then > > FOR i := 0 TO a.size DO > > do something with a.a[i]; > > > > That is "ok". Not great -- what to call the inner a? > > But then furthermore, I'd like to construct constants. > > It seems I am stuck with either the verbose: > > > > PROCEDURE F(a:A); > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > OR I have to come up with a name for the embedded array. > > But of course, its type is really "the same" as the outer type. > > > Ignoring the fact that the types are different linguistically > (one a record type, the other an array), the types are different > at a deep semantic level too. The inner array has static > size, the outer one (call it a "variable array", perhaps) > has dynamically changeable size, even more easily changed > after it is created than a heap-allocated open array. This > is a significant semantic difference, so it also makes program > design sense to view them as different types. > > > > > To wit: > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > TYPE FooArray = RECORD > > a : FooArray; > > size := 1; > > END; > > > > F( FooArray { FooArray { .. } ); > > > > But I have to come up with different names. > > > > And I don't think I can leave out the name for the constructor, > like: > > > > F( FooArray { { .. } ); > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > to omit inner type names in cases like this, and it is convenient. > But > it also crosses a really major line on complexity of the language > semantics, > since type analysis information now flows not only upward, but also > downward > in expression typing. I am mostly content to live with this as one > bit of > the price of avoiding a horribly over complex language. > > Ordinary procedures can do pretty much all of the things done by > exotic > and complex language stuff like C++ constructors. If you don't > want to write > the ponderous nested value constructor, write a constructor > procedure and > call it. As Antony suggested, you can make it accept an open array > formal, > which then codes just like a simple array value constructor. You > could even > make it elaborate and general, e.g.: > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > = VAR LSize : CARDINAL > ; VAR LResult : A > > ; BEGIN > LSize := NUMBER ( Val ) > <* ASSERT LSize <= NUMBER ( FooArray ) *> > ; LResult . size := LSize > ; SUBARRAY ( LResult . a , 0 , LSize ) > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > ; RETURN LResult > END MakeF > > Alternatively, since your maximum element count is so small, you could > write a constructor procedure that took two formals of type FOO, with > at least the second one optional. (This would require a distinguished > value of type FOO that would be used to mean "omitted".) > > And, of course, if you want to use abstraction, you can put the types, > constructor procedures, and various other procedures for manipulating > the variable sized array in a module, behind an interface. > > An additional limitation of Modula-3 in this regard, is that you can't > make the type F opaque, unless you heap allocate it, which we were > trying > to avoid. Ada would allow you to do this, but it's another example of > a convenience with high cost. It forces the equivalent of the > revelation > to be located in the equivalent of the interface, but makes it illegal > to write client code that depends on what the revelation is. > > This in turn creates a source code control nightmare in a large > project, > because now someone who wants to make what is really a purely > internal, > implementation change, nevertheless has to check out the interface, > and > if you aren't in denial mode, that means implementers of all the > client > code have to go to extra trouble to somehow find out that what appears > to be an interface change actually doesn't affect them after all. > > > > > Though that might seem nice. > > > > Am I understanding everything? > > > > Have folks hit this before and there's a set of names that don't > seem too lame > > that folks use? > > > > Also -- language documentation? > > Nelson's green book is excellent. > > The stuff in the doc directory is very dry and scientific. > > The tutorial seems more like a reference. Or maybe I didn't read > it enough. > > Is there better, in case I need a refresher? > > I think I got it, via Nelson's book from memory (wonder if I can > find mine..) and the reference, > > but I don't think anyone could learn from the current online docs > in the source tree. > > > > Maybe it's me, some combination of laziness and short attention span > > as I age.. > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > In C++ I could have both .size and operator[]. > > Modula-3 seems to be missing operator overloading. > > It's got some builtin stuff, even array assignment and equality > and I think > > even record assignment and equality, but it is still a bit > limiting. > > > I have raved on this before, but, having had lots of painful > experience with > user-defined overloading in Ada and C++, I can say with authority, > that it is > a programming language disaster. It interacts with just about > everything > else in the language, in very complicated ways, and all it buys you > is saving > time/energy thinking up distinct names for procedures/functions. > Even this, > aside from the effects on the language, is a net loss, by the time > you consider > readability along with writability. > > User-defined overloaded operators provide a slight readability > benefit, _if_ > used with great restraint and discipline, something you can rely on > not happening. > Meanwhile, the language complexity can easily double or worse. > And, with the > exception of compiler writers and language lawyers who spend > hundreds of hours > on just this, programmers don't understand the rules, not even close. > > > > > Also, if I understand things correctly, this has long bothered me > about Modula-3, > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > objects. Like, small stack allocated structs with member > functions. You seem to have > > to chose between heap allocated garbage collected virtual member > functions full > > featured objects, or featureless dumb structs. It's nice how C++ > allow hybrids -- > > objects don't have to be heap allocated and member functions > don't have be virtual. > > Or am I missing something? > > > C++'s supposedly lighter weight forms of classes/structs with their > special > member functions buy nothing that plain records, plain procedures, and > interfaces/modules don't already provide, again, at significant and > gratuitous > language complexity. Except when methods/member functions actually > dispatch > dynamically, there is nothing that the above won't do, and when you > create a > class instance as a local variable (i.e., on the stack), it is > necessarily > not polymorphic, that is, it can't change its "allocated" or > dynamic type > among various subtypes at runtime. This in turn means it can't > dispatch. > > So, just use plain procedures, an interface and a module, and you > will get > everything a lighter-weight C++ class would give you. > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal > with > > t: Type; > > Type_DoSomething(t); > > > > in place of: > > t.DoSomething(); > > > Exactly. The special "receiver object" in a true method call has > significant > semantic differences from an ordinary parameter and introduces new > complexities > and non-orthogonalities. It has some very valuable uses too. > > But to then create degenerate forms of it that still carry a lot of > these > complexities, but are equivalent in programing power to plain old > parameters is just bad program design and bad language design. > Objects and > methods are indeed cool for situations that utilize their semantic > complexity. > But it's deeply uncool to try to look superficially cool by using an > inappropriately sophisticated construct when the problem doesn't > justify it. > Some OO proponents have gone way over the deep end here. > > > > > - Jay > > > > > > > ---------------------------------------------------------------------- > -- > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! trial.aspx?s_cid=wl_hotmailnews> > > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu From darko at darko.org Fri Nov 16 05:29:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:29:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Not sure what the problem is with modules. If you want to avoid the dot you can name the type something unique then import that type name. You can create an interface with all the nice type names and import all those names in modules by adding an EXPORTS clause too. Personally I think M3, with a couple of extensions, wouldn't need unsafe anything. The unsafe features are there mostly because of legacy interfaces. I forget the name but the folk who wrote an OS in M3 found it very effective with only couple of minor points with regards to interfacing to C code they built on top of, I think one of them was being able to pass NIL to a VAR parameter, which is a common C idiom (and an annoying one for M3 users who then can't use VAR). On 15/11/2007, at 8:08 PM, Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book > so I don't have to find mine. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". > If it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named > "method", then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever > happens to work". > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; > > seems "good". > > And it seems not really all that complicated for the compiler to > flow the static type information around to resolve the functions.. > > Rect_t r; > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > I do find some compelling features in Modula-3. Mainly that it > compiles to native code and has OPTIONAL safety, optional garbage > collection, and that the syntax of modules/interfaces allows fast > compilation -- no longer reparsing the same headers over and over > and over and over. > > Operator overloading btw..have seen "template SafeInt"? It acts > like a primitive integer, but raises exceptions upon overflow. > For this to work very much requires operator overloading. > > A point, of course, is to be able to have user defined types that > can act like the built in types.. > > - Jay > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > From: rodney.bates at wichita.edu > > To: m3devel at elegosoft.com > > Subject: Re: [M3devel] small array in modula-3? > > > > Jay wrote: > > > > > What is the right way to have a variably sized but always small > array in Modula-3? > > > My array will only ever have 1 or 2 elements. > > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > > > It seems I have a choice of > > > > > > a) an "open" array > > > > Heap allocated, I presume? If the max size is only 2 elements, > > this is pretty extravagant, as a heap allocated open array will > > have 4 extra behind-the-scenes words of space overhead, plus > > maybe heap fragmentation, and time overhead of allocation, > > collection, and maybe reduced locality of reference. > > > > > b) wrap it up in a record > > > > > > I'd like so have, like: > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > And be able to say: > > > > > > VAR > > > a : A; > > > > > > .. > > > a.size > > > FOR i := 0 TO a.size DO > > > do something with a[i] > > > > > > It seems I have no option but, like: > > > > > > TYPE A = RECORD > > > a: ARRAY[0..1] OF FOO; > > > size := 1; (* usually of size 1, sometimes 2 *) > > > END > > > > > > and then > > > FOR i := 0 TO a.size DO > > > do something with a.a[i]; > > > > > > That is "ok". Not great -- what to call the inner a? > > > But then furthermore, I'd like to construct constants. > > > It seems I am stuck with either the verbose: > > > > > > PROCEDURE F(a:A); > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > OR I have to come up with a name for the embedded array. > > > But of course, its type is really "the same" as the outer type. > > > > > > Ignoring the fact that the types are different linguistically > > (one a record type, the other an array), the types are different > > at a deep semantic level too. The inner array has static > > size, the outer one (call it a "variable array", perhaps) > > has dynamically changeable size, even more easily changed > > after it is created than a heap-allocated open array. This > > is a significant semantic difference, so it also makes program > > design sense to view them as different types. > > > > > > > > To wit: > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > TYPE FooArray = RECORD > > > a : FooArray; > > > size := 1; > > > END; > > > > > > F( FooArray { FooArray { .. } ); > > > > > > But I have to come up with different names. > > > > > > And I don't think I can leave out the name for the constructor, > like: > > > > > > F( FooArray { { .. } ); > > > > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > > to omit inner type names in cases like this, and it is > convenient. But > > it also crosses a really major line on complexity of the language > semantics, > > since type analysis information now flows not only upward, but > also downward > > in expression typing. I am mostly content to live with this as > one bit of > > the price of avoiding a horribly over complex language. > > > > Ordinary procedures can do pretty much all of the things done by > exotic > > and complex language stuff like C++ constructors. If you don't > want to write > > the ponderous nested value constructor, write a constructor > procedure and > > call it. As Antony suggested, you can make it accept an open > array formal, > > which then codes just like a simple array value constructor. You > could even > > make it elaborate and general, e.g.: > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > = VAR LSize : CARDINAL > > ; VAR LResult : A > > > > ; BEGIN > > LSize := NUMBER ( Val ) > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > ; LResult . size := LSize > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > ; RETURN LResult > > END MakeF > > > > Alternatively, since your maximum element count is so small, you > could > > write a constructor procedure that took two formals of type FOO, > with > > at least the second one optional. (This would require a > distinguished > > value of type FOO that would be used to mean "omitted".) > > > > And, of course, if you want to use abstraction, you can put the > types, > > constructor procedures, and various other procedures for > manipulating > > the variable sized array in a module, behind an interface. > > > > An additional limitation of Modula-3 in this regard, is that you > can't > > make the type F opaque, unless you heap allocate it, which we > were trying > > to avoid. Ada would allow you to do this, but it's another > example of > > a convenience with high cost. It forces the equivalent of the > revelation > > to be located in the equivalent of the interface, but makes it > illegal > > to write client code that depends on what the revelation is. > > > > This in turn creates a source code control nightmare in a large > project, > > because now someone who wants to make what is really a purely > internal, > > implementation change, nevertheless has to check out the > interface, and > > if you aren't in denial mode, that means implementers of all the > client > > code have to go to extra trouble to somehow find out that what > appears > > to be an interface change actually doesn't affect them after all. > > > > > > > > Though that might seem nice. > > > > > > Am I understanding everything? > > > > > > Have folks hit this before and there's a set of names that > don't seem too lame > > > that folks use? > > > > > > Also -- language documentation? > > > Nelson's green book is excellent. > > > The stuff in the doc directory is very dry and scientific. > > > The tutorial seems more like a reference. Or maybe I didn't > read it enough. > > > Is there better, in case I need a refresher? > > > I think I got it, via Nelson's book from memory (wonder if I > can find mine..) and the reference, > > > but I don't think anyone could learn from the current online > docs in the source tree. > > > > > > Maybe it's me, some combination of laziness and short attention > span > > > as I age.. > > > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > > In C++ I could have both .size and operator[]. > > > Modula-3 seems to be missing operator overloading. > > > It's got some builtin stuff, even array assignment and equality > and I think > > > even record assignment and equality, but it is still a bit > limiting. > > > > > > I have raved on this before, but, having had lots of painful > experience with > > user-defined overloading in Ada and C++, I can say with > authority, that it is > > a programming language disaster. It interacts with just about > everything > > else in the language, in very complicated ways, and all it buys > you is saving > > time/energy thinking up distinct names for procedures/functions. > Even this, > > aside from the effects on the language, is a net loss, by the > time you consider > > readability along with writability. > > > > User-defined overloaded operators provide a slight readability > benefit, _if_ > > used with great restraint and discipline, something you can rely > on not happening. > > Meanwhile, the language complexity can easily double or worse. > And, with the > > exception of compiler writers and language lawyers who spend > hundreds of hours > > on just this, programmers don't understand the rules, not even > close. > > > > > > > > Also, if I understand things correctly, this has long bothered > me about Modula-3, > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > > objects. Like, small stack allocated structs with member > functions. You seem to have > > > to chose between heap allocated garbage collected virtual > member functions full > > > featured objects, or featureless dumb structs. It's nice how C+ > + allow hybrids -- > > > objects don't have to be heap allocated and member functions > don't have be virtual. > > > Or am I missing something? > > > > > > C++'s supposedly lighter weight forms of classes/structs with > their special > > member functions buy nothing that plain records, plain > procedures, and > > interfaces/modules don't already provide, again, at significant > and gratuitous > > language complexity. Except when methods/member functions > actually dispatch > > dynamically, there is nothing that the above won't do, and when > you create a > > class instance as a local variable (i.e., on the stack), it is > necessarily > > not polymorphic, that is, it can't change its "allocated" or > dynamic type > > among various subtypes at runtime. This in turn means it can't > dispatch. > > > > So, just use plain procedures, an interface and a module, and you > will get > > everything a lighter-weight C++ class would give you. > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > deal with > > > t: Type; > > > Type_DoSomething(t); > > > > > > in place of: > > > t.DoSomething(); > > > > > > Exactly. The special "receiver object" in a true method call has > significant > > semantic differences from an ordinary parameter and introduces > new complexities > > and non-orthogonalities. It has some very valuable uses too. > > > > But to then create degenerate forms of it that still carry a lot > of these > > complexities, but are equivalent in programing power to plain old > > parameters is just bad program design and bad language design. > Objects and > > methods are indeed cool for situations that utilize their > semantic complexity. > > But it's deeply uncool to try to look superficially cool by using an > > inappropriately sophisticated construct when the problem doesn't > justify it. > > Some OO proponents have gone way over the deep end here. > > > > > > > > - Jay > > > > > > > > > > ---------------------------------------------------------------------- > -- > > > Boo! Scare away worms, viruses and so much more! Try Windows > Live OneCare! Try now! > > s_cid=wl_hotmailnews> > > > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! From jay.krell at cornell.edu Fri Nov 16 05:40:40 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:40:40 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: But if I don't want to pay for heap allocation, I can't say: VAR T: v; v.DoSomething(); Only IMPORT T FROM M; VAR T: v; M.DoSomething(v); Right? SPIN I think you mean. Anyone build it and bring it up? I was long curious but never did.. - Jay > CC: m3devel at elegosoft.com> From: darko at darko.org> Subject: Re: [M3devel] small array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.krell at cornell.edu> > Not sure what the problem is with modules. If you want to avoid the > dot you can name the type something unique then import that type > name. You can create an interface with all the nice type names and > import all those names in modules by adding an EXPORTS clause too.> > Personally I think M3, with a couple of extensions, wouldn't need > unsafe anything. The unsafe features are there mostly because of > legacy interfaces. I forget the name but the folk who wrote an OS in > M3 found it very effective with only couple of minor points with > regards to interfacing to C code they built on top of, I think one of > them was being able to pass NIL to a VAR parameter, which is a common > C idiom (and an annoying one for M3 users who then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > > Rodney, thank you, this is interesting.> > I definitely don't want to pay for heap allocation for a tiny array.> > I don't know about "subarray". It looks like it takes and returns > > arrays. It's not a type. I ordered another copy of the Nelson book > > so I don't have to find mine.> >> > Good idea "MakeT" I forgot about that pattern. I'll try it out.> >> > The record and array I propose are not all that different really.> > I just heard of something new. Have you heard of it? "Duck typing". > > If it acts/quacks/walks like a duck, it is a duck.> > This is in very dynamic languages like Ruby.> > You apply object.method and if object defines something named > > "method", then it "must" have "the" meaning you intend.> > Kind of like how C++ templates "accept as parameters whatever > > happens to work".> >> > Operator overloading is great for strings and "math".> >> > Maybe I should try to have this language debate from scratch again..?> >> > I still am conflcted.> >> > Modules seem overly heavyweight.> > I don't want Module1.T, Module2.T, I want T1, T2.> >> > C++ stack structs with non virtual member functions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(0) { }> >> > int Height() { return bottom - top; }> > int Width() { return right - left; }> > int top, left, bottom, right;> > };> >> > seems "good".> >> > And it seems not really all that complicated for the compiler to > > flow the static type information around to resolve the functions..> >> > Rect_t r;> > r.Height() => Rect_Height(&r); ..and would be inlined anyway.> >> > I do find some compelling features in Modula-3. Mainly that it > > compiles to native code and has OPTIONAL safety, optional garbage > > collection, and that the syntax of modules/interfaces allows fast > > compilation -- no longer reparsing the same headers over and over > > and over and over.> >> > Operator overloading btw..have seen "template SafeInt"? It acts > > like a primitive integer, but raises exceptions upon overflow.> > For this to work very much requires operator overloading.> >> > A point, of course, is to be able to have user defined types that > > can act like the built in types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:18 -0600> > > From: rodney.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > Subject: Re: [M3devel] small array in modula-3?> > >> > > Jay wrote:> > >> > > > What is the right way to have a variably sized but always small > > array in Modula-3?> > > > My array will only ever have 1 or 2 elements.> > > > I'd like to always allocate room for 2 elements, and have there > > be a size.> > > >> > > > It seems I have a choice of> > > >> > > > a) an "open" array> > >> > > Heap allocated, I presume? If the max size is only 2 elements,> > > this is pretty extravagant, as a heap allocated open array will> > > have 4 extra behind-the-scenes words of space overhead, plus> > > maybe heap fragmentation, and time overhead of allocation,> > > collection, and maybe reduced locality of reference.> > >> > > > b) wrap it up in a record> > > >> > > > I'd like so have, like:> > > >> > > > TYPE A = ARRAY [0..1] OF FOO;> > > >> > > > And be able to say:> > > >> > > > VAR> > > > a : A;> > > >> > > > ..> > > > a.size> > > > FOR i := 0 TO a.size DO> > > > do something with a[i]> > > >> > > > It seems I have no option but, like:> > > >> > > > TYPE A = RECORD> > > > a: ARRAY[0..1] OF FOO;> > > > size := 1; (* usually of size 1, sometimes 2 *)> > > > END> > > >> > > > and then> > > > FOR i := 0 TO a.size DO> > > > do something with a.a[i];> > > >> > > > That is "ok". Not great -- what to call the inner a?> > > > But then furthermore, I'd like to construct constants.> > > > It seems I am stuck with either the verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name for the embedded array.> > > > But of course, its type is really "the same" as the outer type.> > >> > >> > > Ignoring the fact that the types are different linguistically> > > (one a record type, the other an array), the types are different> > > at a deep semantic level too. The inner array has static> > > size, the outer one (call it a "variable array", perhaps)> > > has dynamically changeable size, even more easily changed> > > after it is created than a heap-allocated open array. This> > > is a significant semantic difference, so it also makes program> > > design sense to view them as different types.> > >> > > >> > > > To wit:> > > >> > > > TYPE FooArray = ARRAY[0..1] OF Foo;> > > >> > > > TYPE FooArray = RECORD> > > > a : FooArray;> > > > size := 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );> > > >> > > > But I have to come up with different names.> > > >> > > > And I don't think I can leave out the name for the constructor, > > like:> > > >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> > > to omit inner type names in cases like this, and it is > > convenient. But> > > it also crosses a really major line on complexity of the language > > semantics,> > > since type analysis information now flows not only upward, but > > also downward> > > in expression typing. I am mostly content to live with this as > > one bit of> > > the price of avoiding a horribly over complex language.> > >> > > Ordinary procedures can do pretty much all of the things done by > > exotic> > > and complex language stuff like C++ constructors. If you don't > > want to write> > > the ponderous nested value constructor, write a constructor > > procedure and> > > call it. As Antony suggested, you can make it accept an open > > array formal,> > > which then codes just like a simple array value constructor. You > > could even> > > make it elaborate and general, e.g.:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = VAR LSize : CARDINAL> > > ; VAR LResult : A> > >> > > ; BEGIN> > > LSize := NUMBER ( Val )> > > <* ASSERT LSize <= NUMBER ( FooArray ) *>> > > ; LResult . size := LSize> > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > := SUBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RETURN LResult> > > END MakeF> > >> > > Alternatively, since your maximum element count is so small, you > > could> > > write a constructor procedure that took two formals of type FOO, > > with> > > at least the second one optional. (This would require a > > distinguished> > > value of type FOO that would be used to mean "omitted".)> > >> > > And, of course, if you want to use abstraction, you can put the > > types,> > > constructor procedures, and various other procedures for > > manipulating> > > the variable sized array in a module, behind an interface.> > >> > > An additional limitation of Modula-3 in this regard, is that you > > can't> > > make the type F opaque, unless you heap allocate it, which we > > were trying> > > to avoid. Ada would allow you to do this, but it's another > > example of> > > a convenience with high cost. It forces the equivalent of the > > revelation> > > to be located in the equivalent of the interface, but makes it > > illegal> > > to write client code that depends on what the revelation is.> > >> > > This in turn creates a source code control nightmare in a large > > project,> > > because now someone who wants to make what is really a purely > > internal,> > > implementation change, nevertheless has to check out the > > interface, and> > > if you aren't in denial mode, that means implementers of all the > > client> > > code have to go to extra trouble to somehow find out that what > > appears> > > to be an interface change actually doesn't affect them after all.> > >> > > >> > > > Though that might seem nice.> > > >> > > > Am I understanding everything?> > > >> > > > Have folks hit this before and there's a set of names that > > don't seem too lame> > > > that folks use?> > > >> > > > Also -- language documentation?> > > > Nelson's green book is excellent.> > > > The stuff in the doc directory is very dry and scientific.> > > > The tutorial seems more like a reference. Or maybe I didn't > > read it enough.> > > > Is there better, in case I need a refresher?> > > > I think I got it, via Nelson's book from memory (wonder if I > > can find mine..) and the reference,> > > > but I don't think anyone could learn from the current online > > docs in the source tree.> > > >> > > > Maybe it's me, some combination of laziness and short attention > > span> > > > as I age..> > > >> > > > Btw, C doesn't offer a great solution here, though it offers > > leaving out some type names.> > > > In C++ I could have both .size and operator[].> > > > Modula-3 seems to be missing operator overloading.> > > > It's got some builtin stuff, even array assignment and equality > > and I think> > > > even record assignment and equality, but it is still a bit > > limiting.> > >> > >> > > I have raved on this before, but, having had lots of painful > > experience with> > > user-defined overloading in Ada and C++, I can say with > > authority, that it is> > > a programming language disaster. It interacts with just about > > everything> > > else in the language, in very complicated ways, and all it buys > > you is saving> > > time/energy thinking up distinct names for procedures/functions. > > Even this,> > > aside from the effects on the language, is a net loss, by the > > time you consider> > > readability along with writability.> > >> > > User-defined overloaded operators provide a slight readability > > benefit, _if_> > > used with great restraint and discipline, something you can rely > > on not happening.> > > Meanwhile, the language complexity can easily double or worse. > > And, with the> > > exception of compiler writers and language lawyers who spend > > hundreds of hours> > > on just this, programmers don't understand the rules, not even > > close.> > >> > > >> > > > Also, if I understand things correctly, this has long bothered > > me about Modula-3,> > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > > objects. Like, small stack allocated structs with member > > functions. You seem to have> > > > to chose between heap allocated garbage collected virtual > > member functions full> > > > featured objects, or featureless dumb structs. It's nice how C+ > > + allow hybrids --> > > > objects don't have to be heap allocated and member functions > > don't have be virtual.> > > > Or am I missing something?> > >> > >> > > C++'s supposedly lighter weight forms of classes/structs with > > their special> > > member functions buy nothing that plain records, plain > > procedures, and> > > interfaces/modules don't already provide, again, at significant > > and gratuitous> > > language complexity. Except when methods/member functions > > actually dispatch> > > dynamically, there is nothing that the above won't do, and when > > you create a> > > class instance as a local variable (i.e., on the stack), it is > > necessarily> > > not polymorphic, that is, it can't change its "allocated" or > > dynamic type> > > among various subtypes at runtime. This in turn means it can't > > dispatch.> > >> > > So, just use plain procedures, an interface and a module, and you > > will get> > > everything a lighter-weight C++ class would give you.> > >> > >> > > >> > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > deal with> > > > t: Type;> > > > Type_DoSomething(t);> > > >> > > > in place of:> > > > t.DoSomething();> > >> > >> > > Exactly. The special "receiver object" in a true method call has > > significant> > > semantic differences from an ordinary parameter and introduces > > new complexities> > > and non-orthogonalities. It has some very valuable uses too.> > >> > > But to then create degenerate forms of it that still carry a lot > > of these> > > complexities, but are equivalent in programing power to plain old> > > parameters is just bad program design and bad language design. > > Objects and> > > methods are indeed cool for situations that utilize their > > semantic complexity.> > > But it's deeply uncool to try to look superficially cool by using an> > > inappropriately sophisticated construct when the problem doesn't > > justify it.> > > Some OO proponents have gone way over the deep end here.> > >> > > >> > > > - Jay> > > >> > > >> > > > > > ---------------------------------------------------------------------- > > --> > > > Boo! Scare away worms, viruses and so much more! Try Windows > > Live OneCare! Try now!> > > > s_cid=wl_hotmailnews>> > >> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> >> >> > Boo! Scare away worms, viruses and so much more! Try Windows Live > > OneCare! Try now!> _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:54:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:54:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: <430632D5-F522-4B12-BED7-FB65291896BD@darko.org> M3 doesn't have class methods or what have you but you can give v a method which isn't instance specific which is the same diff and doesn't really cost anything. If you read "How M3 Got Its Spots" I think the chapter is called they make a reference to this, and not a very kind one. I don't think they liked the idea. On 15/11/2007, at 8:40 PM, Jay wrote: > But if I don't want to pay for heap allocation, I can't say: > > VAR T: v; > > v.DoSomething(); > > Only IMPORT T FROM M; > > VAR T: v; > > M.DoSomething(v); > > Right? > > SPIN I think you mean. > Anyone build it and bring it up? I was long curious but never did.. > > - Jay > > > > > CC: m3devel at elegosoft.com > > From: darko at darko.org > > Subject: Re: [M3devel] small array in modula-3? > > Date: Thu, 15 Nov 2007 20:29:06 -0800 > > To: jay.krell at cornell.edu > > > > Not sure what the problem is with modules. If you want to avoid the > > dot you can name the type something unique then import that type > > name. You can create an interface with all the nice type names and > > import all those names in modules by adding an EXPORTS clause too. > > > > Personally I think M3, with a couple of extensions, wouldn't need > > unsafe anything. The unsafe features are there mostly because of > > legacy interfaces. I forget the name but the folk who wrote an OS in > > M3 found it very effective with only couple of minor points with > > regards to interfacing to C code they built on top of, I think > one of > > them was being able to pass NIL to a VAR parameter, which is a > common > > C idiom (and an annoying one for M3 users who then can't use VAR). > > > > > > On 15/11/2007, at 8:08 PM, Jay wrote: > > > > > Rodney, thank you, this is interesting. > > > I definitely don't want to pay for heap allocation for a tiny > array. > > > I don't know about "subarray". It looks like it takes and returns > > > arrays. It's not a type. I ordered another copy of the Nelson book > > > so I don't have to find mine. > > > > > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > > > > > The record and array I propose are not all that different really. > > > I just heard of something new. Have you heard of it? "Duck > typing". > > > If it acts/quacks/walks like a duck, it is a duck. > > > This is in very dynamic languages like Ruby. > > > You apply object.method and if object defines something named > > > "method", then it "must" have "the" meaning you intend. > > > Kind of like how C++ templates "accept as parameters whatever > > > happens to work". > > > > > > Operator overloading is great for strings and "math". > > > > > > Maybe I should try to have this language debate from scratch > again..? > > > > > > I still am conflcted. > > > > > > Modules seem overly heavyweight. > > > I don't want Module1.T, Module2.T, I want T1, T2. > > > > > > C++ stack structs with non virtual member functions: > > > class Rect_t > > > { > > > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > > > > > int Height() { return bottom - top; } > > > int Width() { return right - left; } > > > int top, left, bottom, right; > > > }; > > > > > > seems "good". > > > > > > And it seems not really all that complicated for the compiler to > > > flow the static type information around to resolve the functions.. > > > > > > Rect_t r; > > > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > > > > > I do find some compelling features in Modula-3. Mainly that it > > > compiles to native code and has OPTIONAL safety, optional garbage > > > collection, and that the syntax of modules/interfaces allows fast > > > compilation -- no longer reparsing the same headers over and over > > > and over and over. > > > > > > Operator overloading btw..have seen "template SafeInt"? It acts > > > like a primitive integer, but raises exceptions upon overflow. > > > For this to work very much requires operator overloading. > > > > > > A point, of course, is to be able to have user defined types that > > > can act like the built in types.. > > > > > > - Jay > > > > > > > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > > > From: rodney.bates at wichita.edu > > > > To: m3devel at elegosoft.com > > > > Subject: Re: [M3devel] small array in modula-3? > > > > > > > > Jay wrote: > > > > > > > > > What is the right way to have a variably sized but always > small > > > array in Modula-3? > > > > > My array will only ever have 1 or 2 elements. > > > > > I'd like to always allocate room for 2 elements, and have > there > > > be a size. > > > > > > > > > > It seems I have a choice of > > > > > > > > > > a) an "open" array > > > > > > > > Heap allocated, I presume? If the max size is only 2 elements, > > > > this is pretty extravagant, as a heap allocated open array will > > > > have 4 extra behind-the-scenes words of space overhead, plus > > > > maybe heap fragmentation, and time overhead of allocation, > > > > collection, and maybe reduced locality of reference. > > > > > > > > > b) wrap it up in a record > > > > > > > > > > I'd like so have, like: > > > > > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > > > > > And be able to say: > > > > > > > > > > VAR > > > > > a : A; > > > > > > > > > > .. > > > > > a.size > > > > > FOR i := 0 TO a.size DO > > > > > do something with a[i] > > > > > > > > > > It seems I have no option but, like: > > > > > > > > > > TYPE A = RECORD > > > > > a: ARRAY[0..1] OF FOO; > > > > > size := 1; (* usually of size 1, sometimes 2 *) > > > > > END > > > > > > > > > > and then > > > > > FOR i := 0 TO a.size DO > > > > > do something with a.a[i]; > > > > > > > > > > That is "ok". Not great -- what to call the inner a? > > > > > But then furthermore, I'd like to construct constants. > > > > > It seems I am stuck with either the verbose: > > > > > > > > > > PROCEDURE F(a:A); > > > > > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > > > > > OR I have to come up with a name for the embedded array. > > > > > But of course, its type is really "the same" as the outer > type. > > > > > > > > > > > > Ignoring the fact that the types are different linguistically > > > > (one a record type, the other an array), the types are different > > > > at a deep semantic level too. The inner array has static > > > > size, the outer one (call it a "variable array", perhaps) > > > > has dynamically changeable size, even more easily changed > > > > after it is created than a heap-allocated open array. This > > > > is a significant semantic difference, so it also makes program > > > > design sense to view them as different types. > > > > > > > > > > > > > > To wit: > > > > > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > > > > > TYPE FooArray = RECORD > > > > > a : FooArray; > > > > > size := 1; > > > > > END; > > > > > > > > > > F( FooArray { FooArray { .. } ); > > > > > > > > > > But I have to come up with different names. > > > > > > > > > > And I don't think I can leave out the name for the > constructor, > > > like: > > > > > > > > > > F( FooArray { { .. } ); > > > > > > > > > > > > Yes, this is a limitation in Modula-3. Ada allows value > constructors > > > > to omit inner type names in cases like this, and it is > > > convenient. But > > > > it also crosses a really major line on complexity of the > language > > > semantics, > > > > since type analysis information now flows not only upward, but > > > also downward > > > > in expression typing. I am mostly content to live with this as > > > one bit of > > > > the price of avoiding a horribly over complex language. > > > > > > > > Ordinary procedures can do pretty much all of the things done by > > > exotic > > > > and complex language stuff like C++ constructors. If you don't > > > want to write > > > > the ponderous nested value constructor, write a constructor > > > procedure and > > > > call it. As Antony suggested, you can make it accept an open > > > array formal, > > > > which then codes just like a simple array value constructor. You > > > could even > > > > make it elaborate and general, e.g.: > > > > > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > > > > > = VAR LSize : CARDINAL > > > > ; VAR LResult : A > > > > > > > > ; BEGIN > > > > LSize := NUMBER ( Val ) > > > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > > > ; LResult . size := LSize > > > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > > > ; RETURN LResult > > > > END MakeF > > > > > > > > Alternatively, since your maximum element count is so small, you > > > could > > > > write a constructor procedure that took two formals of type FOO, > > > with > > > > at least the second one optional. (This would require a > > > distinguished > > > > value of type FOO that would be used to mean "omitted".) > > > > > > > > And, of course, if you want to use abstraction, you can put the > > > types, > > > > constructor procedures, and various other procedures for > > > manipulating > > > > the variable sized array in a module, behind an interface. > > > > > > > > An additional limitation of Modula-3 in this regard, is that you > > > can't > > > > make the type F opaque, unless you heap allocate it, which we > > > were trying > > > > to avoid. Ada would allow you to do this, but it's another > > > example of > > > > a convenience with high cost. It forces the equivalent of the > > > revelation > > > > to be located in the equivalent of the interface, but makes it > > > illegal > > > > to write client code that depends on what the revelation is. > > > > > > > > This in turn creates a source code control nightmare in a large > > > project, > > > > because now someone who wants to make what is really a purely > > > internal, > > > > implementation change, nevertheless has to check out the > > > interface, and > > > > if you aren't in denial mode, that means implementers of all the > > > client > > > > code have to go to extra trouble to somehow find out that what > > > appears > > > > to be an interface change actually doesn't affect them after > all. > > > > > > > > > > > > > > Though that might seem nice. > > > > > > > > > > Am I understanding everything? > > > > > > > > > > Have folks hit this before and there's a set of names that > > > don't seem too lame > > > > > that folks use? > > > > > > > > > > Also -- language documentation? > > > > > Nelson's green book is excellent. > > > > > The stuff in the doc directory is very dry and scientific. > > > > > The tutorial seems more like a reference. Or maybe I didn't > > > read it enough. > > > > > Is there better, in case I need a refresher? > > > > > I think I got it, via Nelson's book from memory (wonder if I > > > can find mine..) and the reference, > > > > > but I don't think anyone could learn from the current online > > > docs in the source tree. > > > > > > > > > > Maybe it's me, some combination of laziness and short > attention > > > span > > > > > as I age.. > > > > > > > > > > Btw, C doesn't offer a great solution here, though it offers > > > leaving out some type names. > > > > > In C++ I could have both .size and operator[]. > > > > > Modula-3 seems to be missing operator overloading. > > > > > It's got some builtin stuff, even array assignment and > equality > > > and I think > > > > > even record assignment and equality, but it is still a bit > > > limiting. > > > > > > > > > > > > I have raved on this before, but, having had lots of painful > > > experience with > > > > user-defined overloading in Ada and C++, I can say with > > > authority, that it is > > > > a programming language disaster. It interacts with just about > > > everything > > > > else in the language, in very complicated ways, and all it buys > > > you is saving > > > > time/energy thinking up distinct names for procedures/functions. > > > Even this, > > > > aside from the effects on the language, is a net loss, by the > > > time you consider > > > > readability along with writability. > > > > > > > > User-defined overloaded operators provide a slight readability > > > benefit, _if_ > > > > used with great restraint and discipline, something you can rely > > > on not happening. > > > > Meanwhile, the language complexity can easily double or worse. > > > And, with the > > > > exception of compiler writers and language lawyers who spend > > > hundreds of hours > > > > on just this, programmers don't understand the rules, not even > > > close. > > > > > > > > > > > > > > Also, if I understand things correctly, this has long bothered > > > me about Modula-3, > > > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > > for lighter wieght > > > > > objects. Like, small stack allocated structs with member > > > functions. You seem to have > > > > > to chose between heap allocated garbage collected virtual > > > member functions full > > > > > featured objects, or featureless dumb structs. It's nice > how C+ > > > + allow hybrids -- > > > > > objects don't have to be heap allocated and member functions > > > don't have be virtual. > > > > > Or am I missing something? > > > > > > > > > > > > C++'s supposedly lighter weight forms of classes/structs with > > > their special > > > > member functions buy nothing that plain records, plain > > > procedures, and > > > > interfaces/modules don't already provide, again, at significant > > > and gratuitous > > > > language complexity. Except when methods/member functions > > > actually dispatch > > > > dynamically, there is nothing that the above won't do, and when > > > you create a > > > > class instance as a local variable (i.e., on the stack), it is > > > necessarily > > > > not polymorphic, that is, it can't change its "allocated" or > > > dynamic type > > > > among various subtypes at runtime. This in turn means it can't > > > dispatch. > > > > > > > > So, just use plain procedures, an interface and a module, and > you > > > will get > > > > everything a lighter-weight C++ class would give you. > > > > > > > > > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > > deal with > > > > > t: Type; > > > > > Type_DoSomething(t); > > > > > > > > > > in place of: > > > > > t.DoSomething(); > > > > > > > > > > > > Exactly. The special "receiver object" in a true method call has > > > significant > > > > semantic differences from an ordinary parameter and introduces > > > new complexities > > > > and non-orthogonalities. It has some very valuable uses too. > > > > > > > > But to then create degenerate forms of it that still carry a lot > > > of these > > > > complexities, but are equivalent in programing power to plain > old > > > > parameters is just bad program design and bad language design. > > > Objects and > > > > methods are indeed cool for situations that utilize their > > > semantic complexity. > > > > But it's deeply uncool to try to look superficially cool by > using an > > > > inappropriately sophisticated construct when the problem doesn't > > > justify it. > > > > Some OO proponents have gone way over the deep end here. > > > > > > > > > > > > > > - Jay > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > -- > > > > > Boo! Scare away worms, viruses and so much more! Try Windows > > > Live OneCare! Try now! > > > > > > s_cid=wl_hotmailnews> > > > > > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > > > OneCare! Try now! > > > > > Climb to the top of the charts! Play Star Shuffle: the word > scramble challenge with star power. Play Now! From lemming at henning-thielemann.de Fri Nov 16 09:42:26 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 09:42:26 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Jay wrote: > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. This way generic modules would not work. They require that the parameter modules have exactly the same interface. 'T' everywhere looked strange to me at first, but I get used to it and now I also use that naming in other languages (namely Haskell). Btw. Haskell has a restricted kind of operator overloading by so called type classes. Although sometimes useful, people tend to overuse it. From rodney.bates at wichita.edu Fri Nov 16 22:42:35 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:42:35 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <473E0ECB.504@wichita.edu> Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book so I > don't have to find mine. SUBARRAY is an expression. It accesses a subrange of the elements of an array. You can use it on the left of assignment or on the right. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". If > it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named "method", > then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever happens to > work". This kind of thinking about software will work sometimes, but it's a recipe for disaster overall. It's quite too hard already to get the bugs out of software without people invoking things with only a guess what they mean. "If it looks like a duck ..." is absolutely not reliable in software. That's also the problem with over complex languages: people write massive amounts of code with only guesses about what the language constructs mean. > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. ; IMPORT Module1 ; IMPORT Module2 ... ; TYPE T1 = Module1 . T ; TYPE T2 = Module2 . T Now you can use T1 and T2 all over the place. Of course, if it weren't for two modules each having a different T, you could just say FROM Module1 IMPORT T, so T is available without qualification, but unlike above, is not renamed. (This is pasted in from Jay's other post on this topic) >But if I don't want to pay for heap allocation, I can't say: >VAR T: v; >v.DoSomething(); >Only IMPORT T FROM M; >VAR T: v; >M.DoSomething(v); > Right? If you don't want to have to write the module name as a qualifier, you can rename a procedure too, with a constant declaration (Procedures in Modula-3 are actually the same thing a constants of procedure type.) CONST DoSomething = M.DoSomething ... DoSomething ( v ) Having been almost forced (for other reasons I'll skip for now) in Ada to consistently use qualified references like M.DoSomething, I've come to believe that is the right way to code, even though it's more writing. It makes old code/somebody else's code _much_ easier to read. Using unqualified names is turning the priorities upside-down and saying writability trumps readability. Only if it's referred to _very_ often, do I use unqualified names (in which case, I also make them short). One limitation in Modula-3 is that you can't rename an exception or (well, not in the most general way) a variable from an imported module. I discussed this once in a list of language wants, but expressed ambivalence, particularly about variable renames. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; The nonvirtual member functions greatly complicate the language, and provide nothing that plain, nonmember functions don't provide. -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From lemming at henning-thielemann.de Fri Nov 16 22:24:15 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 22:24:15 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: <473E0ECB.504@wichita.edu> References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Rodney M. Bates wrote: > If you don't want to have to write the module name as a qualifier, you can > rename a procedure too, with a constant declaration (Procedures in Modula-3 > are actually the same thing a constants of procedure type.) > > CONST DoSomething = M.DoSomething > ... > DoSomething ( v ) It would have been nice if PROCEDURE declarations would reflect this, like in functional languages. Say CONST Sin = PROCEDURE (x: LONGREAL;): LONGREAL BEGIN ... RETURN y; END; This would also be the key for anonymous functions or loops as higher order functions. Just an idea, it's certainly simpler just to use a functional language. :-) From rodney.bates at wichita.edu Fri Nov 16 22:54:56 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:54:56 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> References: <473CE6B6.3030402@wichita.edu> <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Message-ID: <473E11B0.3060103@wichita.edu> Darko wrote: > Is it really four words? I would have thought it might need a type > reference and a size, what are the others for? > One word for the pointer in the stack variable or wherever the real data would be, if not heap allocated. One word at negative offset in the heap object for the allocator/collector to keep track of memory. This is as low as heap manager space overhead gets, as far as I know. In any case, unless somebody figured out how to get it down to zero, there would still just about have to be a full word because of alignment. One word of "shape" for each open dimension, when the object is an open array. This example is one-dimensional, so it's one word total. One word (actually appears before the shape (which varies in size), so its location is consistent for all open array heap objects). This is a pointer to the zero-th actual array element. For a heap allocated open array, this is redundant, as it always points to the word following the shape. I presume the implementors did this because open array formal parameters need a consistent representation, regardless of whether the formal is an open array, a fixed array, or a SUBARRAY. It should be possible to implement less extravagantly, but it would complicate the compiler with more combinations of cases to handle. > > On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > >> Jay wrote: >> >> > What is the right way to have a variably sized but always small >> array in Modula-3? >> > My array will only ever have 1 or 2 elements. >> > I'd like to always allocate room for 2 elements, and have there be >> a size. >> > >> > It seems I have a choice of >> > >> > a) an "open" array >> >> Heap allocated, I presume? If the max size is only 2 elements, >> this is pretty extravagant, as a heap allocated open array will >> have 4 extra behind-the-scenes words of space overhead, plus >> maybe heap fragmentation, and time overhead of allocation, >> collection, and maybe reduced locality of reference. >> -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From mika at async.caltech.edu Fri Nov 16 23:07:13 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Fri, 16 Nov 2007 14:07:13 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: Your message of "Fri, 16 Nov 2007 16:39:44 GMT." Message-ID: <200711162207.lAGM7D2N050225@camembert.async.caltech.edu> Naw, it's DoSomething(x); DoSomethingElse(y) It's not the same function. Not even in C++! It's just another example of overloading... Jay writes: >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >> VAR v : T;> DoSomething(v);> > What's the big deal if it's DoSomething(v)= > or v.DoSomething()? VAR x : T1; VAR y : T2; DoSomething(x); DoSomething(y)= >; >isn't legal, right? >=20 >So I have to: > M1.DoSomething(x); M2.DoSomething(y); >right? Constantly repeating types, or modules, on function names? >=20 > - Jay >=20 > > > >> To: jay.krell at cornell.edu> Subject: Re: [M3devel] small array in modula-3= >? > Date: Thu, 15 Nov 2007 21:00:13 -0800> From: mika at async.caltech.edu> > = >Why not > > FROM M IMPORT T, DoSomething;> > VAR v : T;> DoSomething(v);> >= > What's the big deal if it's DoSomething(v) or v.DoSomething()?> > If anyth= >ing, "DoSomething(v)" tells me that the call can be statically> resolved, w= >hereas v.DoSomething() tells me that something odd can> happen at runtime--= >-that is, I cannot be sure I understand this> code simply by looking for a = >routine called "DoSomething" and reading> that, but have to be more careful= >. This distinction is unclear in> C++. What, in fact, is the distinction in= > C++ between DoSomething(v)> and v.DoSomething()? None, right? Just two way= >s of saying the> same thing... why?> > The Modula-2+ work on the Firefly is= > also close enough to be "almost"> Modula-3...> > Regarding UNSAFE: most in= >terfaces to C code are (or should be)> UNSAFE because there are ways of cal= >ling them that can lead to> unchecked runtime errors. I don't see how you c= >an live without> UNSAFE if you ever want to link with other people's C libr= >aries...> > Mika> > Jay writes:> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_>= > >Content-Type: text/plain; charset=3D"iso-8859-1"> >Content-Transfer-Encod= >ing: quoted-printable> >> >But if I don't want to pay for heap allocation, = >I can't say:> >=3D20> >VAR T: v;> >=3D20> >v.DoSomething();> >=3D20> >Only = >IMPORT T FROM M;> >=3D20> >VAR T: v;> >=3D20> >M.DoSomething(v);> >=3D20> >= >Right?> >SPIN I think you mean.> >Anyone build it and bring it up? I was lo= >ng curious but never did..> >=3D20> > - Jay> >> >> >> >> CC: m3devel at elegos= >oft.com> From: darko at darko.org> Subject: Re: [M3devel] =3D> >small array in= > modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.kr=3D> >ell at corn= >ell.edu> > Not sure what the problem is with modules. If you want t=3D> >o = >avoid the > dot you can name the type something unique then import that t= >=3D> >ype > name. You can create an interface with all the nice type names = >and > =3D> >import all those names in modules by adding an EXPORTS clause t= >oo.> > Perso=3D> >nally I think M3, with a couple of extensions, wouldn't n= >eed > unsafe anyth=3D> >ing. The unsafe features are there mostly because o= >f > legacy interfaces. I=3D> > forget the name but the folk who wrote an OS= > in > M3 found it very effecti=3D> >ve with only couple of minor points wit= >h > regards to interfacing to C code=3D> > they built on top of, I think on= >e of > them was being able to pass NIL to =3D> >a VAR parameter, which is a= > common > C idiom (and an annoying one for M3 us=3D> >ers who then can't us= >e VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > =3D> >> Rodney, thank= > you, this is interesting.> > I definitely don't want to pay=3D> > for heap= > allocation for a tiny array.> > I don't know about "subarray". It=3D> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered ano=3D= >> >ther copy of the Nelson book > > so I don't have to find mine.> >> > Goo= >d i=3D> >dea "MakeT" I forgot about that pattern. I'll try it out.> >> > Th= >e record =3D> >and array I propose are not all that different really.> > I = >just heard of s=3D> >omething new. Have you heard of it? "Duck typing". > >= > If it acts/quacks/wa=3D> >lks like a duck, it is a duck.> > This is in ver= >y dynamic languages like Ru=3D> >by.> > You apply object.method and if obje= >ct defines something named > > "m=3D> >ethod", then it "must" have "the" me= >aning you intend.> > Kind of like how C=3D> >++ templates "accept as parame= >ters whatever > > happens to work".> >> > Ope=3D> >rator overloading is gre= >at for strings and "math".> >> > Maybe I should try=3D> > to have this lang= >uage debate from scratch again..?> >> > I still am conflc=3D> >ted.> >> > M= >odules seem overly heavyweight.> > I don't want Module1.T, Modu=3D> >le2.T,= > I want T1, T2.> >> > C++ stack structs with non virtual member funct=3D> >= >ions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(= >=3D> >0) { }> >> > int Height() { return bottom - top; }> > int Width() { r= >eturn =3D> >right - left; }> > int top, left, bottom, right;> > };> >> > se= >ems "good".>=3D> > >> > And it seems not really all that complicated for th= >e compiler to > > =3D> >flow the static type information around to resolve = >the functions..> >> > Re=3D> >ct_t r;> > r.Height() =3D3D> Rect_Height(&r);= > ..and would be inlined anyway.>=3D> > >> > I do find some compelling featu= >res in Modula-3. Mainly that it > > co=3D> >mpiles to native code and has O= >PTIONAL safety, optional garbage > > collect=3D> >ion, and that the syntax = >of modules/interfaces allows fast > > compilation =3D> >-- no longer repars= >ing the same headers over and over > > and over and over=3D> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D> > like a= > primitive integer, but raises exceptions upon overflow.> > For this=3D> > = >to work very much requires operator overloading.> >> > A point, of course,= >=3D> > is to be able to have user defined types that > > can act like the b= >uilt i=3D> >n types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:1= >8 -0600> > >=3D> > From: rodney.bates at wichita.edu> > > To: m3devel at elegosof= >t.com> > > Subject=3D> >: Re: [M3devel] small array in modula-3?> > >> > > = >Jay wrote:> > >> > > > W=3D> >hat is the right way to have a variably sized= > but always small > > array in=3D> > Modula-3?> > > > My array will only ev= >er have 1 or 2 elements.> > > > I'd =3D> >like to always allocate room for = >2 elements, and have there > > be a size.>=3D> > > > >> > > > It seems I ha= >ve a choice of> > > >> > > > a) an "open" array>=3D> > > >> > > Heap alloca= >ted, I presume? If the max size is only 2 elements,> >=3D> > > this is pret= >ty extravagant, as a heap allocated open array will> > > hav=3D> >e 4 extra= > behind-the-scenes words of space overhead, plus> > > maybe heap f=3D> >rag= >mentation, and time overhead of allocation,> > > collection, and maybe r=3D= >> >educed locality of reference.> > >> > > > b) wrap it up in a record> > >= > >>=3D> > > > > I'd like so have, like:> > > >> > > > TYPE A =3D3D ARRAY [0= >..1] OF FOO=3D> >;> > > >> > > > And be able to say:> > > >> > > > VAR> > >= > > a : A;> > > >>=3D> > > > > ..> > > > a.size> > > > FOR i :=3D3D 0 TO a.s= >ize DO> > > > do somethin=3D> >g with a[i]> > > >> > > > It seems I have no= > option but, like:> > > >> > > =3D> >> TYPE A =3D3D RECORD> > > > a: ARRAY[= >0..1] OF FOO;> > > > size :=3D3D 1; (* us=3D> >ually of size 1, sometimes 2= > *)> > > > END> > > >> > > > and then> > > > FO=3D> >R i :=3D3D 0 TO a.size= > DO> > > > do something with a.a[i];> > > >> > > > That=3D> > is "ok". Not = >great -- what to call the inner a?> > > > But then furthermor=3D> >e, I'd l= >ike to construct constants.> > > > It seems I am stuck with either =3D> >th= >e verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..= >=3D> >1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name fo= >r the =3D> >embedded array.> > > > But of course, its type is really "the s= >ame" as the =3D> >outer type.> > >> > >> > > Ignoring the fact that the typ= >es are different l=3D> >inguistically> > > (one a record type, the other an= > array), the types are d=3D> >ifferent> > > at a deep semantic level too. T= >he inner array has static> > >=3D> > size, the outer one (call it a "variab= >le array", perhaps)> > > has dynamic=3D> >ally changeable size, even more e= >asily changed> > > after it is created tha=3D> >n a heap-allocated open arr= >ay. This> > > is a significant semantic differen=3D> >ce, so it also makes = >program> > > design sense to view them as different ty=3D> >pes.> > >> > > = >>> > > > To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[0..1]=3D> > OF Foo= >;> > > >> > > > TYPE FooArray =3D3D RECORD> > > > a : FooArray;> > > >=3D> = >> size :=3D3D 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );= >> >=3D> > > >> > > > But I have to come up with different names.> > > >> > = >> > And I=3D> > don't think I can leave out the name for the constructor, >= > > like:> > > >=3D> >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, th= >is is a limitation in=3D> > Modula-3. Ada allows value constructors> > > to= > omit inner type names in c=3D> >ases like this, and it is > > convenient. = >But> > > it also crosses a really=3D> > major line on complexity of the lan= >guage > > semantics,> > > since type an=3D> >alysis information now flows n= >ot only upward, but > > also downward> > > in=3D> > expression typing. I am= > mostly content to live with this as > > one bit of=3D> >> > > the price of= > avoiding a horribly over complex language.> > >> > > Ord=3D> >inary proced= >ures can do pretty much all of the things done by > > exotic> >=3D> > > and= > complex language stuff like C++ constructors. If you don't > > want =3D> >= >to write> > > the ponderous nested value constructor, write a constructor >= >=3D> > > procedure and> > > call it. As Antony suggested, you can make it a= >ccept =3D> >an open > > array formal,> > > which then codes just like a sim= >ple array va=3D> >lue constructor. You > > could even> > > make it elaborat= >e and general, e.g=3D> .:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) = >: F> > >> > > =3D3D VAR L=3D> >Size : CARDINAL> > > ; VAR LResult : A> > >>= > > > ; BEGIN> > > LSize :=3D3D NU=3D> >MBER ( Val )> > > <* ASSERT LSize <= >=3D3D NUMBER ( FooArray ) *>> > > ; LResul=3D> >t . size :=3D3D LSize> > > = >; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S=3D> >UBARRAY ( Val , F= >IRST ( Val ) , LSize )> > > ; RETURN LResult> > > END Make=3D> >F> > >> > >= > Alternatively, since your maximum element count is so small, yo=3D> >u > >= > could> > > write a constructor procedure that took two formals of typ=3D> = >>e FOO, > > with> > > at least the second one optional. (This would require= > =3D> >a > > distinguished> > > value of type FOO that would be used to mea= >n "omit=3D> >ted".)> > >> > > And, of course, if you want to use abstractio= >n, you can pu=3D> >t the > > types,> > > constructor procedures, and variou= >s other procedures =3D> >for > > manipulating> > > the variable sized array= > in a module, behind an i=3D> >nterface.> > >> > > An additional limitation= > of Modula-3 in this regard, is=3D> > that you > > can't> > > make the type= > F opaque, unless you heap allocate i=3D> >t, which we > > were trying> > >= > to avoid. Ada would allow you to do this, =3D> >but it's another > > examp= >le of> > > a convenience with high cost. It force=3D> >s the equivalent of = >the > > revelation> > > to be located in the equivalent=3D> > of the interf= >ace, but makes it > > illegal> > > to write client code that =3D> >depends = >on what the revelation is.> > >> > > This in turn creates a source =3D> >co= >de control nightmare in a large > > project,> > > because now someone who= >=3D> > wants to make what is really a purely > > internal,> > > implementat= >ion ch=3D> >ange, nevertheless has to check out the > > interface, and> > >= > if you aren=3D> >'t in denial mode, that means implementers of all the > >= > client> > > code =3D> >have to go to extra trouble to somehow find out tha= >t what > > appears> > > =3D> >to be an interface change actually doesn't af= >fect them after all.> > >> > >=3D> > >> > > > Though that might seem nice.>= > > > >> > > > Am I understanding eve=3D> >rything?> > > >> > > > Have folks= > hit this before and there's a set of name=3D> >s that > > don't seem too l= >ame> > > > that folks use?> > > >> > > > Also --=3D> > language documentati= >on?> > > > Nelson's green book is excellent.> > > > Th=3D> >e stuff in the = >doc directory is very dry and scientific.> > > > The tutoria=3D> >l seems m= >ore like a reference. Or maybe I didn't > > read it enough.> > > >=3D> > Is= > there better, in case I need a refresher?> > > > I think I got it, via =3D= >> >Nelson's book from memory (wonder if I > > can find mine..) and the refe= >ren=3D> >ce,> > > > but I don't think anyone could learn from the current o= >nline > >=3D> > docs in the source tree.> > > >> > > > Maybe it's me, some = >combination of =3D> >laziness and short attention > > span> > > > as I age.= >.> > > >> > > > Btw, =3D> >C doesn't offer a great solution here, though it= > offers > > leaving out som=3D> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D> >Modula-3 seems to be missing operato= >r overloading.> > > > It's got some bui=3D> >ltin stuff, even array assignm= >ent and equality > > and I think> > > > even =3D> >record assignment and eq= >uality, but it is still a bit > > limiting.> > >> >=3D> > >> > > I have rav= >ed on this before, but, having had lots of painful > > ex=3D> >perience wit= >h> > > user-defined overloading in Ada and C++, I can say with =3D> >> > au= >thority, that it is> > > a programming language disaster. It interact=3D> >= >s with just about > > everything> > > else in the language, in very complic= >=3D> >ated ways, and all it buys > > you is saving> > > time/energy thinkin= >g up d=3D> >istinct names for procedures/functions. > > Even this,> > > asi= >de from the =3D> >effects on the language, is a net loss, by the > > time y= >ou consider> > > r=3D> >eadability along with writability.> > >> > > User-d= >efined overloaded operat=3D> >ors provide a slight readability > > benefit,= > _if_> > > used with great res=3D> >traint and discipline, something you ca= >n rely > > on not happening.> > > Me=3D> >anwhile, the language complexity = >can easily double or worse. > > And, with =3D> >the> > > exception of compi= >ler writers and language lawyers who spend > > h=3D> >undreds of hours> > >= > on just this, programmers don't understand the rules,=3D> > not even > > c= >lose.> > >> > > >> > > > Also, if I understand things correc=3D> >tly, this= > has long bothered > > me about Modula-3,> > > > though I'm more t=3D> >ole= >rant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > >=3D= >> > objects. Like, small stack allocated structs with member > > functions.= > Yo=3D> >u seem to have> > > > to chose between heap allocated garbage coll= >ected vir=3D> >tual > > member functions full> > > > featured objects, or f= >eatureless dumb=3D> > structs. It's nice how C+ > > + allow hybrids --> > >= > > objects don't have=3D> > to be heap allocated and member functions > > d= >on't have be virtual.> > > =3D> >> Or am I missing something?> > >> > >> > = >> C++'s supposedly lighter weight=3D> > forms of classes/structs with > > t= >heir special> > > member functions buy =3D> >nothing that plain records, pl= >ain > > procedures, and> > > interfaces/modul=3D> >es don't already provide= >, again, at significant > > and gratuitous> > > lan=3D> >guage complexity. = >Except when methods/member functions > > actually dispatc=3D> >h> > > dynam= >ically, there is nothing that the above won't do, and when > > =3D> >you cr= >eate a> > > class instance as a local variable (i.e., on the stack), =3D> >= >it is > > necessarily> > > not polymorphic, that is, it can't change its "a= >=3D> >llocated" or > > dynamic type> > > among various subtypes at runtime.= > This =3D> >in turn means it can't > > dispatch.> > >> > > So, just use pla= >in procedure=3D> >s, an interface and a module, and you > > will get> > > e= >verything a lighte=3D> >r-weight C++ class would give you.> > >> > >> > > >= >> > > > Anyway, I've got=3D> >ten to accept C a bit more vs. C++ so I can >= > > deal with> > > > t: Type;> =3D> >> > > Type_DoSomething(t);> > > >> > > = >> in place of:> > > > t.DoSomething(=3D> >);> > >> > >> > > Exactly. The sp= >ecial "receiver object" in a true method c=3D> >all has > > significant> > = >> semantic differences from an ordinary paramete=3D> >r and introduces > > = >new complexities> > > and non-orthogonalities. It has =3D> >some very valua= >ble uses too.> > >> > > But to then create degenerate forms =3D> >of it tha= >t still carry a lot > > of these> > > complexities, but are equiva=3D> >len= >t in programing power to plain old> > > parameters is just bad program d=3D= >> >esign and bad language design. > > Objects and> > > methods are indeed c= >ool=3D> > for situations that utilize their > > semantic complexity.> > > B= >ut it's d=3D> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D> >tely sophisticated construct when the problem doesn't = >> > justify it.> > > =3D> >Some OO proponents have gone way over the deep e= >nd here.> > >> > > >> > > >=3D> > - Jay> > > >> > > >> > > > > > ----------= >---------------------------------=3D> >--------------------------- > > --> = >> > > Boo! Scare away worms, viruses an=3D> >d so much more! Try Windows > = >> Live OneCare! Try now!> > > >.live.com/standard/en-us= >/purchase/trial.aspx? > > s_cid=3D3Dwl_hotmailnews>> =3D> >> >> > >> > > --= >> > > -----------------------------------------------------=3D> >--------> = >> > Rodney M. Bates, retired assistant professor> > > Dept. of Co=3D> >mput= >er Science, Wichita State University> > > Wichita, KS 67260-0083> > > 3=3D>= > >16-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------= >--=3D> >----------------------------------------------> > > Rodney M. Bates= >, retire=3D> >d assistant professor> > > Dept. of Computer Science, Wichita= > State Univers=3D> >ity> > > Wichita, KS 67260-0083> > > 316-978-3922> > > = >rodney.bates at wichita=3D> >.edu> >> >> > Boo! Scare away worms, viruses and = >so much more! Try Windows =3D> >Live > > OneCare! Try now!>=3D20> >________= >_________________________________________________________> >Climb to the to= >p of the charts!=3DA0 Play Star Shuffle:=3DA0 the word scramble =3D> >chall= >enge with star power.> >http://club.live.com/star_shuffle.aspx?icid=3D3Dsta= >rshuffle_wlmailtextlink_oc=3D> >t=3D> >> >--_0109391c-2ffe-4cfe-9165-c2a246= >28c3c7_> >Content-Type: text/html; charset=3D"iso-8859-1"> >Content-Transfe= >r-Encoding: quoted-printable> >> >> >> >> >> >'>But if I don't want to pay for heap allocation, I=3D> > can't say:
> >= > 
> >VAR T: v;
> > 
> >v.DoSomething();
> > 
= >> >Only IMPORT T FROM M;
> > 
> >VAR T: v;
> > 
> >M.= >DoSomething(v);
> > 
> >Right?

> >SPIN I think you mean.<= >BR>> >Anyone build it and bring it up? I was long curious but never did..R>> > 
> > - Jay


> >> >
> ><= >BR>> >> CC: m3devel at elegosoft.com
> From: darko at darko.org
> = >Subjec=3D> >t: Re: [M3devel] small array in modula-3?
> Date: Thu, 15= > Nov 2007 20=3D> >:29:06 -0800
> To: jay.krell at cornell.edu
> R>> Not sure wh=3D> >at the problem is with modules. If you want to avoi= >d the
> dot you c=3D> >an name the type something unique then import= > that type
> name. You =3D> >can create an interface with all the ni= >ce type names and
> import al=3D> >l those names in modules by addin= >g an EXPORTS clause too.
>
> =3D> >Personally I think M3, with= > a couple of extensions, wouldn't need
> =3D> >unsafe anything. The = >unsafe features are there mostly because of
> l=3D> >egacy interface= >s. I forget the name but the folk who wrote an OS in
>=3D> >; M3 foun= >d it very effective with only couple of minor points with
>=3D> > re= >gards to interfacing to C code they built on top of, I think one of
=3D= >> >> them was being able to pass NIL to a VAR parameter, which is a comm= >on =3D> >
> C idiom (and an annoying one for M3 users who then can't = >use VAR).=3D> >
>
>
> On 15/11/2007, at 8:08 PM, Jay wr= >ote:
> >R>> > Rodney, thank you, this is interesting.>> > I definite=3D> >ly don't want to pay for heap allocation for a t= >iny array.
> > I d=3D> >on't know about "subarray". It looks like = >it takes and returns
> >=3D> >; arrays. It's not a type. I ordered= > another copy of the Nelson book
&g=3D> >t; > so I don't have to fin= >d mine.
> >
> > Good idea "=3D> >MakeT" I forgot about th= >at pattern. I'll try it out.
> >
> &=3D> >gt; The record and= > array I propose are not all that different really.
&g=3D> >t; > I ju= >st heard of something new. Have you heard of it? "Duck typing".=3D> >
&= >gt; > If it acts/quacks/walks like a duck, it is a duck.
> &=3D> >= >gt; This is in very dynamic languages like Ruby.
> > You apply obj= >=3D> >ect.method and if object defines something named
> > "metho= >d", th=3D> >en it "must" have "the" meaning you intend.
> > Kind o= >f like how C=3D> >++ templates "accept as parameters whatever
> >= > happens to work".=3D> >
> >
> > Operator overloading is = >great for strings and "m=3D> >ath".
> >
> > Maybe I shoul= >d try to have this language de=3D> >bate from scratch again..?
> >= >
> > I still am conflcted.<=3D> >BR>> >
> > Modules= > seem overly heavyweight.
> > I d=3D> >on't want Module1.T, Module= >2.T, I want T1, T2.
> >
> > C+=3D> >+ stack structs with = >non virtual member functions:
> > class Rect_=3D> >t
> > = >{
> > Rect_t() : top(0), left(0), right(0), bottom(=3D> >0) { }>> >
> > int Height() { return bottom - top; }
&=3D> >gt;= > > int Width() { return right - left; }
> > int top, left, b=3D= >> >ottom, right;
> > };
> >
> > seems "good".>&g=3D> >t; >
> > And it seems not really all that complicated = >for the c=3D> >ompiler to
> > flow the static type information ar= >ound to resolve=3D> > the functions..
> >
> > Rect_t r;R>> > r.Height(=3D> >) =3D3D> Rect_Height(&r); ..and would be = >inlined anyway.
> ><=3D> >BR>> > I do find some compelling f= >eatures in Modula-3. Mainly that it=3D> >
> > compiles to native = >code and has OPTIONAL safety, optional ga=3D> >rbage
> > collecti= >on, and that the syntax of modules/interfaces a=3D> >llows fast
> &g= >t; compilation -- no longer reparsing the same header=3D> >s over and over = >
> > and over and over.
> >
> > =3D> >Operator o= >verloading btw..have seen "template SafeInt"? It acts
> &g=3D> >t; l= >ike a primitive integer, but raises exceptions upon overflow.
> &=3D>= > >gt; For this to work very much requires operator overloading.
> >= >;<=3D> >BR>> > A point, of course, is to be able to have user defined= > types t=3D> >hat
> > can act like the built in types..
> &= >gt;
> &g=3D> >t; - Jay
> >
> >
> > > Da= >te: Thu, 15 Nov 2007=3D> > 18:39:18 -0600
> > > From: rodney.ba= >tes at wichita.edu
> &g=3D> >t; > To: m3devel at elegosoft.com
> &= >gt; > Subject: Re: [M3devel] =3D> >small array in modula-3?
> >= > >
> > > Jay wrote:
=3D> >> > >
> > >= >; > What is the right way to have a varia=3D> >bly sized but always smal= >l
> > array in Modula-3?
> > &g=3D> >t; > My array wi= >ll only ever have 1 or 2 elements.
> > > >=3D> >; I'd like to= > always allocate room for 2 elements, and have there
> =3D> >> be= > a size.
> > > >
> > > > It seems I ha=3D> >v= >e a choice of
> > > >
> > > > a) an "open" a= >=3D> >rray
> > >
> > > Heap allocated, I presume? I= >f the =3D> >max size is only 2 elements,
> > > this is pretty e= >xtravagant, =3D> >as a heap allocated open array will
> > > hav= >e 4 extra behind-t=3D> >he-scenes words of space overhead, plus
> >= >; > maybe heap fragme=3D> >ntation, and time overhead of allocation,
= >> > > collection, and=3D> > maybe reduced locality of reference.R>> > >
> > > &=3D> >gt; b) wrap it up in a record
= >> > > >
> > > >=3D> > I'd like so have, like:>> > > >
> > > > TYPE=3D> > A =3D3D ARRAY [0..1]= > OF FOO;
> > > >
> > > > A=3D> >nd be able to= > say:
> > > >
> > > > VAR
>=3D> >; > = >> > a : A;
> > > >
> > > > .. >>= >> > > > a.size
> > > > FOR i :=3D3D 0 TO a.size = >D=3D> >O
> > > > do something with a[i]
> > > &g= >t;
&=3D> >gt; > > > It seems I have no option but, like:
>= >; > > &=3D> >gt;
> > > > TYPE A =3D3D RECORD
> &= >gt; > > a: ARRA=3D> >Y[0..1] OF FOO;
> > > > size :=3D= >3D 1; (* usually of size 1, s=3D> >ometimes 2 *)
> > > > END= >
> > > >
> >=3D> >; > > and then
> > = >> > FOR i :=3D3D 0 TO a.size DO
&g=3D> >t; > > > do somet= >hing with a.a[i];
> > > >
> =3D> >> > > That = >is "ok". Not great -- what to call the inner a?
>=3D> > > > >= >; But then furthermore, I'd like to construct constants.
&=3D> >gt; >= > > > It seems I am stuck with either the verbose:
> >=3D> >; = >> >
> > > > PROCEDURE F(a:A);
> > > >= >=3D> >
> > > > F( A { ARRAY[0..1] OF FOO { .. } );
> &= >gt; &g=3D> >t; >
> > > > OR I have to come up with a name= > for the emb=3D> >edded array.
> > > > But of course, its ty= >pe is really "the =3D> >same" as the outer type.
> > >
> = >> >
> > &=3D> >gt; Ignoring the fact that the types are diff= >erent linguistically
> &=3D> >gt; > (one a record type, the other = >an array), the types are different >R>> > > at a deep semant= >ic level too. The inner array has static >R>> > > size, the = >outer one (call it a "variable array", perhaps)<=3D> >BR>> > > has= > dynamically changeable size, even more easily changed=3D> >
> > &= >gt; after it is created than a heap-allocated open array. Th=3D> >is
>= >; > > is a significant semantic difference, so it also makes=3D> > pr= >ogram
> > > design sense to view them as different types.> >>> > >
> > > >
> > > > To wit:>&g=3D> >t; > > >
> > > > TYPE FooArray =3D3D ARRAY= >[0..1] OF F=3D> >oo;
> > > >
> > > > TYPE Foo= >Array =3D3D RECORD<=3D> >BR>> > > > a : FooArray;
> > = >> > size :=3D3D 1; >>> > > > END;
> > >= >; >
> > > > F( =3D> >FooArray { FooArray { .. } );
>= >; > > >
> > > >=3D> > But I have to come up with di= >fferent names.
> > > >
>=3D> > > > > And I do= >n't think I can leave out the name for the construc=3D> >tor,
> >= > like:
> > > >
> > > > F( F=3D> >ooArray { { = >.. } );
> > >
> > >
> > > Y=3D> >es, th= >is is a limitation in Modula-3. Ada allows value constructors
>=3D> >= > > > to omit inner type names in cases like this, and it is
> = >=3D> >> convenient. But
> > > it also crosses a really major= > line =3D> >on complexity of the language
> > semantics,
> = >> > si=3D> >nce type analysis information now flows not only upward, = >but
> > =3D> >also downward
> > > in expression typin= >g. I am mostly content t=3D> >o live with this as
> > one bit of<= >BR>> > > the price of=3D> > avoiding a horribly over complex langu= >age.
> > >
> > =3D> >> Ordinary procedures can do p= >retty much all of the things done by
&=3D> >gt; > exotic
> >= >; > and complex language stuff like C++ const=3D> >ructors. If you don't= >
> > want to write
> > > the pon=3D> >derous nested v= >alue constructor, write a constructor
> > procedur=3D> >e and
= >> > > call it. As Antony suggested, you can make it accep=3D> >t a= >n open
> > array formal,
> > > which then codes ju=3D= >> >st like a simple array value constructor. You
> > could evenR>&=3D> >gt; > > make it elaborate and general, e.g.:
> > &g= >t;
>=3D> >; > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F
&g= >t; > > >>> > > =3D3D VAR LSize : CARDINAL
> >= >; > ; VAR LResult : =3D> >A
> > >
> > > ; BEGIN<= >BR>> > > LSize :=3D3D =3D> >NUMBER ( Val )
> > > <*= > ASSERT LSize <=3D3D NUMBER ( FooArr=3D> >ay ) *>
> > > ;= > LResult . size :=3D3D LSize
> > > =3D> >; SUBARRAY ( LResult .= > a , 0 , LSize )
> > > :=3D3D SUBARRAY ( Va=3D> >l , FIRST ( Va= >l ) , LSize )
> > > ; RETURN LResult
> >=3D> > > EN= >D MakeF
> > >
> > > Alternatively, since yo=3D> >ur= > maximum element count is so small, you
> > could
> > = >=3D> >> write a constructor procedure that took two formals of type FOO,= >
&=3D> >gt; > with
> > > at least the second one optiona= >l. (This wou=3D> >ld require a
> > distinguished
> > >= >; value of type FO=3D> >O that would be used to mean "omitted".)
> &g= >t; >
> > >=3D> >; And, of course, if you want to use abstract= >ion, you can put the
> =3D> >> types,
> > > construct= >or procedures, and various other pro=3D> >cedures for
> > manipul= >ating
> > > the variable sized=3D> > array in a module, behind = >an interface.
> > >
> > >=3D> >; An additional limit= >ation of Modula-3 in this regard, is that you
>=3D> > > can't
= >> > > make the type F opaque, unless you heap alloc=3D> >ate it, w= >hich we
> > were trying
> > > to avoid. Ada =3D> >wou= >ld allow you to do this, but it's another
> > example of
&g=3D= >> >t; > > a convenience with high cost. It forces the equivalent of t= >he =3D> >
> > revelation
> > > to be located in the eq= >uivalent =3D> >of the interface, but makes it
> > illegal
>= > > > to w=3D> >rite client code that depends on what the revelation i= >s.
> > ><=3D> >BR>> > > This in turn creates a source = >code control nightmare in a=3D> > large
> > project,
> >= > > because now someone who wan=3D> >ts to make what is really a purely <= >BR>> > internal,
> > >=3D> >; implementation change, never= >theless has to check out the
> > in=3D> >terface, and
> >= >; > if you aren't in denial mode, that means imp=3D> >lementers of all t= >he
> > client
> > > code have to go=3D> > to extra tr= >ouble to somehow find out that what
> > appears
&g=3D> >t; >= >; > to be an interface change actually doesn't affect them after a=3D> >= >ll.
> > >
> > > >
> > > > Though = >=3D> >that might seem nice.
> > > >
> > > > A= >m I un=3D> >derstanding everything?
> > > >
> > >= >; > Have =3D> >folks hit this before and there's a set of names that >> > don't s=3D> >eem too lame
> > > > that folks use?= >
> > > ><=3D> >BR>> > > > Also -- language docum= >entation?
> > > &g=3D> >t; Nelson's green book is excellent.>> > > > The stuff in th=3D> >e doc directory is very dry and s= >cientific.
> > > > The tuto=3D> >rial seems more like a refe= >rence. Or maybe I didn't
> > read it e=3D> >nough.
> > &= >gt; > Is there better, in case I need a refresher?<=3D> >BR>> > &g= >t; > I think I got it, via Nelson's book from memory (won=3D> >der if I = >
> > can find mine..) and the reference,
> > >=3D> >; &= >gt; but I don't think anyone could learn from the current online
>=3D= >> >; > docs in the source tree.
> > > >
> > >= > &g=3D> >t; Maybe it's me, some combination of laziness and short attention= >
>=3D> > > span
> > > > as I age..
> > &g= >t; >
>=3D> > > > > Btw, C doesn't offer a great solution = >here, though it offer=3D> >s
> > leaving out some type names.
= >> > > > In C++ =3D> >I could have both .size and operator[].>> > > > Modula-3 see=3D> >ms to be missing operator overloadin= >g.
> > > > It's got some=3D> > builtin stuff, even array ass= >ignment and equality
> > and I thin=3D> >k
> > > >= > even record assignment and equality, but it is sti=3D> >ll a bit
> = >> limiting.
> > >
> > >
>=3D> >; > > = >I have raved on this before, but, having had lots of painful >R>>= > > experience with
> > > user-defined overloading in A=3D> >= >da and C++, I can say with
> > authority, that it is
> >= >=3D> > > a programming language disaster. It interacts with just about <= >BR>>=3D> >; > everything
> > > else in the language, in ve= >ry complicat=3D> >ed ways, and all it buys
> > you is saving
&= >gt; > > time=3D> >/energy thinking up distinct names for procedures/f= >unctions.
> > =3D> >Even this,
> > > aside from the e= >ffects on the language, is a n=3D> >et loss, by the
> > time you = >consider
> > > readabili=3D> >ty along with writability.
>= >; > >
> > > User-defined=3D> > overloaded operators provi= >de a slight readability
> > benefit, _=3D> >if_
> > >= > used with great restraint and discipline, something y=3D> >ou can rely >> > on not happening.
> > > Meanwhile, th=3D> >e languag= >e complexity can easily double or worse.
> > And, with t=3D> >he<= >BR>> > > exception of compiler writers and language lawyers who=3D= >> > spend
> > hundreds of hours
> > > on just this, p= >rog=3D> >rammers don't understand the rules, not even
> > close.<= >BR>> &=3D> >gt; >
> > > >
> > > > Also,= > if I understan=3D> >d things correctly, this has long bothered
> &g= >t; me about Modula-3,=3D> >
> > > > though I'm more tolerant= > now -- Modula-3 doesn't se=3D> >em to allow
> > for lighter wieg= >ht
> > > > objects=3D> >. Like, small stack allocated struct= >s with member
> > functions. =3D> >You seem to have
> > = >> > to chose between heap allocated gar=3D> >bage collected virtual <= >BR>> > member functions full
> > >=3D> >; > featured ob= >jects, or featureless dumb structs. It's nice how C+
=3D> >> > + = >allow hybrids --
> > > > objects don't have to b=3D> >e heap= > allocated and member functions
> > don't have be virtual.<=3D> >= >BR>> > > > Or am I missing something?
> > >
>= >=3D> > > >
> > > C++'s supposedly lighter weight forms of= > class=3D> >es/structs with
> > their special
> > > m= >ember functi=3D> >ons buy nothing that plain records, plain
> > p= >rocedures, and
=3D> >> > > interfaces/modules don't already pro= >vide, again, at signific=3D> >ant
> > and gratuitous
> >= > > language complexity. Exc=3D> >ept when methods/member functions
&= >gt; > actually dispatch
> &=3D> >gt; > dynamically, there is no= >thing that the above won't do, and when >R>> > you create a>> > > class instance as a local variab=3D> >le (i.e., on the stac= >k), it is
> > necessarily
> > > =3D> >not polymorphic= >, that is, it can't change its "allocated" or
> > =3D> >dynamic t= >ype
> > > among various subtypes at runtime. This in t=3D> >urn= > means it can't
> > dispatch.
> > >
> > &=3D= >> >gt; So, just use plain procedures, an interface and a module, and you R>&=3D> >gt; > will get
> > > everything a lighter-weight C+= >+ class w=3D> >ould give you.
> > >
> > >
> &= >gt; > > >R>> > > > Anyway, I've gotten to accept C = >a bit more vs. C++ so=3D> > I can
> > deal with
> > >= > > t: Type;
> >=3D> > > > Type_DoSomething(t);
> &g= >t; > >
> > > &g=3D> >t; in place of:
> > > &g= >t; t.DoSomething();
> > > >R>> > >
> > = >> Exactly. The special "receiver object" i=3D> >n a true method call has= >
> > significant
> > > semant=3D> >ic differences fro= >m an ordinary parameter and introduces
> > new =3D> >complexities= >
> > > and non-orthogonalities. It has some very va=3D> >luable= > uses too.
> > >
> > > But to then create deg=3D> >= >enerate forms of it that still carry a lot
> > of these
> &= >=3D> >gt; > complexities, but are equivalent in programing power to plai= >n old<=3D> >BR>> > > parameters is just bad program design and bad= > language de=3D> sign.
> > Objects and
> > > methods = >are indeed cool f=3D> >or situations that utilize their
> > seman= >tic complexity.
>=3D> > > > But it's deeply uncool to try to lo= >ok superficially cool by usin=3D> >g an
> > > inappropriately s= >ophisticated construct when the pro=3D> >blem doesn't
> > justify= > it.
> > > Some OO proponents=3D> > have gone way over the deep= > end here.
> > >
> > > =3D> >>
> > >= > > - Jay
> > > >
> > > =3D> >>
> >= >; > >
> > ---------------------------------=3D> >----------= >---------------------------
> > --
> > > &g=3D> >t; B= >oo! Scare away worms, viruses and so much more! Try Windows
> &g=3D>= > >t; Live OneCare! Try now!
> > > <http://onecare.live.com/s= >ta=3D> >ndard/en-us/purchase/trial.aspx?
> > s_cid=3D3Dwl_hotmail= >news> >R>> > >
> > >
> > > --
= >> > > -=3D> >-----------------------------------------------------= >-------
> > &=3D> >gt; Rodney M. Bates, retired assistant professo= >r
> > > Dept. of=3D> > Computer Science, Wichita State Universi= >ty
> > > Wichita, KS 6=3D> >7260-0083
> > > 316-978= >-3922
> > > rodney.bates at wic=3D> >hita.edu
> > >>> > > --
> > > ---------=3D> >-----------------------= >-----------------------------
> > > Rodn=3D> >ey M. Bates, reti= >red assistant professor
> > > Dept. of Compute=3D> >r Science, = >Wichita State University
> > > Wichita, KS 67260-008=3D> >3
= >> > > 316-978-3922
> > > rodney.bates at wichita.edu=3D> = >>
> >
> >
> > Boo! Scare away worms, viruses and= =3D> >so much more! Try Windows Live
> > OneCare! Try now!
&g= >t;
=3D> >


Climb to the top of the charts!=3DA0 Play Star= > Shuffle:=3DA0 th=3D> >e word scramble challenge with star power. =3D3D'http://club.live.com/=3D> >star_shuffle.aspx?icid=3D3Dstarshuffle_wlm= >ailtextlink_oct' target=3D3D'_new'>Pl=3D> >ay Now!> >=3D>= > >> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_-- >_________________________________________________________________ >Help yourself to FREE treats served up daily at the Messenger Caf=E9. Stop = >by today. >http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=3DTXT_TAGLM_Oc= >tWLtagline= > >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > > >> VAR v : T;
> DoSomething(v);
> <= >BR>> What's the big deal if it's DoSomething(v) or v.NT face=3D"">DoSomething()?

 VAR x : T1;
= > VAR y : T2;
 DoSomething(x);
 DoSomething(y);>
>isn't legal, right?

>So I have to:
>
 M1.DoSomething(x);
 M2.DoSomething(y);

>right? Constantly repeating types, or modules, on function names?

> - Jay

> >
>
>> To: jay.krell at cornell.edu
> Subject: Re: [M3devel] small array i= >n modula-3?
> Date: Thu, 15 Nov 2007 21:00:13 -0800
> From: mi= >ka at async.caltech.edu
>
> Why not
>
> FROM M IMPO= >RT T, DoSomething;
>
> VAR v : T;
> DoSomething(v);
&= >gt;
> What's the big deal if it's DoSomething(v) or = >v.DoSomething()?
>
> If anything= >, "DoSomething(v)" tells me that the call can be statically
> resolve= >d, whereas v.DoSomething() te= >lls me that something odd can
> happen at runtime---that is, I cannot= > be sure I understand this
> code simply by looking for a routine cal= >led "DoSomething" and reading
> that, but have to be more careful. Th= >is distinction is unclear in
> C++. What, in fact, is the distinction= > in C++ between DoSomething(v)
> and v.">DoSomething()? None, right? Just two ways of saying the
= >> same thing... why?
>
> The Modula-2+ work on the Firefly = >is also close enough to be "almost"
> Modula-3...
>
> Re= >garding UNSAFE: most interfaces to C code are (or should be)
> UNSAFE= > because there are ways of calling them that can lead to
> unchecked = >runtime errors. I don't see how you can live without
> UNSAFE if you = >ever want to link with other people's C libraries...
>
> Mika<= >BR>>
> Jay writes:
> >--_0109391c-2ffe-4cfe-9165-c2a2462= >8c3c7_
> >Content-Type: text/plain; charset=3D"iso-8859-1"
>= > >Content-Transfer-Encoding: quoted-printable
> >
> >B= >ut if I don't want to pay for heap allocation, I can't say:
> >=3D= >20
> >VAR T: v;
> >=3D20
> >v.ONT face=3D"">DoSomething();
> >=3D20
> >On= >ly IMPORT T FROM M;
> >=3D20
> >VAR T: v;
> >=3D= >20
> >M.DoSomething(v);
> >=3D20
> >Right?
&g= >t; >SPIN I think you mean.
> >Anyone build it and bring it up? = >I was long curious but never did..
> >=3D20
> > - Jay
= >> >
> >
> >
> >> CC: m3devel at elegosoft.= >com> From: darko at darko.org> Subject: Re: [M3devel] =3D
> >sm= >all array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: ja= >y.kr=3D
> >ell at cornell.edu> > Not sure what the problem is w= >ith modules. If you want t=3D
> >o avoid the > dot you can name= > the type something unique then import that t=3D
> >ype > name.= > You can create an interface with all the nice type names and > =3D
&= >gt; >import all those names in modules by adding an EXPORTS clause too.&= >gt; > Perso=3D
> >nally I think M3, with a couple of extensions= >, wouldn't need > unsafe anyth=3D
> >ing. The unsafe features a= >re there mostly because of > legacy interfaces. I=3D
> > forget= > the name but the folk who wrote an OS in > M3 found it very effecti=3D<= >BR>> >ve with only couple of minor points with > regards to interf= >acing to C code=3D
> > they built on top of, I think one of > t= >hem was being able to pass NIL to =3D
> >a VAR parameter, which is= > a common > C idiom (and an annoying one for M3 us=3D
> >ers wh= >o then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:&= >gt; > =3D
> >> Rodney, thank you, this is interesting.> &= >gt; I definitely don't want to pay=3D
> > for heap allocation for = >a tiny array.> > I don't know about "subarray". It=3D
> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered = >ano=3D
> >ther copy of the Nelson book > > so I don't have t= >o find mine.> >> > Good i=3D
> >dea "MakeT" I forgot a= >bout that pattern. I'll try it out.> >> > The record =3D
>= >; >and array I propose are not all that different really.> > I jus= >t heard of s=3D
> >omething new. Have you heard of it? "Duck typin= >g". > > If it acts/quacks/wa=3D
> >lks like a duck, it is a = >duck.> > This is in very dynamic languages like Ru=3D
> >by.= >> > You apply object.method and if object defines something named >= >; > "m=3D
> >ethod", then it "must" have "the" meaning you inte= >nd.> > Kind of like how C=3D
> >++ templates "accept as para= >meters whatever > > happens to work".> >> > Ope=3D
>= >; >rator overloading is great for strings and "math".> >> > = >Maybe I should try=3D
> > to have this language debate from scratc= >h again..?> >> > I still am conflc=3D
> >ted.> >= >> > Modules seem overly heavyweight.> > I don't want Module1.T,= > Modu=3D
> >le2.T, I want T1, T2.> >> > C++ stack stru= >cts with non virtual member funct=3D
> >ions:> > class Rect_= >t> > {> > Rect_t() : top(0), left(0), right(0), bottom(=3D
&= >gt; >0) { }> >> > int Height() { return bottom - top; }> = >> int Width() { return =3D
> >right - left; }> > int top,= > left, bottom, right;> > };> >> > seems "good".>=3D>> > >> > And it seems not really all that complicated for t= >he compiler to > > =3D
> >flow the static type information a= >round to resolve the functions..> >> > Re=3D
> >ct_t r= >;> > r.Height() =3D3D> Rect_Height(&r); ..and would be inlined= > anyway.>=3D
> > >> > I do find some compelling featur= >es in Modula-3. Mainly that it > > co=3D
> >mpiles to native= > code and has OPTIONAL safety, optional garbage > > collect=3D
>= >; >ion, and that the syntax of modules/interfaces allows fast > > = >compilation =3D
> >-- no longer reparsing the same headers over an= >d over > > and over and over=3D
> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D
= >> > like a primitive integer, but raises exceptions upon overflow.>= >; > For this=3D
> > to work very much requires operator overloa= >ding.> >> > A point, of course,=3D
> > is to be able t= >o have user defined types that > > can act like the built i=3D
>= >; >n types..> >> > - Jay> >> >> > > Dat= >e: Thu, 15 Nov 2007 18:39:18 -0600> > >=3D
> > From: rodn= >ey.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > = >Subject=3D
> >: Re: [M3devel] small array in modula-3?> > &g= >t;> > > Jay wrote:> > >> > > > W=3D
> &= >gt;hat is the right way to have a variably sized but always small > >= > array in=3D
> > Modula-3?> > > > My array will only e= >ver have 1 or 2 elements.> > > > I'd =3D
> >like to al= >ways allocate room for 2 elements, and have there > > be a size.>= >=3D
> > > > >> > > > It seems I have a choice= > of> > > >> > > > a) an "open" array>=3D
>= > > > >> > > Heap allocated, I presume? If the max size is= > only 2 elements,> >=3D
> > > this is pretty extravagant,= > as a heap allocated open array will> > > hav=3D
> >e 4 e= >xtra behind-the-scenes words of space overhead, plus> > > maybe he= >ap f=3D
> >ragmentation, and time overhead of allocation,> >= > > collection, and maybe r=3D
> >educed locality of reference.&= >gt; > >> > > > b) wrap it up in a record> > > &g= >t;>=3D
> > > > > I'd like so have, like:> > >= > >> > > > TYPE A =3D3D ARRAY [0..1] OF FOO=3D
> >;&= >gt; > > >> > > > And be able to say:> > > >= >;> > > > VAR> > > > a : A;> > > >>= >=3D
> > > > > ..> > > > a.size> > > = >> FOR i :=3D3D 0 TO a.size DO> > > > do somethin=3D
> = >>g with a[i]> > > >> > > > It seems I have no op= >tion but, like:> > > >> > > =3D
> >> TYPE = >A =3D3D RECORD> > > > a: ARRAY[0..1] OF FOO;> > > >= > size :=3D3D 1; (* us=3D
> >ually of size 1, sometimes 2 *)> &g= >t; > > END> > > >> > > > and then> > &g= >t; > FO=3D
> >R i :=3D3D 0 TO a.size DO> > > > do s= >omething with a.a[i];> > > >> > > > That=3D
>= > > is "ok". Not great -- what to call the inner a?> > > > Bu= >t then furthermor=3D
> >e, I'd like to construct constants.> &g= >t; > > It seems I am stuck with either =3D
> >the verbose:&g= >t; > > >> > > > PROCEDURE F(a:A);> > > >&g= >t; > > > F( A { ARRAY[0..=3D
> >1] OF FOO { .. } );> &= >gt; > >> > > > OR I have to come up with a name for the = >=3D
> >embedded array.> > > > But of course, its type = >is really "the same" as the =3D
> >outer type.> > >> &= >gt; >> > > Ignoring the fact that the types are different l=3D<= >BR>> >inguistically> > > (one a record type, the other an ar= >ray), the types are d=3D
> >ifferent> > > at a deep seman= >tic level too. The inner array has static> > >=3D
> > siz= >e, the outer one (call it a "variable array", perhaps)> > > has dy= >namic=3D
> >ally changeable size, even more easily changed> >= >; > after it is created tha=3D
> >n a heap-allocated open array= >. This> > > is a significant semantic differen=3D
> >ce, = >so it also makes program> > > design sense to view them as differe= >nt ty=3D
> >pes.> > >> > > >> > > &g= >t; To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[= >0..1]=3D
> > OF Foo;> > > >> > > > TYPE Fo= >oArray =3D3D RECORD> > > > a : FooArray;> > > >=3D<= >BR>> > size :=3D3D 1;> > > > END;> > > >> = >> > > F( FooArray { FooArray { .. } );> >=3D
> > &g= >t; >> > > > But I have to come up with different names.> = >> > >> > > > And I=3D
> > don't think I can l= >eave out the name for the constructor, > > like:> > > >= >=3D
> >> > > > F( FooArray { { .. } );> > >&g= >t; > >> > > Yes, this is a limitation in=3D
> > Mod= >ula-3. Ada allows value constructors> > > to omit inner type names= > in c=3D
> >ases like this, and it is > > convenient. But>= >; > > it also crosses a really=3D
> > major line on complexi= >ty of the language > > semantics,> > > since type an=3D
&= >gt; >alysis information now flows not only upward, but > > also do= >wnward> > > in=3D
> > expression typing. I am mostly cont= >ent to live with this as > > one bit of=3D
> >> > >= > the price of avoiding a horribly over complex language.> > >> = >> > Ord=3D
> >inary procedures can do pretty much all of the= > things done by > > exotic> >=3D
> > > and complex = >language stuff like C++ constructors. If you don't > > want =3D
&g= >t; >to write> > > the ponderous nested value constructor, write= > a constructor >=3D
> > > procedure and> > > call i= >t. As Antony suggested, you can make it accept =3D
> >an open >= > array formal,> > > which then codes just like a simple array= > va=3D
> >lue constructor. You > > could even> > > = >make it elaborate and general, e.g=3D
> .:> > >> > >= >; PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = >=3D3D VAR L=3D
> >Size : CARDINAL> > > ; VAR LResult : A&= >gt; > >> > > ; BEGIN> > > LSize :=3D3D NU=3D
>= >; >MBER ( Val )> > > <* ASSERT LSize <=3D3D NUMBER ( FooA= >rray ) *>> > > ; LResul=3D
> >t . size :=3D3D LSize>= >; > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S= >=3D
> >UBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RET= >URN LResult> > > END Make=3D
> >F> > >> > = >> Alternatively, since your maximum element count is so small, yo=3D
= >> >u > > could> > > write a constructor procedure that= > took two formals of typ=3D
> >e FOO, > > with> > >= > at least the second one optional. (This would require =3D
> >a &g= >t; > distinguished> > > value of type FOO that would be used to= > mean "omit=3D
> >ted".)> > >> > > And, of cours= >e, if you want to use abstraction, you can pu=3D
> >t the > >= >; types,> > > constructor procedures, and various other procedures= > =3D
> >for > > manipulating> > > the variable size= d array in a module, behind an i=3D
> >nterface.> > >>= > > > An additional limitation of Modula-3 in this regard, is=3D
&g= >t; > that you > > can't> > > make the type F opaque, unle= >ss you heap allocate i=3D
> >t, which we > > were trying>= > > > to avoid. Ada would allow you to do this, =3D
> >but it= >'s another > > example of> > > a convenience with high cost.= > It force=3D
> >s the equivalent of the > > revelation> &= >gt; > to be located in the equivalent=3D
> > of the interface, = >but makes it > > illegal> > > to write client code that =3D<= >BR>> >depends on what the revelation is.> > >> > > = >This in turn creates a source =3D
> >code control nightmare in a l= >arge > > project,> > > because now someone who=3D
> &g= >t; wants to make what is really a purely > > internal,> > > = >implementation ch=3D
> >ange, nevertheless has to check out the &g= >t; > interface, and> > > if you aren=3D
> >'t in denia= >l mode, that means implementers of all the > > client> > > c= >ode =3D
> >have to go to extra trouble to somehow find out that wh= >at > > appears> > > =3D
> >to be an interface chang= >e actually doesn't affect them after all.> > >> > >=3D>> > >> > > > Though that might seem nice.> > &g= >t; >> > > > Am I understanding eve=3D
> >rything?&g= >t; > > >> > > > Have folks hit this before and there's= > a set of name=3D
> >s that > > don't seem too lame> >= > > > that folks use?> > > >> > > > Also --=3D= >
> > language documentation?> > > > Nelson's green boo= >k is excellent.> > > > Th=3D
> >e stuff in the doc dir= >ectory is very dry and scientific.> > > > The tutoria=3D
>= >; >l seems more like a reference. Or maybe I didn't > > read it en= >ough.> > > >=3D
> > Is there better, in case I need a = >refresher?> > > > I think I got it, via =3D
> >Nelson'= >s book from memory (wonder if I > > can find mine..) and the referen= >=3D
> >ce,> > > > but I don't think anyone could learn= > from the current online > >=3D
> > docs in the source tree.= >> > > >> > > > Maybe it's me, some combination of = >=3D
> >laziness and short attention > > span> > > &= >gt; as I age..> > > >> > > > Btw, =3D
> >C= > doesn't offer a great solution here, though it offers > > leaving ou= >t som=3D
> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D
> >Modula-3 seems= > to be missing operator overloading.> > > > It's got some bui= >=3D
> >ltin stuff, even array assignment and equality > > an= >d I think> > > > even =3D
> >record assignment and equ= >ality, but it is still a bit > > limiting.> > >> >=3D<= >BR>> > >> > > I have raved on this before, but, having ha= >d lots of painful > > ex=3D
> >perience with> > > u= >ser-defined overloading in Ada and C++, I can say with =3D
> >>= > > authority, that it is> > > a programming language disaster. = >It interact=3D
> >s with just about > > everything> > = >> else in the language, in very complic=3D
> >ated ways, and al= >l it buys > > you is saving> > > time/energy thinking up d= >=3D
> >istinct names for procedures/functions. > > Even this= >,> > > aside from the =3D
> >effects on the language, is = >a net loss, by the > > time you consider> > > r=3D
> &= >gt;eadability along with writability.> > >> > > User-defi= >ned overloaded operat=3D
> >ors provide a slight readability > = >> benefit, _if_> > > used with great res=3D
> >traint = >and discipline, something you can rely > > on not happening.> >= > > Me=3D
> >anwhile, the language complexity can easily double = >or worse. > > And, with =3D
> >the> > > exception o= >f compiler writers and language lawyers who spend > > h=3D
> &g= >t;undreds of hours> > > on just this, programmers don't understand= > the rules,=3D
> > not even > > close.> > >> >= >; > >> > > > Also, if I understand things correc=3D
&g= >t; >tly, this has long bothered > > me about Modula-3,> > &g= >t; > though I'm more t=3D
> >olerant now -- Modula-3 doesn't se= >em to allow > > for lighter wieght> > > >=3D
> >= > objects. Like, small stack allocated structs with member > > functio= >ns. Yo=3D
> >u seem to have> > > > to chose between he= >ap allocated garbage collected vir=3D
> >tual > > member fun= >ctions full> > > > featured objects, or featureless dumb=3D
= >> > structs. It's nice how C+ > > + allow hybrids --> > &= >gt; > objects don't have=3D
> > to be heap allocated and member= > functions > > don't have be virtual.> > > =3D
> >&= >gt; Or am I missing something?> > >> > >> > > C+= >+'s supposedly lighter weight=3D
> > forms of classes/structs with= > > > their special> > > member functions buy =3D
> >= >;nothing that plain records, plain > > procedures, and> > > = >interfaces/modul=3D
> >es don't already provide, again, at signifi= >cant > > and gratuitous> > > lan=3D
> >guage comple= >xity. Except when methods/member functions > > actually dispatc=3D>> >h> > > dynamically, there is nothing that the above won'= >t do, and when > > =3D
> >you create a> > > class i= >nstance as a local variable (i.e., on the stack), =3D
> >it is >= >; > necessarily> > > not polymorphic, that is, it can't change = >its "a=3D
> >llocated" or > > dynamic type> > > amo= >ng various subtypes at runtime. This =3D
> >in turn means it can't= > > > dispatch.> > >> > > So, just use plain procedu= >re=3D
> >s, an interface and a module, and you > > will get&= >gt; > > everything a lighte=3D
> >r-weight C++ class would g= >ive you.> > >> > >> > > >> > > > = >Anyway, I've got=3D
> >ten to accept C a bit more vs. C++ so I can= > > > deal with> > > > t: Type;> =3D
> >> &= >gt; > Type_DoSomething(t);> > > >> > > > in plac= >e of:> > > > t.DoSomething(=3D
> >);> > >>= > > >> > > Exactly. The special "receiver object" in a true m= >ethod c=3D
> >all has > > significant> > > semantic= > differences from an ordinary paramete=3D
> >r and introduces >= > > new complexities> > > and non-orthogonalities. It has =3D>> >some very valuable uses too.> > >> > > But to t= >hen create degenerate forms =3D
> >of it that still carry a lot &g= >t; > of these> > > complexities, but are equiva=3D
> >= >lent in programing power to plain old> > > parameters is just bad = >program d=3D
> >esign and bad language design. > > Objects a= >nd> > > methods are indeed cool=3D
> > for situations tha= >t utilize their > > semantic complexity.> > > But it's d=3D<= >BR>> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D
> >tely sophisticated construct when the = >problem doesn't > > justify it.> > > =3D
> >Some OO= > proponents have gone way over the deep end here.> > >> > &g= >t; >> > > >=3D
> > - Jay> > > >> >= >; > >> > > > > > ----------------------------------= >---------=3D
> >--------------------------- > > --> > = >> > Boo! Scare away worms, viruses an=3D
> >d so much more! = >Try Windows > > Live OneCare! Try now!> > > <http://oneca= >re=3D
> >.live.com/standard/en-us/purchase/trial.aspx? > > s= >_cid=3D3Dwl_hotmailnews>> =3D
> >> >> > >>= > > > --> > > -----------------------------------------------= >------=3D
> >--------> > > Rodney M. Bates, retired assis= >tant professor> > > Dept. of Co=3D
> >mputer Science, Wic= >hita State University> > > Wichita, KS 67260-0083> > > 3= >=3D
> >16-978-3922> > > rodney.bates at wichita.edu> >= > >> > > --> > > ---------------=3D
> >-------= >---------------------------------------> > > Rodney M. Bates, reti= >re=3D
> >d assistant professor> > > Dept. of Computer Sci= >ence, Wichita State Univers=3D
> >ity> > > Wichita, KS 67= >260-0083> > > 316-978-3922> > > rodney.bates at wichita=3DR>> >.edu> >> >> > Boo! Scare away worms, viruses a= >nd so much more! Try Windows =3D
> >Live > > OneCare! Try no= >w!>=3D20
> >___________________________________________________= >______________
> >Climb to the top of the charts!=3DA0 Play Star S= >huffle:=3DA0 the word scramble =3D
> >challenge with star power.R>> >http://club.live.com/star_shuffle.aspx?icid=3D3Dstarshuffle_wlma= >iltextlink_oc=3D
> >t=3D
> >
> >--_0109391c-2ffe= >-4cfe-9165-c2a24628c3c7_
> >Content-Type: text/html; charset=3D"is= >o-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> &= >gt;
> ><html>
> ><head>
> ><style= >>
> >.hmmessage P
> >{
> >margin:0px;
>= > >padding:0px
> >}
> >body.hmmessage
> >{
= >> >FONT-SIZE: 10pt;
> >FONT-FAMILY:Tahoma
> >}
&= >gt; ></style>
> ></head>
> ><body class= >=3D3D'hmmessage'>But if I don't want to pay for heap allocation, I=3D>> > can't say:<BR>
> >&nbsp;<BR>
> &g= >t;VAR T: v;<BR>
> >&nbsp;<BR>
> >ce=3D"">v.DoSomething();<BR>
> &g= >t;&nbsp;<BR>
> >Only IMPORT T FROM M;<BR>
> = >>&nbsp;<BR>
> >VAR T: v;<BR>
> >&n= >bsp;<BR>
> >M.DoSomething(v);<BR>
> >&nbs= >p;<BR>
> >Right?<BR><BR>
> >SPIN I thin= >k you mean.<BR>
> >Anyone build it and bring it up? I was lo= >ng curious but never did..<BR>
> >&nbsp;<BR>
&g= >t; >&nbsp;- Jay<BR><BR><BR>
> >
> &= >gt;<HR id=3D3DstopSpelling>
> ><BR>
> >&g= >t; CC: m3devel at elegosoft.com<BR>&gt; From: darko at darko.org<BR&= >gt;&gt; Subjec=3D
> >t: Re: [M3devel] small array in modula-3?= ><BR>&gt; Date: Thu, 15 Nov 2007 20=3D
> >:29:06 -0800<= >;BR>&gt; To: jay.krell at cornell.edu<BR>&gt; <BR>&= >gt; Not sure wh=3D
> >at the problem is with modules. If you want = >to avoid the <BR>&gt; dot you c=3D
> >an name the type s= >omething unique then import that type <BR>&gt; name. You =3D
&= >gt; >can create an interface with all the nice type names and <BR>= >&gt; import al=3D
> >l those names in modules by adding an EXP= >ORTS clause too.<BR>&gt; <BR>&gt; =3D
> >Perso= >nally I think M3, with a couple of extensions, wouldn't need <BR>&= >;gt; =3D
> >unsafe anything. The unsafe features are there mostly = >because of <BR>&gt; l=3D
> >egacy interfaces. I forget t= >he name but the folk who wrote an OS in <BR>&gt=3D
> >; = >M3 found it very effective with only couple of minor points with <BR>= >&gt;=3D
> > regards to interfacing to C code they built on top= > of, I think one of <BR>=3D
> >&gt; them was being able = >to pass NIL to a VAR parameter, which is a common =3D
> ><BR>= >;&gt; C idiom (and an annoying one for M3 users who then can't use VAR)= >.=3D
> ><BR>&gt; <BR>&gt; <BR>&gt; O= >n 15/11/2007, at 8:08 PM, Jay wrote:<BR>&gt; <B=3D
> >= >;R>&gt; &gt; Rodney, thank you, this is interesting.<BR>&a= >mp;gt; &gt; I definite=3D
> >ly don't want to pay for heap all= >ocation for a tiny array.<BR>&gt; &gt; I d=3D
> >on'= >t know about "subarray". It looks like it takes and returns <BR>&= >gt; &gt=3D
> >; arrays. It's not a type. I ordered another cop= >y of the Nelson book <BR>&g=3D
> >t; &gt; so I don't= > have to find mine.<BR>&gt; &gt;<BR>&gt; &gt; G= >ood idea "=3D
> >MakeT" I forgot about that pattern. I'll try it o= >ut.<BR>&gt; &gt;<BR>&gt; &=3D
> >gt; T= >he record and array I propose are not all that different really.<BR>&= >amp;g=3D
> >t; &gt; I just heard of something new. Have you he= >ard of it? "Duck typing".=3D
> > <BR>&gt; &gt; If it= > acts/quacks/walks like a duck, it is a duck.<BR>&gt; &=3D>> >gt; This is in very dynamic languages like Ruby.<BR>&gt= >; &gt; You apply obj=3D
> >ect.method and if object defines so= >mething named <BR>&gt; &gt; "method", th=3D
> >en it= > "must" have "the" meaning you intend.<BR>&gt; &gt; Kind of l= >ike how C=3D
> >++ templates "accept as parameters whatever <BR= >>&gt; &gt; happens to work".=3D
> ><BR>&gt; &= >amp;gt;<BR>&gt; &gt; Operator overloading is great for string= >s and "m=3D
> >ath".<BR>&gt; &gt;<BR>&gt; = >&gt; Maybe I should try to have this language de=3D
> >bate fr= >om scratch again..?<BR>&gt; &gt;<BR>&gt; &gt; I= > still am conflcted.<=3D
> >BR>&gt; &gt;<BR>&a= >mp;gt; &gt; Modules seem overly heavyweight.<BR>&gt; &gt;= > I d=3D
> >on't want Module1.T, Module2.T, I want T1, T2.<BR>= >;&gt; &gt;<BR>&gt; &gt; C+=3D
> >+ stack str= >ucts with non virtual member functions:<BR>&gt; &gt; class Re= >ct_=3D
> >t<BR>&gt; &gt; {<BR>&gt; &gt= >; Rect_t() : top(0), left(0), right(0), bottom(=3D
> >0) { }<BR= >>&gt; &gt;<BR>&gt; &gt; int Height() { return bott= >om - top; }<BR>&=3D
> >gt; &gt; int Width() { return= > right - left; }<BR>&gt; &gt; int top, left, b=3D
> >= >;ottom, right;<BR>&gt; &gt; };<BR>&gt; &gt;<= >BR>&gt; &gt; seems "good".<BR>&g=3D
> >t; &am= >p;gt;<BR>&gt; &gt; And it seems not really all that complicat= >ed for the c=3D
> >ompiler to <BR>&gt; &gt; flow the= > static type information around to resolve=3D
> > the functions..&= >lt;BR>&gt; &gt;<BR>&gt; &gt; Rect_t r;<BR>&a= >mp;gt; &gt; r.Height(=3D
> >) =3D3D&gt; Rect_Height(&a= >mp;r); ..and would be inlined anyway.<BR>&gt; &gt;<=3D
= >> >BR>&gt; &gt; I do find some compelling features in Modu= >la-3. Mainly that it=3D
> > <BR>&gt; &gt; compiles t= >o native code and has OPTIONAL safety, optional ga=3D
> >rbage <= >;BR>&gt; &gt; collection, and that the syntax of modules/interfa= >ces a=3D
> >llows fast <BR>&gt; &gt; compilation -- = >no longer reparsing the same header=3D
> >s over and over <BR&g= >t;&gt; &gt; and over and over.<BR>&gt; &gt;<BR>= >&gt; &gt; =3D
> >Operator overloading btw..have seen "temp= >late SafeInt"? It acts <BR>&gt; &g=3D
> >t; like a p= >rimitive integer, but raises exceptions upon overflow.<BR>&gt; &a= >mp;=3D
> >gt; For this to work very much requires operator overloa= >ding.<BR>&gt; &gt;<=3D
> >BR>&gt; &gt;= > A point, of course, is to be able to have user defined types t=3D
> = >>hat <BR>&gt; &gt; can act like the built in types..<BR= >>&gt; &gt;<BR>&gt; &g=3D
> >t; - Jay<B= >R>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt= >; &gt; Date: Thu, 15 Nov 2007=3D
> > 18:39:18 -0600<BR>&= >amp;gt; &gt; &gt; From: rodney.bates at wichita.edu<BR>&gt; = >&g=3D
> >t; &gt; To: m3devel at elegosoft.com<BR>&g= >t; &gt; &gt; Subject: Re: [M3devel] =3D
> >small array in = >modula-3?<BR>&gt; &gt; &gt;<BR>&gt; &gt; &a= >mp;gt; Jay wrote:<BR>=3D
> >&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &gt; What is the right way to have a var= >ia=3D
> >bly sized but always small <BR>&gt; &gt; ar= >ray in Modula-3?<BR>&gt; &gt; &g=3D
> >t; &g= >t; My array will only ever have 1 or 2 elements.<BR>&gt; &gt;= > &gt; &gt=3D
> >; I'd like to always allocate room for 2 e= >lements, and have there <BR>&gt; =3D
> >&gt; be a si= >ze.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt;= > &gt; &gt; It seems I ha=3D
> >ve a choice of<BR>&am= >p;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t; a) an "open" a=3D
> >rray<BR>&gt; &gt; &gt;&l= >t;BR>&gt; &gt; &gt; Heap allocated, I presume? If the =3D>> >max size is only 2 elements,<BR>&gt; &gt; &gt; = >this is pretty extravagant, =3D
> >as a heap allocated open array = >will<BR>&gt; &gt; &gt; have 4 extra behind-t=3D
> &= >gt;he-scenes words of space overhead, plus<BR>&gt; &gt; &= >gt; maybe heap fragme=3D
> >ntation, and time overhead of allocati= >on,<BR>&gt; &gt; &gt; collection, and=3D
> > may= >be reduced locality of reference.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &=3D
> >gt; b) wrap it up in a = >record<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &gt;=3D
> > I'd like so have, like:<BR>&= >;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt= >; TYPE=3D
> > A =3D3D ARRAY [0..1] OF FOO;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; A=3D
= >> >nd be able to say:<BR>&gt; &gt; &gt; &gt;<= >;BR>&gt; &gt; &gt; &gt; VAR<BR>&gt=3D
> = >>; &gt; &gt; &gt; a : A;<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; ..<BR=3D
> = >>>&gt; &gt; &gt; &gt; a.size<BR>&gt; &g= >t; &gt; &gt; FOR i :=3D3D 0 TO a.size D=3D
> >O<BR>&= >amp;gt; &gt; &gt; &gt; do something with a[i]<BR>&gt;= > &gt; &gt; &gt;<BR>&=3D
> >gt; &gt; &= >;gt; &gt; It seems I have no option but, like:<BR>&gt; &g= >t; &gt; &=3D
> >gt;<BR>&gt; &gt; &gt; &a= >mp;gt; TYPE A =3D3D RECORD<BR>&gt; &gt; &gt; &gt; a: = >ARRA=3D
> >Y[0..1] OF FOO;<BR>&gt; &gt; &gt; &am= >p;gt; size :=3D3D 1; (* usually of size 1, s=3D
> >ometimes 2 *)&l= >t;BR>&gt; &gt; &gt; &gt; END<BR>&gt; &gt; = >&gt; &gt;<BR>&gt; &gt=3D
> >; &gt; &= >gt; and then<BR>&gt; &gt; &gt; &gt; FOR i :=3D3D 0 TO= > a.size DO<BR>&g=3D
> >t; &gt; &gt; &gt; do = >something with a.a[i];<BR>&gt; &gt; &gt; &gt;<BR&g= >t;&gt; =3D
> >&gt; &gt; &gt; That is "ok". Not gre= >at -- what to call the inner a?<BR>&gt;=3D
> > &gt; = >&gt; &gt; But then furthermore, I'd like to construct constants.<= >;BR>&=3D
> >gt; &gt; &gt; &gt; It seems I am st= >uck with either the verbose:<BR>&gt; &gt=3D
> >; &am= >p;gt; &gt;<BR>&gt; &gt; &gt; &gt; PROCEDURE F(a:A= >);<BR>&gt; &gt; &gt; &gt;=3D
> ><BR>&a= >mp;gt; &gt; &gt; &gt; F( A { ARRAY[0..1] OF FOO { .. } );<BR= >>&gt; &gt; &g=3D
> >t; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; OR I have to come up with a name for the emb=3DR>> >edded array.<BR>&gt; &gt; &gt; &gt; But of= > course, its type is really "the =3D
> >same" as the outer type.&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<B= >R>&gt; &gt; &=3D
> >gt; Ignoring the fact that the = >types are different linguistically<BR>&gt; &=3D
> >g= >t; &gt; (one a record type, the other an array), the types are differen= >t<B=3D
> >R>&gt; &gt; &gt; at a deep semantic le= >vel too. The inner array has static<B=3D
> >R>&gt; &= >gt; &gt; size, the outer one (call it a "variable array", perhaps)<= >=3D
> >BR>&gt; &gt; &gt; has dynamically changeable= > size, even more easily changed=3D
> ><BR>&gt; &gt; = >&gt; after it is created than a heap-allocated open array. Th=3D
>= >; >is<BR>&gt; &gt; &gt; is a significant semantic diff= >erence, so it also makes=3D
> > program<BR>&gt; &gt;= > &gt; design sense to view them as different types.<BR=3D
> &g= >t;>&gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t;<BR>&gt; &gt; &gt; &gt; To wit:<BR>&g=3D<= >BR>> >t; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &gt; TYPE FooArray =3D3D ARRAY[0..1] OF F=3D
> >oo;<BR&g= >t;&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &= >amp;gt; TYPE FooArray =3D3D RECORD<=3D
> >BR>&gt; &g= >t; &gt; &gt; a : FooArray;<BR>&gt; &gt; &gt; &= >;gt; size :=3D3D 1;<BR=3D
> >>&gt; &gt; &gt; &am= >p;gt; END;<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; F( =3D
> >FooArray { FooArray { .. } );&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &am= >p;gt; &gt;=3D
> > But I have to come up with different names.&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt;=3D
> &= >gt; &gt; &gt; &gt; And I don't think I can leave out the name f= >or the construc=3D
> >tor, <BR>&gt; &gt; like:<BR= >>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt;= > &gt; F( F=3D
> >ooArray { { .. } );<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &= >amp;gt; Y=3D
> >es, this is a limitation in Modula-3. Ada allows v= >alue constructors<BR>&gt;=3D
> > &gt; &gt; to om= >it inner type names in cases like this, and it is <BR>&gt; =3D>> >&gt; convenient. But<BR>&gt; &gt; &gt; it a= >lso crosses a really major line =3D
> >on complexity of the langua= >ge <BR>&gt; &gt; semantics,<BR>&gt; &gt; &g= >t; si=3D
> >nce type analysis information now flows not only upwar= >d, but <BR>&gt; &gt; =3D
> >also downward<BR>&= >amp;gt; &gt; &gt; in expression typing. I am mostly content t=3D>> >o live with this as <BR>&gt; &gt; one bit of<BR&= >gt;&gt; &gt; &gt; the price of=3D
> > avoiding a horri= >bly over complex language.<BR>&gt; &gt; &gt;<BR>&am= >p;gt; &gt; =3D
> >&gt; Ordinary procedures can do pretty m= >uch all of the things done by <BR>&=3D
> >gt; &gt; e= >xotic<BR>&gt; &gt; &gt; and complex language stuff like C= >++ const=3D
> >ructors. If you don't <BR>&gt; &gt; w= >ant to write<BR>&gt; &gt; &gt; the pon=3D
> >der= >ous nested value constructor, write a constructor <BR>&gt; &g= >t; procedur=3D
> >e and<BR>&gt; &gt; &gt; call i= >t. As Antony suggested, you can make it accep=3D
> >t an open <= >BR>&gt; &gt; array formal,<BR>&gt; &gt; &gt; w= >hich then codes ju=3D
> >st like a simple array value constructor.= > You <BR>&gt; &gt; could even<BR>&=3D
> >g= >t; &gt; &gt; make it elaborate and general, e.g.:<BR>&gt;= > &gt; &gt;<BR>&gt=3D
> >; &gt; &gt; PROC= >EDURE MakeF ( Val : ARRAY OF FOO ) : F<BR>&gt; &gt; &gt;&= >lt;BR=3D
> >>&gt; &gt; &gt; =3D3D VAR LSize : CARDI= >NAL<BR>&gt; &gt; &gt; ; VAR LResult : =3D
> >A&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; ; BE= >GIN<BR>&gt; &gt; &gt; LSize :=3D3D =3D
> >NUMBER= > ( Val )<BR>&gt; &gt; &gt; &lt;* ASSERT LSize &lt= >;=3D3D NUMBER ( FooArr=3D
> >ay ) *&gt;<BR>&gt; &= >;gt; &gt; ; LResult . size :=3D3D LSize<BR>&gt; &gt; &= >;gt; =3D
> >; SUBARRAY ( LResult . a , 0 , LSize )<BR>&g= >t; &gt; &gt; :=3D3D SUBARRAY ( Va=3D
> >l , FIRST ( Val ) = >, LSize )<BR>&gt; &gt; &gt; ; RETURN LResult<BR>&am= >p;gt; &gt;=3D
> > &gt; END MakeF<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt; Alternatively, since yo=3DR>> >ur maximum element count is so small, you <BR>&gt; &am= >p;gt; could<BR>&gt; &gt; =3D
> >&gt; write a con= >structor procedure that took two formals of type FOO, <BR>&=3D>> >gt; &gt; with<BR>&gt; &gt; &gt; at least th= >e second one optional. (This wou=3D
> >ld require a <BR>&= >;gt; &gt; distinguished<BR>&gt; &gt; &gt; value of ty= >pe FO=3D
> >O that would be used to mean "omitted".)<BR>&= >;gt; &gt; &gt;<BR>&gt; &gt; &gt=3D
> >; = >And, of course, if you want to use abstraction, you can put the <BR>&= >amp;gt; =3D
> >&gt; types,<BR>&gt; &gt; &gt;= > constructor procedures, and various other pro=3D
> >cedures for &= >lt;BR>&gt; &gt; manipulating<BR>&gt; &gt; &gt;= > the variable sized=3D
> > array in a module, behind an interface.= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt=3D<= >BR>> >; An additional limitation of Modula-3 in this regard, is that = >you <BR>&gt;=3D
> > &gt; can't<BR>&gt; &am= >p;gt; &gt; make the type F opaque, unless you heap alloc=3D
> >= >;ate it, which we <BR>&gt; &gt; were trying<BR>&gt;= > &gt; &gt; to avoid. Ada =3D
> >would allow you to do this= >, but it's another <BR>&gt; &gt; example of<BR>&g= >=3D
> >t; &gt; &gt; a convenience with high cost. It force= >s the equivalent of the =3D
> ><BR>&gt; &gt; revelat= >ion<BR>&gt; &gt; &gt; to be located in the equivalent =3D= >
> >of the interface, but makes it <BR>&gt; &gt; ill= >egal<BR>&gt; &gt; &gt; to w=3D
> >rite client co= >de that depends on what the revelation is.<BR>&gt; &gt; &= >gt;<=3D
> >BR>&gt; &gt; &gt; This in turn create= >s a source code control nightmare in a=3D
> > large <BR>&= >;gt; &gt; project,<BR>&gt; &gt; &gt; because now some= >one who wan=3D
> >ts to make what is really a purely <BR>&am= >p;gt; &gt; internal,<BR>&gt; &gt; &gt=3D
> >= >; implementation change, nevertheless has to check out the <BR>&g= >t; &gt; in=3D
> >terface, and<BR>&gt; &gt; &= >gt; if you aren't in denial mode, that means imp=3D
> >lementers o= >f all the <BR>&gt; &gt; client<BR>&gt; &gt; &am= >p;gt; code have to go=3D
> > to extra trouble to somehow find out = >that what <BR>&gt; &gt; appears<BR>&g=3D
> &g= >t;t; &gt; &gt; to be an interface change actually doesn't affect th= >em after a=3D
> >ll.<BR>&gt; &gt; &gt;<BR>= >&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &am= >p;gt; Though =3D
> >that might seem nice.<BR>&gt; &g= >t; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Am I un= >=3D
> >derstanding everything?<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; Have =3D
> >= >;folks hit this before and there's a set of names that <BR>&gt; &= >amp;gt; don't s=3D
> >eem too lame<BR>&gt; &gt; &= >;gt; &gt; that folks use?<BR>&gt; &gt; &gt; &gt;&= >lt;=3D
> >BR>&gt; &gt; &gt; &gt; Also -- langua= >ge documentation?<BR>&gt; &gt; &gt; &g=3D
> >= >;t; Nelson's green book is excellent.<BR>&gt; &gt; &gt; &= >amp;gt; The stuff in th=3D
> >e doc directory is very dry and scie= >ntific.<BR>&gt; &gt; &gt; &gt; The tuto=3D
> &g= >t;rial seems more like a reference. Or maybe I didn't <BR>&gt; &a= >mp;gt; read it e=3D
> >nough.<BR>&gt; &gt; &gt; = >&gt; Is there better, in case I need a refresher?<=3D
> >BR= >>&gt; &gt; &gt; &gt; I think I got it, via Nelson's book= > from memory (won=3D
> >der if I <BR>&gt; &gt; can f= >ind mine..) and the reference,<BR>&gt; &gt; &gt=3D
>= >; >; &gt; but I don't think anyone could learn from the current onli= >ne <BR>&gt=3D
> >; &gt; docs in the source tree.<= >BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &g=3D
> >t; Maybe it's me, some combination of laziness and= > short attention <BR>&gt;=3D
> > &gt; span<BR>= >&gt; &gt; &gt; &gt; as I age..<BR>&gt; &gt; &= >amp;gt; &gt;<BR>&gt;=3D
> > &gt; &gt; &g= >t; Btw, C doesn't offer a great solution here, though it offer=3D
> &= >gt;s <BR>&gt; &gt; leaving out some type names.<BR>&= >;gt; &gt; &gt; &gt; In C++ =3D
> >I could have both .s= >ize and operator[].<BR>&gt; &gt; &gt; &gt; Modula-3 s= >ee=3D
> >ms to be missing operator overloading.<BR>&gt; = >&gt; &gt; &gt; It's got some=3D
> > builtin stuff, eve= >n array assignment and equality <BR>&gt; &gt; and I thin=3DR>> >k<BR>&gt; &gt; &gt; &gt; even record assig= >nment and equality, but it is sti=3D
> >ll a bit <BR>&gt= >; &gt; limiting.<BR>&gt; &gt; &gt;<BR>&gt; = >&gt; &gt;<BR>&gt=3D
> >; &gt; &gt; I hav= >e raved on this before, but, having had lots of painful <B=3D
> &g= >t;R>&gt; &gt; experience with<BR>&gt; &gt; &gt= >; user-defined overloading in A=3D
> >da and C++, I can say with &= >lt;BR>&gt; &gt; authority, that it is<BR>&gt; &gt;= >=3D
> > &gt; a programming language disaster. It interacts wit= >h just about <BR>&gt=3D
> >; &gt; everything<BR&g= >t;&gt; &gt; &gt; else in the language, in very complicat=3D
= >> >ed ways, and all it buys <BR>&gt; &gt; you is saving= ><BR>&gt; &gt; &gt; time=3D
> >/energy thinking u= >p distinct names for procedures/functions. <BR>&gt; &gt; =3D<= >BR>> >Even this,<BR>&gt; &gt; &gt; aside from the e= >ffects on the language, is a n=3D
> >et loss, by the <BR>&am= >p;gt; &gt; time you consider<BR>&gt; &gt; &gt; readab= >ili=3D
> >ty along with writability.<BR>&gt; &gt; &a= >mp;gt;<BR>&gt; &gt; &gt; User-defined=3D
> > ove= >rloaded operators provide a slight readability <BR>&gt; &gt; = >benefit, _=3D
> >if_<BR>&gt; &gt; &gt; used with= > great restraint and discipline, something y=3D
> >ou can rely <= >;BR>&gt; &gt; on not happening.<BR>&gt; &gt; &= >gt; Meanwhile, th=3D
> >e language complexity can easily double or= > worse. <BR>&gt; &gt; And, with t=3D
> >he<BR>= >&gt; &gt; &gt; exception of compiler writers and language lawye= >rs who=3D
> > spend <BR>&gt; &gt; hundreds of hours&= >lt;BR>&gt; &gt; &gt; on just this, prog=3D
> >ramme= >rs don't understand the rules, not even <BR>&gt; &gt; close.&= >lt;BR>&gt; &=3D
> >gt; &gt;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Also, if= > I understan=3D
> >d things correctly, this has long bothered <= >BR>&gt; &gt; me about Modula-3,=3D
> ><BR>&gt= >; &gt; &gt; &gt; though I'm more tolerant now -- Modula-3 doesn= >'t se=3D
> >em to allow <BR>&gt; &gt; for lighter wi= >eght<BR>&gt; &gt; &gt; &gt; objects=3D
> >. = >Like, small stack allocated structs with member <BR>&gt; &gt;= > functions. =3D
> >You seem to have<BR>&gt; &gt; &am= >p;gt; &gt; to chose between heap allocated gar=3D
> >bage coll= >ected virtual <BR>&gt; &gt; member functions full<BR>&a= >mp;gt; &gt; &gt=3D
> >; &gt; featured objects, or feat= >ureless dumb structs. It's nice how C+ <BR>=3D
> >&gt; &= >amp;gt; + allow hybrids --<BR>&gt; &gt; &gt; &gt; obj= >ects don't have to b=3D
> >e heap allocated and member functions &= >lt;BR>&gt; &gt; don't have be virtual.<=3D
> >BR>= >&gt; &gt; &gt; &gt; Or am I missing something?<BR>&am= >p;gt; &gt; &gt;<BR>&gt;=3D
> > &gt; &gt;= ><BR>&gt; &gt; &gt; C++'s supposedly lighter weight forms = >of class=3D
> >es/structs with <BR>&gt; &gt; their s= >pecial<BR>&gt; &gt; &gt; member functi=3D
> >ons= > buy nothing that plain records, plain <BR>&gt; &gt; procedur= >es, and<BR>=3D
> >&gt; &gt; &gt; interfaces/modu= >les don't already provide, again, at signific=3D
> >ant <BR>= >&gt; &gt; and gratuitous<BR>&gt; &gt; &gt; langua= >ge complexity. Exc=3D
> >ept when methods/member functions <BR&= >gt;&gt; &gt; actually dispatch<BR>&gt; &=3D
> &= >gt;gt; &gt; dynamically, there is nothing that the above won't do, and = >when <B=3D
> >R>&gt; &gt; you create a<BR>&= >;gt; &gt; &gt; class instance as a local variab=3D
> >le (= >i.e., on the stack), it is <BR>&gt; &gt; necessarily<BR>= >;&gt; &gt; &gt; =3D
> >not polymorphic, that is, it ca= >n't change its "allocated" or <BR>&gt; &gt; =3D
> >d= >ynamic type<BR>&gt; &gt; &gt; among various subtypes at r= >untime. This in t=3D
> >urn means it can't <BR>&gt; &= >;gt; dispatch.<BR>&gt; &gt; &gt;<BR>&gt; &g= >t; &=3D
> >gt; So, just use plain procedures, an interface and= > a module, and you <BR>&=3D
> >gt; &gt; will get<= >BR>&gt; &gt; &gt; everything a lighter-weight C++ class w=3D= >
> >ould give you.<BR>&gt; &gt; &gt;<BR>&a= >mp;gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt;<B= >=3D
> >R>&gt; &gt; &gt; &gt; Anyway, I've gotte= >n to accept C a bit more vs. C++ so=3D
> > I can <BR>&gt= >; &gt; deal with<BR>&gt; &gt; &gt; &gt; t: Type;&= >lt;BR>&gt; &gt;=3D
> > &gt; &gt; Type_DoSomethi= >ng(t);<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &g=3D
> >t; in place of:<BR>&gt; &g= >t; &gt; &gt; t.DoSomething();<BR>&gt; &gt; &gt;&l= >t;B=3D
> >R>&gt; &gt; &gt;<BR>&gt; &g= >t; &gt; Exactly. The special "receiver object" i=3D
> >n a tru= >e method call has <BR>&gt; &gt; significant<BR>&gt;= > &gt; &gt; semant=3D
> >ic differences from an ordinary pa= >rameter and introduces <BR>&gt; &gt; new =3D
> >comp= >lexities<BR>&gt; &gt; &gt; and non-orthogonalities. It ha= >s some very va=3D
> >luable uses too.<BR>&gt; &gt; &= >amp;gt;<BR>&gt; &gt; &gt; But to then create deg=3D
&g= >t; >enerate forms of it that still carry a lot <BR>&gt; &g= >t; of these<BR>&gt; &=3D
> >gt; &gt; complexitie= >s, but are equivalent in programing power to plain old<=3D
> >B= >R>&gt; &gt; &gt; parameters is just bad program design and b= >ad language de=3D
> sign. <BR>&gt; &gt; Objects and<= >BR>&gt; &gt; &gt; methods are indeed cool f=3D
> >o= >r situations that utilize their <BR>&gt; &gt; semantic comple= >xity.<BR>&gt;=3D
> > &gt; &gt; But it's deeply u= >ncool to try to look superficially cool by usin=3D
> >g an<BR&g= >t;&gt; &gt; &gt; inappropriately sophisticated construct when t= >he pro=3D
> >blem doesn't <BR>&gt; &gt; justify it.&= >lt;BR>&gt; &gt; &gt; Some OO proponents=3D
> > have= > gone way over the deep end here.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; =3D
> >&gt;<BR>&gt; &= >amp;gt; &gt; &gt; - Jay<BR>&gt; &gt; &gt; &gt= >;<BR>&gt; &gt; &gt; =3D
> >&gt;<BR>&am= >p;gt; &gt; &gt; &gt; <BR>&gt; &gt; --------------= >-------------------=3D
> >------------------------------------- &l= >t;BR>&gt; &gt; --<BR>&gt; &gt; &gt; &g=3D<= >BR>> >t; Boo! Scare away worms, viruses and so much more! Try Windows= > <BR>&gt; &g=3D
> >t; Live OneCare! Try now!<BR&g= >t;&gt; &gt; &gt; &lt;http://onecare.live.com/sta=3D
>= > >ndard/en-us/purchase/trial.aspx? <BR>&gt; &gt; s_cid=3D3= >Dwl_hotmailnews&gt;<B=3D
> >R>&gt; &gt; &gt;= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; --= ><BR>&gt; &gt; &gt; -=3D
> >---------------------= >---------------------------------------<BR>&gt; &gt; &=3D= >
> >gt; Rodney M. Bates, retired assistant professor<BR>&= >;gt; &gt; &gt; Dept. of=3D
> > Computer Science, Wichita S= >tate University<BR>&gt; &gt; &gt; Wichita, KS 6=3D
>= >; >7260-0083<BR>&gt; &gt; &gt; 316-978-3922<BR>&= >amp;gt; &gt; &gt; rodney.bates at wic=3D
> >hita.edu<BR>= >;&gt; &gt; &gt;<BR>&gt; &gt; &gt; --<BR>= >;&gt; &gt; &gt; ---------=3D
> >----------------------= >------------------------------<BR>&gt; &gt; &gt; Rodn=3D<= >BR>> >ey M. Bates, retired assistant professor<BR>&gt; &= >;gt; &gt; Dept. of Compute=3D
> >r Science, Wichita State Univ= >ersity<BR>&gt; &gt; &gt; Wichita, KS 67260-008=3D
>= > >3<BR>&gt; &gt; &gt; 316-978-3922<BR>&gt; &= >amp;gt; &gt; rodney.bates at wichita.edu=3D
> ><BR>&gt;= > &gt;<BR>&gt; &gt;<BR>&gt; &gt; Boo! Scare = >away worms, viruses and =3D
> >so much more! Try Windows Live <= >BR>&gt; &gt; OneCare! Try now!<BR>&gt; <BR>=3DR>> ><BR><br /><hr />Climb to the top of the charts= >!=3DA0 Play Star Shuffle:=3DA0 th=3D
> >e word scramble challenge = >with star power. <a href=3D3D'http://club.live.com/=3D
> >star_= >shuffle.aspx?icid=3D3Dstarshuffle_wlmailtextlink_oct' target=3D3D'_new'>= >Pl=3D
> >ay Now!</a></body>
> ></html>= >=3D
> >
> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_--
= >


Help yourself to FREE treats served up daily at the Messeng= >er Caf=E9. ml?ocid=3DTXT_TAGLM_OctWLtagline' target=3D'_new'>Stop by today! >= > >--_85b6c041-9539-4614-b541-8813489e58bb_-- From jay.krell at cornell.edu Sat Nov 17 09:35:10 2007 From: jay.krell at cornell.edu (Jay) Date: Sat, 17 Nov 2007 08:35:10 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: I forgot to point out something I half agree with -- overloading...We have a plain text index over a very large code base. Look for "Close", and hypothetically, I'm making up names here, you find File::Close, Window::Close, Session::Close -- not too bad for the implementations, if you can look for "File::Close", but if you want to find the callers, f.Close, w.Close, s.Close, etc... A "problem" with C++ is that the compiler implements it very well, and nothing else comes close. Good luck evaluating expressions in a debugger, search, "refactoring editors", "wizards" that can change code, etc. It's neat that Modula-3 is simple enough that the remoting feature can be a separate parser over the one language, instead of having a seperate interface language.. But still it is super tempting to have function names qualified by at least the static types of their first parameter or all parameters, if not the dynamic types. Qualification by the dynamic type of the first parameter is if course super common, super popular, even supported in Modula-3.. and maybe in C via function pointers..though at least in C it is obvious when such "switching" is being used (except, even then, it is often hidden by an upper layer -- like, I call ReadFile/WriteFile and then way down under the covers there are drivers to switch between FAT, NTFS, SMB, etc.) As to looseness and "duck typing", well, I see both sides here really.. And I am well aware of how buggy code is.. - Jay > Date: Fri, 16 Nov 2007 22:24:15 +0100> From: lemming at henning-thielemann.de> To: rodney.bates at wichita.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > > On Fri, 16 Nov 2007, Rodney M. Bates wrote:> > > If you don't want to have to write the module name as a qualifier, you can> > rename a procedure too, with a constant declaration (Procedures in Modula-3> > are actually the same thing a constants of procedure type.)> >> > CONST DoSomething = M.DoSomething> > ...> > DoSomething ( v )> > It would have been nice if PROCEDURE declarations would reflect this, like> in functional languages. Say> > CONST> Sin => PROCEDURE (x: LONGREAL;): LONGREAL> BEGIN> ...> RETURN y;> END;> > This would also be the key for anonymous functions or loops as higher> order functions. Just an idea, it's certainly simpler just to use a> functional language. :-) _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Nov 19 13:36:00 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 19 Nov 2007 04:36:00 -0800 Subject: [M3devel] write access to CM3 repository? Message-ID: <200711191236.lAJCa0YE051000@camembert.async.caltech.edu> Hello, Not sure who to write to these days... but it seems I lost my write access to the source repository? I just made the little "sharedboard" demo work on my machine and thought it'd be nice if it were committed. Mika From hosking at cs.purdue.edu Wed Nov 21 21:22:55 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Wed, 21 Nov 2007 15:22:55 -0500 Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <817267.35735.qm@web27105.mail.ukl.yahoo.com> References: <817267.35735.qm@web27105.mail.ukl.yahoo.com> Message-ID: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Have you tried this lately? It seems to work fine for me on Fedora Core. On Oct 30, 2007, at 12:48 PM, Daniel Alejandro Benavides D. wrote: > Hi: > LINUXLIBC6 32 bits, ubuntu dapper > > >Hmm. showheap works fine for me on my I386_DARWIN box. What > >platform are you on? > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro Benavides D. wrote: > > > Hi: > > About this last changes, the runtime can not properly > > feed shownew, with a @M3shownew=shownew. > > The program 'a' is just not started as it seems here, > > altough the window (shownew) does appear, start > > doesn't respond, and it stays there until aborted. > > > > Thanks > > > > --- "Daniel Alejandro Benavides D." > > escribi?: > > > >> Hi: > >> Yes it's working very well. I'm sorry for the delay. > >> Thanks. > >> --- Tony Hosking escribi?: > >> > >>> Please try the latest CVS head. > >>> > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > >>> Benavides D. wrote: > >>> > >>>> Hi: > >>>> Im trying to execute the following program with > >>> the Pthread cvs > >>>> head implementation and I got this when > >> executing > >>> the program: > >>>> > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>> LINUXLIBC6/Main > >>>> Entre dos enteros6 7 > >>>> Estadisticas del Heap > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > >>>> > >>>> > >>>> *** > >>>> *** runtime error: > >>>> *** <*ASSERT*> failed. > >>>> *** file > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line 992 > >>>> *** > >>>> > >>>> Aborted > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>>> > >>>> The assert violated in > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is this: > >>>> PROCEDURE ProcessOther (act: Activation; p: > >>> PROCEDURE (start, > >>>> stop: ADDRESS)) = > >>>> (* LL=activeMu *) > >>>> VAR > >>>> sp: ADDRESS; > >>>> state: RTMachine.ThreadState; > >>>> BEGIN > >>>> <*ASSERT act.state = ActState.Stopped*> > >>>> > >>>> > >>>> The source code of the little program is this: > >>>> > >>>> MODULE Main; > >>>> > >>>> IMPORT SIO; > >>>> IMPORT RTHeapStats; > >>>> IMPORT RTutils; > >>>> IMPORT RTHeapDebug; > >>>> VAR > >>>> varA, varB, varC: INTEGER; > >>>> > >>>> > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > >>>> VAR > >>>> varC: INTEGER; > >>>> BEGIN > >>>> varC:=a*b; > >>>> RETURN varC; > >>>> END multiplicar; > >>>> > >>>> > >>>> BEGIN > >>>> > >>>> SIO.PutText("Entre dos enteros"); > >>>> varA:=SIO.GetInt(); > >>>> varB:=SIO.GetInt(); > >>>> varC:=multiplicar(varA,varB); > >>>> SIO.PutText("Estadisticas del Heap"); > >>>> RTHeapDebug.CheckHeap(); > >>>> RTHeapStats.ReportReachable(); > >>>> (* RTutils.Heap > >>>> > >>> > >> > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > >>>> SIO.PutInt(varC); > >>>> > >>>> END Main. > >>>> > >>>> According to the draft book of Michael Dagenais > >>> Building > >>>> Distributed OO Applications: Modula-3 Objects > >> at > >>> Work, > >>>> RTHeapStats.ReportReachable() > >>>> " ... is called to determine the number > >>>> of active, reachable, objects (i.e. those which > >>> would not be > >>>> garbage collected). Of the 1980 objects on the > >>> heap, only slightly > >>>> more than half are still alive." > >>>> > >>>> According to the interface documentation: > >>>> "reports the number of reachable objects and > >>> bytes from each > >>>> compilation unit, thread stack, and the > >> individual > >>> roots that reach > >>>> the most bytes. The report is written to stderr. > >>> The Modula-3 > >>>> process is frozen during the scanning and > >>> reporting." > >>>> > >>>> Obviously with the previous version of pthread > >> the > >>> things were > >>>> working fine, also with user level > >> implementation > >>>> > >>>> Thanks, > >>>> > >>>> Daniel Benavides > > > ?Descubre una nueva forma de obtener respuestas a tus preguntas! > Entra en Yahoo! Respuestas. From dabenavidesd at yahoo.es Thu Nov 22 20:56:04 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 22 Nov 2007 20:56:04 +0100 (CET) Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Message-ID: <645186.51518.qm@web27114.mail.ukl.yahoo.com> Hi: Yes, it is working; shownew and also the test program. Thanks. --- Tony Hosking wrote: > Have you tried this lately? It seems to work fine > for me on Fedora > Core. > > On Oct 30, 2007, at 12:48 PM, Daniel Alejandro > Benavides D. wrote: > > > Hi: > > LINUXLIBC6 32 bits, ubuntu dapper > > > > >Hmm. showheap works fine for me on my I386_DARWIN > box. What > > >platform are you on? > > > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro > Benavides D. wrote: > > > > > Hi: > > > About this last changes, the runtime can not > properly > > > feed shownew, with a @M3shownew=shownew. > > > The program 'a' is just not started as it seems > here, > > > altough the window (shownew) does appear, start > > > doesn't respond, and it stays there until > aborted. > > > > > > Thanks > > > > > > --- "Daniel Alejandro Benavides D." > > > escribi?: > > > > > >> Hi: > > >> Yes it's working very well. I'm sorry for the > delay. > > >> Thanks. > > >> --- Tony Hosking escribi?: > > >> > > >>> Please try the latest CVS head. > > >>> > > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > > >>> Benavides D. wrote: > > >>> > > >>>> Hi: > > >>>> Im trying to execute the following program > with > > >>> the Pthread cvs > > >>>> head implementation and I got this when > > >> executing > > >>> the program: > > >>>> > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>> LINUXLIBC6/Main > > >>>> Entre dos enteros6 7 > > >>>> Estadisticas del Heap > > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > > >>>> > > >>>> > > >>>> *** > > >>>> *** runtime error: > > >>>> *** <*ASSERT*> failed. > > >>>> *** file > > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line > 992 > > >>>> *** > > >>>> > > >>>> Aborted > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>>> > > >>>> The assert violated in > > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is > this: > > >>>> PROCEDURE ProcessOther (act: Activation; p: > > >>> PROCEDURE (start, > > >>>> stop: ADDRESS)) = > > >>>> (* LL=activeMu *) > > >>>> VAR > > >>>> sp: ADDRESS; > > >>>> state: RTMachine.ThreadState; > > >>>> BEGIN > > >>>> <*ASSERT act.state = ActState.Stopped*> > > >>>> > > >>>> > > >>>> The source code of the little program is > this: > > >>>> > > >>>> MODULE Main; > > >>>> > > >>>> IMPORT SIO; > > >>>> IMPORT RTHeapStats; > > >>>> IMPORT RTutils; > > >>>> IMPORT RTHeapDebug; > > >>>> VAR > > >>>> varA, varB, varC: INTEGER; > > >>>> > > >>>> > > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > > >>>> VAR > > >>>> varC: INTEGER; > > >>>> BEGIN > > >>>> varC:=a*b; > > >>>> RETURN varC; > > >>>> END multiplicar; > > >>>> > > >>>> > > >>>> BEGIN > > >>>> > > >>>> SIO.PutText("Entre dos enteros"); > > >>>> varA:=SIO.GetInt(); > > >>>> varB:=SIO.GetInt(); > > >>>> varC:=multiplicar(varA,varB); > > >>>> SIO.PutText("Estadisticas del Heap"); > > >>>> RTHeapDebug.CheckHeap(); > > >>>> RTHeapStats.ReportReachable(); > > >>>> (* RTutils.Heap > > >>>> > > >>> > > >> > > > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > > >>>> SIO.PutInt(varC); > > >>>> > > >>>> END Main. > > >>>> > > >>>> According to the draft book of Michael > Dagenais > > >>> Building > > >>>> Distributed OO Applications: Modula-3 Objects > > >> at > > >>> Work, > > >>>> RTHeapStats.ReportReachable() > > >>>> " ... is called to determine the number > > >>>> of active, reachable, objects (i.e. those > which > > >>> would not be > > >>>> garbage collected). Of the 1980 objects on > the > > >>> heap, only slightly > > >>>> more than half are still alive." > > >>>> > > >>>> According to the interface documentation: > > >>>> "reports the number of reachable objects and > > >>> bytes from each > > >>>> compilation unit, thread stack, and the > > >> individual > > >>> roots that reach > > >>>> the most bytes. The report is written to > stderr. > > >>> The Modula-3 > > >>>> process is frozen during the scanning and > > >>> reporting." > > >>>> > > >>>> Obviously with the previous version of > pthread > > >> the > > >>> things were > > >>>> working fine, also with user level > > >> implementation > > >>>> > > >>>> Thanks, > > >>>> > > >>>> Daniel Benavides > > > > > > ?Descubre una nueva forma de obtener respuestas a > tus preguntas! > > Entra en Yahoo! Respuestas. > > ______________________________________________ ?Chef por primera vez? S? un mejor Cocinillas. http://es.answers.yahoo.com/info/welcome From lemming at henning-thielemann.de Thu Nov 29 08:08:03 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 08:08:03 +0100 (MET) Subject: [M3devel] Disabling runtime checks Message-ID: I remember that it was already discussed. I found this one: http://groups.google.de/group/comp.lang.modula3/browse_thread/thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check but it seems to be out of date. So once again: How can I disable checks on overflow, array bound violation, NIL pointer etc. in cm3 for the sake of speed? I hoped that '-A' (disable code generation for assertions) would do it, since these checks are like built-in ASSERTs, but I was wrong. From lemming at henning-thielemann.de Thu Nov 29 10:14:21 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 10:14:21 +0100 (MET) Subject: [M3devel] Disabling runtime checks In-Reply-To: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: On Thu, 29 Nov 2007, Mika Nystrom wrote: > For PM3/m3build you can check > > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet! cm3 supports m3_option quake command, but it accepts only the command line options. > Counter-question: does anyone have CM3 working well on Windows? I > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on > Windows 2k/Cygwin. By "well" I mean that everything (including > Network Objects) has to work... I don't know about all the M3 libraries but I could get my stuff to work, including three foreign libraries. http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip From jay.krell at cornell.edu Thu Nov 29 10:23:31 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 09:23:31 +0000 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: I also don't know about all the M3 libraries either, but it can build itself, repeatedly. I know I can start some of the netobj stuff but I don't have a "real" test case. I have the following built from source, should be "easy" for anyone to do so: C:\cm3\bin>dir /b *.exe *.dll /wCalculator.execm3-d5.5.0.execm3.execmpdir.exeCube.exeDeckScape.exedirfp.exefisheye.exefix_nl.exeformsedit.exeJuno.exem3browser.exem3bundle.exem3tohtml.exem3totex.exem3zume.exementor.exemklib.exenetobjd.exeobliq-anim.exeobliq-min.exeobliq-std.exeobliq-ui.exeobliqsrv-std.exeobliqsrv-ui.exeRehearseCode.exereplayheap.exeshobjcodegen.exeshowheap.exeshownew.exeshowthread.exestablegen.exestubgen.exevisobliq.exevocgi.exevoquery.exevorun.exeWebScape.exeanim3D.dllbinIO.dllBitVector.dllcmvbt.dlldb.dlldebug.dlldeepcopy.dllDiGraph.dllembutils.dllevents.dllGeometry.dllhttp.dlljuno-compiler.dlljuno-machine.dlljvideo.dlllibbuf.dlllibsio.dlllistfuncs.dllm3.dllm3codeview.dllm3core.dllm3formsvbt.dllm3formsvbtpixmaps.dllm3markup.dllm3mg.dllm3mgkit.dllm3netobj.dllm3parseparams.dllm3scan.dllm3slisp.dllm3smalldb.dllm3tcl.dllm3tcp.dllm3tk-misc.dllm3tk.dllm3ui.dllm3vbtkit.dllm3zeus.dllmetasyn.dllobliq.dllobliqlibanim.dllobliqlibemb.dllobliqlibm3.dllobliqlibui.dllobliqparse.dllobliqprint.dllobliqrt.dllodbc.dllopengl.dllpatternmatching.dllrdwr.dllserialio.dllset.dllsgml.dllsharedobj.dllSortedTableExtras.dllstable.dllsynex.dllsynwr.dlltable-list.dllTempFiles.dllUDP.dllvideovbt.dllweb.dllwebvbt.dll Bolded what /think/ is relevant. I'm /still/ looking into the int64 stuff... - Jay > Date: Thu, 29 Nov 2007 10:14:21 +0100> From: lemming at henning-thielemann.de> To: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] Disabling runtime checks> > > On Thu, 29 Nov 2007, Mika Nystrom wrote:> > > For PM3/m3build you can check> >> > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html> >> > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet!> > cm3 supports m3_option quake command, but it accepts only the command line> options.> > > Counter-question: does anyone have CM3 working well on Windows? I> > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on> > Windows 2k/Cygwin. By "well" I mean that everything (including> > Network Objects) has to work...> > I don't know about all the M3 libraries but I could get my stuff to work,> including three foreign libraries.> > http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 12:15:34 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 11:15:34 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: please confirm my understanding I don't feel great being a lone reader/changer of code esp. that I didn't write and that lacks sufficient documentation for my small brain/confidence. (I'm not stupid, but this isn't trivial stuff either.) I am bound to make mistakes. In the context of Modula-3 code gen interfaces, and the word interfaces, which apparently are identical/analogous/whatever: There is: Shift (aka, my bad naming, "generic" shift)LeftShiftRightShift LeftShift and RightShift allow only positive shift counts, 0 .. 31 or 0 .. 63 (given particular word sizes and depending on types..) The "front end" checks constants against these.The "front end" inserts checks for variables against these.The back end can assume 0 .. 31 or 0 .. 63. It looks like the x86 back end does redundant masks against 31, at least when shifting by a constant, only in its own data, not in the codegen. Just a small waste of time in the compiler, no negative affect on codegen. "generic" Shift accepts any number for a shift count.Negative numbers mean a right shift.Positive numbers mean a left shift.If the shift count is >31|63 or <-31|63, the result is not an error, but zero. In all cases, right shifts are unsigned, zero filling. There is no shift operation that propagates the sign bit.In the Modula-3 language even. Perhaps, yes, integer division. But the frontend does not optimizethere and turn multiplication or division into shifts, I think, haven't read much of the frontend. The backend could. Rotate is presumably similar, but I have not looked at it.(LeftRotate, RightRotate, Rotate...) m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, very redundanty code, could be combined. The layering is /roughly/ m3x86 on top stackx86 in the middle codex86 at the bottom However m3x86 does call through to codex86 directly.They are largely one layer. There is no strict division."stack" is a simple way to implement some optimizations and stategiesaround constant propagation and register allocation. It is a stack of "operands", which may be constants, globals, or locals.If something is needed in a register, a register will be freed up.If something is later needed and the register hasn't been spilled, it will be reused. If not, not. Presently the operands are assumed to be of word size, 32 bits, register size.That is largely a convenience, and very convenient.I will expand it to allow two word operands.It could be expanded to arbitrarily, at least to "fill" "all" the registers, for some not particularly interesting but theoretically useful scenarios -- passing "medium" sized structs around by value or such. There are ABI concerns though, this could only be amongst local functions that aren't visible/used externally (aka "custom calling conventions"). The "generic" shift (vs. left_shift, right_shift) is implemented in stackx86while left_shift, right_shift are in m3x86. All three functions are very similar,could be combined, and there is no good reason for some to be in one layervs. the other and it's a just a pointless inconsistency. Granted, "generic" shift is a good bit different, it has to check the sign and the magnitude,whereas left and right can just blindly do the operation with no comparisons or branches. Some of this I gather from attempting to compile code with shifts -- esp. the frontend checking of stuff, which then lead me to look at word.i3which declares subranges for the parameters. Is Bill Kalsow around?Or the other original authors?Everyone just figured stuff out from the code, comments, and "literature" (I ordered another copy of Nelson's good book. :) ) - Jay _________________________________________________________________ Connect and share in new ways with Windows Live. http://www.windowslive.com/connect.html?ocid=TXT_TAGLM_Wave2_newways_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 13:41:12 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 12:41:12 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: At one point Linux/x86 didn't use gcc, right? It used the same as the Win32/x86 backend? Anyway, on Win32/x86, small functions like: PROCEDURE F5(b : INTEGER) : INTEGER =BEGIN RETURN Word.Shift(0, b);END F5; result in: _T__F5: 004010C2: 55 push ebp 004010C3: 8B EC mov ebp,esp 004010C5: 81 EC 04 00 00 00 sub esp,4 004010CB: 53 push ebx 004010CC: 56 push esi 004010CD: 57 push edi 004010CE: 33 C0 xor eax,eax 004010D0: 5F pop edi 004010D1: 5E pop esi 004010D2: 5B pop ebx 004010D3: C9 leave 004010D4: C3 ret Now, I can grant that having a consistent frame is nice for stack walkability in a debugger in the absence of symbols, so I won't argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure leave is the state of the art, need to compare to current compiler output). But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. Doesn't it? Looking at the code, and how it avoids having multiple passes, it should be easy to at least track which registers are used, and go back and nop out the pushes, and avoid the pops entirely. Or possibly to move the function ahead up to three bytes, leaving three bytes of padding -- being sure to test recursive code..except anything with a function call, maybe leave alone. I ASSUME nop is faster than push, esp. when combined with saving the pops entirely, ESP. when there are presumably two and three byte nops, so the instruction count can be dropped, even if the byte count cannot easily. Thoughts? Nobody cares 'cause everyone else is using gcc and it handles these things well? - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Nov 29 16:47:40 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:47:40 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <7670DE57-26E8-4A2B-9169-1B77E80C610A@cs.purdue.edu> m3_option("-NoChecks") should do it. For assertions use m3_option("-NoAsserts"). On Nov 29, 2007, at 2:08 AM, Henning Thielemann wrote: > > I remember that it was already discussed. I found this one: > http://groups.google.de/group/comp.lang.modula3/browse_thread/ > thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check > but it seems to be out of date. So once again: How can I disable > checks > on overflow, array bound violation, NIL pointer etc. in cm3 for the > sake > of speed? I hoped that '-A' (disable code generation for assertions) > would do it, since these checks are like built-in ASSERTs, but I was > wrong. From hosking at cs.purdue.edu Thu Nov 29 16:59:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:59:26 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 6:15 AM, Jay wrote: > please confirm my understanding > > I don't feel great being a lone reader/changer of code esp. that I > didn't write and that lacks > sufficient documentation for my small brain/confidence. (I'm not > stupid, but this isn't trivial stuff either.) If you are talking about the native x86 (non-gcc) backend then I concur that it is pretty unreadable. Hence my lack of enthusiasm in working on it myself. > I am bound to make mistakes. We all do! > In the context of Modula-3 code gen interfaces, and the word > interfaces, which apparently are identical/analogous/whatever: > > There is: > > Shift (aka, my bad naming, "generic" shift) Yes, shift by n>0 is shift left. n<0 is shift right. > LeftShift > RightShift > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > or 0 .. 63 (given > particular word sizes and depending on types..) > The "front end" checks constants against these. > The "front end" inserts checks for variables against these. > The back end can assume 0 .. 31 or 0 .. 63. Yes, depending on word-size. > It looks like the x86 back end does redundant masks against 31, at > least when shifting by a constant, > only in its own data, not in the codegen. Just a small waste of > time in the compiler, no negative affect on codegen. > > "generic" Shift accepts any number for a shift count. > Negative numbers mean a right shift. > Positive numbers mean a left shift. > If the shift count is >31|63 or <-31|63, the result is not an > error, but zero. Yes. > In all cases, right shifts are unsigned, zero filling. Yes. > There is no shift operation that propagates the sign bit. > In the Modula-3 language even. Perhaps, yes, integer division. But > the frontend does not optimize > there and turn multiplication or division into shifts, I think, > haven't read much of the frontend. The backend could. Correct. I think the thinking was that a decent back-end would turn integer division by a power of 2 into an arithmetic right shift (the gcc backend certainly does). > Rotate is presumably similar, but I have not looked at it. > (LeftRotate, RightRotate, Rotate...) Weird thing with these is the way the high/low bits are rotated around, so sign can change! > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > very redundanty code, could be combined. > > The layering is /roughly/ > m3x86 on top > stackx86 in the middle > codex86 at the bottom > > However m3x86 does call through to codex86 directly. > They are largely one layer. There is no strict division. > "stack" is a simple way to implement some optimizations and stategies > around constant propagation and register allocation. > > It is a stack of "operands", which may be constants, globals, or > locals. > If something is needed in a register, a register will be freed up. > If something is later needed and the register hasn't been spilled, > it will be > reused. If not, not. > > Presently the operands are assumed to be of word size, 32 bits, > register size. > That is largely a convenience, and very convenient. > I will expand it to allow two word operands. > It could be expanded to arbitrarily, at least to "fill" "all" the > registers, for some > not particularly interesting but theoretically useful scenarios -- > passing "medium" > sized structs around by value or such. There are ABI concerns > though, this could > only be amongst local functions that aren't visible/used > externally (aka "custom calling conventions"). You can make some assumptions about how the front-end uses the middle- end interfaces. For example, it only ever stacks integer things as 32 or 64 bits, even if the integers have a memory representation that is 8 bits, etc. > The "generic" shift (vs. left_shift, right_shift) is implemented in > stackx86 > while left_shift, right_shift are in m3x86. All three functions are > very similar, > could be combined, and there is no good reason for some to be in > one layer > vs. the other and it's a just a pointless inconsistency. > > Granted, "generic" shift is a good bit different, it has to check > the sign and the magnitude, > whereas left and right can just blindly do the operation with no > comparisons or branches. > > Some of this I gather from attempting to compile code with shifts > -- esp. the frontend checking of stuff, which then lead me to look > at word.i3 > which declares subranges for the parameters. > > Is Bill Kalsow around? Good question. Farshad Nayeri may know where he ended up. > Or the other original authors? I know Michel Dagenais had a student who adapted the native x86 backend for use on Linux with PM3. I don't remember the student's name. > Everyone just figured stuff out from the code, comments, and > "literature" (I ordered another copy of Nelson's good book. :) ) > > > - Jay > > > Connect and share in new ways with Windows Live. Connect now! From hosking at cs.purdue.edu Thu Nov 29 17:02:42 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 11:02:42 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> On Nov 29, 2007, at 7:41 AM, Jay wrote: > At one point Linux/x86 didn't use gcc, right? It used the same as > the Win32/x86 backend? > > Anyway, on Win32/x86, small functions like: > > PROCEDURE F5(b : INTEGER) : INTEGER = > BEGIN > RETURN Word.Shift(0, b); > END F5; > > result in: > > _T__F5: > 004010C2: 55 push ebp > 004010C3: 8B EC mov ebp,esp > 004010C5: 81 EC 04 00 00 00 sub esp,4 > 004010CB: 53 push ebx > 004010CC: 56 push esi > 004010CD: 57 push edi > 004010CE: 33 C0 xor eax,eax > 004010D0: 5F pop edi > 004010D1: 5E pop esi > 004010D2: 5B pop ebx > 004010D3: C9 leave > 004010D4: C3 ret > > Now, I can grant that having a consistent frame is nice for stack > walkability in a debugger in the absence of symbols, so I won't > argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure > leave is the state of the art, need to compare to current compiler > output). > > But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. > Doesn't it? > > Looking at the code, and how it avoids having multiple passes, it > should be easy to at least track which registers are used, and go > back and nop out the pushes, and avoid the pops entirely. > > Or possibly to move the function ahead up to three bytes, leaving > three bytes of padding -- being sure to test recursive code..except > anything with a function call, maybe leave alone. I ASSUME nop is > faster than push, esp. when combined with saving the pops entirely, > ESP. when there are presumably two and three byte nops, so the > instruction count can be dropped, even if the byte count cannot > easily. > > Thoughts? Sounds reasonable. Having glanced at the native x86 backend I believe it really needs a good shake-out to bring it up to speed. > Nobody cares 'cause everyone else is using gcc and it handles these > things well? I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. > > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! :-) From rcolebur at scires.com Thu Nov 29 19:30:46 2007 From: rcolebur at scires.com (Randy Coleburn) Date: Thu, 29 Nov 2007 13:30:46 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> Message-ID: <474EBF06.1E75.00D7.1@scires.com> I am willing to help test stuff on the Windows platform, but I won't be much help with low-level stuff like what Jay is doing now. I have a working cm3 v4.1 on Windows. I tried a few weeks ago to get the "current" cm3 working on Windows, but ran into trouble. I say "current" in quotes, because I was downloading the tarballs. I presume there is more recent stuff avail via CVS. Can someone let me know how to check out the latest "stable" sources from CVS? I'll give it another try if someone can point me to the right code. If stuff breaks, I can provide feedback. Also, if I can get the new cm3 working on Windows, I should be able to complete the work on getting the CM3IDE (aka Reactor) ready for release. Regards, Randy Randy C. Coleburn, CISSP Senior Systems Engineer, Communications, Networks, & Electronics Division (CNE) Corporate & Atlanta Information Systems Security Manager (ISSM) Scientific Research Corporation 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) 989-9497 Quality Policy: "SRC CNE Division is committed to delivering continually improving research & engineering excellence that meets or exceeds customer requirements." >>> Tony Hosking 11/29/2007 11:02 AM >>> > At one point Linux/x86 didn't use gcc, right? It used the same as I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 4492 bytes Desc: S/MIME Cryptographic Signature URL: From hosking at cs.purdue.edu Thu Nov 29 21:11:59 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 15:11:59 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <474EBF06.1E75.00D7.1@scires.com> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> Message-ID: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote: > I am willing to help test stuff on the Windows platform, but I > won't be much help with low-level stuff like what Jay is doing now. > > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > get the "current" cm3 working on Windows, but ran into trouble. I > say "current" in quotes, because I was downloading the tarballs. I > presume there is more recent stuff avail via CVS. > > Can someone let me know how to check out the latest "stable" > sources from CVS? I'll give it another try if someone can point me > to the right code. If stuff breaks, I can provide feedback. Jay is probably your best resource on this. > Also, if I can get the new cm3 working on Windows, I should be > able to complete the work on getting the CM3IDE (aka Reactor) ready > for release. That would be very cool! > > Regards, > Randy > > Randy C. Coleburn, CISSP > Senior Systems Engineer, Communications, Networks, & Electronics > Division (CNE) > Corporate & Atlanta Information Systems Security Manager (ISSM) > Scientific Research Corporation > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > 989-9497 > > Quality Policy: "SRC CNE Division is committed to delivering > continually improving research & engineering excellence that meets > or exceeds customer requirements." > > >>> Tony Hosking 11/29/2007 11:02 AM >>> > > At one point Linux/x86 didn't use gcc, right? It used the same as > I haven't tried the CygWin (gcc-backend) based build of CM3 for > Windows, but clearly we need a good story for Windows-based CM3. Jay > you have done a great job keeping this branch of the system alive. I > certainly hope you can keep it up. Not being a Windows user myself, > I do lack the incentive (and expertise) to keep things going for > Windows. That's why we need people like you to help out. > From lemming at henning-thielemann.de Thu Nov 29 21:43:49 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 21:43:49 +0100 (CET) Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: On Thu, 29 Nov 2007, Tony Hosking wrote: > m3_option("-NoChecks") should do it. Is this documented somewhere? > For assertions use m3_option("-NoAsserts"). $ cm3 -O -A -keep unsupported m3_option value: "-NoChecks" Sorry, it's not the newest version: $ cm3 -version Critical Mass Modula-3 version 5.2.6 last updated: 2003-06-27 configuration: /usr/local/cm3/bin/cm3.cfg From hosking at cs.purdue.edu Thu Nov 29 22:06:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 16:06:26 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: Hmmm... On Nov 29, 2007, at 3:43 PM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? > >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" > > > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg From wagner at elegosoft.com Thu Nov 29 23:08:58 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Thu, 29 Nov 2007 23:08:58 +0100 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Quoting Henning Thielemann : > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? Actually yes, it is: http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html But I'm afraid that the documentation hasn't been updated for CM3 5.x in this respect, as Critical Mass never release it and Michael and I simply had not the resources to check every detail. So it will be out of date :-( >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" That's what I meant ;-/ > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg Later does not necessary mean better documented. A quick grep through the code does produce this though: .../cm3/m3-sys/m3front/src/misc/Host.m3 ELSIF (Text.Equal (t, "-NoChecks")) THEN doAsserts := FALSE; doNarrowChk := FALSE; doRangeChk := FALSE; doReturnChk := FALSE; doCaseChk := FALSE; doTCaseChk := FALSE; doNilChk := FALSE; doRaisesChk := FALSE; doDebugs := FALSE; So actually it seems like it should work; perhaps only the m3_option embedding is broken. ... It seems to be set from M3_OPTIONS in cm3.cfg: s.m3_options := GetConfigArray (s, "M3_OPTIONS"); So I'd try to set it there. Perhaps cm3 -D'M3_OPTIONS=[ "NoChecks" ]" will work, too. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From hosking at cs.purdue.edu Fri Nov 30 00:19:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 18:19:05 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <9DDF7EB7-803E-4781-8139-06BFCD2D4F78@cs.purdue.edu> On Nov 29, 2007, at 5:08 PM, Olaf Wagner wrote: > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" Ah, yes, that seems to be the trick. I think you can do: cm3 -DM3_OPTIONS="-NoChecks" as well. > > will work, too. > > Olaf > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > From jay.krell at cornell.edu Fri Nov 30 02:22:09 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:22:09 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: I haven't tried this in a few weeks, but the following should work. This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever. It is not particularly current, but it should work, by design and by my latest testing. (Until such time as a newer distribution is available, I assume a need to bootstrap from this, but perhaps not anything older). Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:28:12 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:28:12 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: Thanks! It helps to know I'm understanding things correctly. The backend isn't bad really, it's written by someone who very much knew what they were doing, which is necessary. > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that Understood. Actually, btw, the front/middleend could do more easy optimizations, like some of the ones I already commited, and really, all the constant propagation that m3x86.m3 does, via its stack stuff and remembering if something is "immediate". I should look into that some time....... - Jay > From: hosking at cs.purdue.edu> Date: Thu, 29 Nov 2007 10:59:26 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] "please confirm my understanding"> > > On Nov 29, 2007, at 6:15 AM, Jay wrote:> > > please confirm my understanding> >> > I don't feel great being a lone reader/changer of code esp. that I > > didn't write and that lacks> > sufficient documentation for my small brain/confidence. (I'm not > > stupid, but this isn't trivial stuff either.)> > If you are talking about the native x86 (non-gcc) backend then I > concur that it is pretty unreadable. Hence my lack of enthusiasm in > working on it myself.> > > I am bound to make mistakes.> > We all do!> > > In the context of Modula-3 code gen interfaces, and the word > > interfaces, which apparently are identical/analogous/whatever:> >> > There is:> >> > Shift (aka, my bad naming, "generic" shift)> > Yes, shift by n>0 is shift left. n<0 is shift right.> > > LeftShift> > RightShift> >> > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > or 0 .. 63 (given> > particular word sizes and depending on types..)> > The "front end" checks constants against these.> > The "front end" inserts checks for variables against these.> > The back end can assume 0 .. 31 or 0 .. 63.> > Yes, depending on word-size.> > > It looks like the x86 back end does redundant masks against 31, at > > least when shifting by a constant,> > only in its own data, not in the codegen. Just a small waste of > > time in the compiler, no negative affect on codegen.> >> > "generic" Shift accepts any number for a shift count.> > Negative numbers mean a right shift.> > Positive numbers mean a left shift.> > If the shift count is >31|63 or <-31|63, the result is not an > > error, but zero.> > Yes.> > > In all cases, right shifts are unsigned, zero filling.> > Yes.> > > There is no shift operation that propagates the sign bit.> > In the Modula-3 language even. Perhaps, yes, integer division. But > > the frontend does not optimize> > there and turn multiplication or division into shifts, I think, > > haven't read much of the frontend. The backend could.> > Correct. I think the thinking was that a decent back-end would turn > integer division by a power of 2 into an arithmetic right shift (the > gcc backend certainly does).> > > Rotate is presumably similar, but I have not looked at it.> > (LeftRotate, RightRotate, Rotate...)> > Weird thing with these is the way the high/low bits are rotated > around, so sign can change!> > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift,> > very redundanty code, could be combined.> >> > The layering is /roughly/> > m3x86 on top> > stackx86 in the middle> > codex86 at the bottom> >> > However m3x86 does call through to codex86 directly.> > They are largely one layer. There is no strict division.> > "stack" is a simple way to implement some optimizations and stategies> > around constant propagation and register allocation.> >> > It is a stack of "operands", which may be constants, globals, or > > locals.> > If something is needed in a register, a register will be freed up.> > If something is later needed and the register hasn't been spilled, > > it will be> > reused. If not, not.> >> > Presently the operands are assumed to be of word size, 32 bits, > > register size.> > That is largely a convenience, and very convenient.> > I will expand it to allow two word operands.> > It could be expanded to arbitrarily, at least to "fill" "all" the > > registers, for some> > not particularly interesting but theoretically useful scenarios -- > > passing "medium"> > sized structs around by value or such. There are ABI concerns > > though, this could> > only be amongst local functions that aren't visible/used > > externally (aka "custom calling conventions").> > You can make some assumptions about how the front-end uses the middle- > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that > is 8 bits, etc.> > > The "generic" shift (vs. left_shift, right_shift) is implemented in > > stackx86> > while left_shift, right_shift are in m3x86. All three functions are > > very similar,> > could be combined, and there is no good reason for some to be in > > one layer> > vs. the other and it's a just a pointless inconsistency.> >> > Granted, "generic" shift is a good bit different, it has to check > > the sign and the magnitude,> > whereas left and right can just blindly do the operation with no > > comparisons or branches.> >> > Some of this I gather from attempting to compile code with shifts > > -- esp. the frontend checking of stuff, which then lead me to look > > at word.i3> > which declares subranges for the parameters.> >> > Is Bill Kalsow around?> > Good question. Farshad Nayeri may know where he ended up.> > > Or the other original authors?> > I know Michel Dagenais had a student who adapted the native x86 > backend for use on Linux with PM3. I don't remember the student's name.> > > Everyone just figured stuff out from the code, comments, and > > "literature" (I ordered another copy of Nelson's good book. :) )> >> >> > - Jay> >> >> > Connect and share in new ways with Windows Live. Connect now!> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:31:49 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:31:49 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: oops C:\net\modula3>tar tf cm3-min-WIN32-NT386-5.2.6.tar.bz2 cm3-min-WIN32-NT386-5.2.6/ cm3-min-WIN32-NT386-5.2.6/cminstall.exe cm3-min-WIN32-NT386-5.2.6/COPYRIGHT-CMASS cm3-min-WIN32-NT386-5.2.6/cygwin.dll cm3-min-WIN32-NT386-5.2.6/gzip.exe cm3-min-WIN32-NT386-5.2.6/system.tgz cm3-min-WIN32-NT386-5.2.6/tar.exe It is system.tgz that can be extracted into c:\cm3. You can dispense with the rest. Older versions of tar, such as the one in this distribution, require the z flag. Newer ones do not. - Jay From: jay.krell at cornell.eduTo: hosking at cs.purdue.edu; rcolebur at scires.comDate: Fri, 30 Nov 2007 01:22:09 +0000CC: m3devel at elegosoft.comSubject: Re: [M3devel] win32/x86 prolog/epilog I haven't tried this in a few weeks, but the following should work.This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever.It is not particularly current, but it should work, by design and by my latest testing. (Until suchtime as a newer distribution is available, I assume a need to bootstrap from this, but perhapsnot anything older).Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:48:36 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:48:36 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:59:43 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:59:43 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. x86 only. - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 01:48:36 +0000Subject: [M3devel] some more notes on the win32 system some more notes on the win32 system> setup your C++ compiler/linkerYou can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking.What you need in particular arecl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path.%LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker.msvcrt.lib must be in one of them.Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 08:28:16 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 07:28:16 +0000 Subject: [M3devel] non-gcc backend Message-ID: I thought the last Digital release used the non-gcc backend for Linux x86. My mistake I see. The next thing to look into is the Critical Mass release, which I can't get to at the moment. - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 11:03:46 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 10:03:46 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: <20071130095354.8D45B10D4540@birch.elegosoft.com> References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...) Note that currently you have to use Visual C++ 6.0 or newer. I tested 2.0, 6.0, 8.0. 2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...) I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so. I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 12:50:21 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 11:50:21 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: Older than 6.0 should work now.. I probe the linker in sysinfo.cmd.. 7.1 Express which lacks msvcrt.lib should work now too, I probe for msvcrt.lib. The probing methods may be considered..not great..and "inspired" by autoconf..try stuff, see if it works, or sniff the error message (not sure if autoconf sniffs error messages). The testing remains..light. Stuff like run upgrade or do-pkg-core, not with all VC toolsets, not always going back to cm3 5.2.6. I've got 2.0,4.0,4.1,4.2,5.0,6.0,7.0,7.1, 8.0, sometimes just express, but not patience/time. The oldest officially supported by Microsoft I believe is 7.0. Really this is just a way to procrastinate on the int64 stuff and real work.. :( - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 10:03:46 +0000Subject: [M3devel] FW: fix win32 bootstrapping m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...)Note that currently you have to use Visual C++ 6.0 or newer.I tested 2.0, 6.0, 8.0.2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...)I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so.I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Fri Nov 30 14:25:09 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 30 Nov 2007 14:25:09 +0100 (CET) Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: On Thu, 29 Nov 2007, Olaf Wagner wrote: > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html Aha. > It seems to be set from M3_OPTIONS in cm3.cfg: > > s.m3_options := GetConfigArray (s, "M3_OPTIONS"); > > So I'd try to set it there. Perhaps > > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" > > will work, too. $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: ) Fatal Error: package build failed But, the following works: $ cm3 -O -D'M3_OPTIONS+=-NoChecks' where there must be no space between = and -. Many thanks for the help! I'm trying to read the code that cm3 produces, because I thought that the simple loop I wrote needs too much time. I'm sitting in front of an Intel machine and I do not really understand the Intel assembly code (I'm used to Motorola :-), but according to the line numbering (.loc directive) it seems that 'ROUND' and friends needs lot of time. The count of assembly commands is reduced by -NoChecks but still around 20 commands. It seems that ROUND, FLOOR and CEILING are implemented manually (checks for negative numbers), whereas TRUNC is the shortest, but still about 9 commands. I do not know whether Intel processors have primitives for several rounding modes. From hosking at cs.purdue.edu Fri Nov 30 15:03:39 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:03:39 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Shouldn't Jay's notes go somewhere on the CM3 Web-site? On Nov 29, 2007, at 8:48 PM, Jay wrote: > some more notes on the win32 system > > > setup your C++ compiler/linker > > You can/should "play dumb", skip that, and just run upgrade. > See what errors you get. > I tried to put in the right amount of up front sanity checking. > > What you need in particular are > > cl and link on the %PATH%. > See, cminstall would have you specify full paths, my > configuration uses %PATH%. > If using VS2005 (8) or newer, mt on the path. > > %LIB% is a semicolon delimited list of directories. > That is a feature of the Microsoft linker. > msvcrt.lib must be in one of them. > > Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, > 7.0, 7.1, 8.0 -- should work. > I have tested all of them some and many required small changes in > one particular spot, > that actually is only used by "maintainers" (C:\dev2\cm3\m3-win > \import-libs\src\make-lib-1.cmd). > I use 8.0 the most lately. > I haven't done much with 9.0. > > Another thing, fairly redundant: > > C:\dev2\cm3\m3-win>more vcredist.txt > On computers without Visual C++ 2005 or CLR 2.0 installed, download > and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- > from either > > RTM (release to manufacturing): > http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE- > A3F9-4C13-9C99-220B62A191EE > > or Service Pack 1: > http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9- > ae1a-4a14-984d-389c36f85647 > > You can find those searching the web for vcredist, no real need to > recort the URLs. That's about it. > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! From hosking at cs.purdue.edu Fri Nov 30 15:02:53 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:02:53 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 8:28 PM, Jay wrote: > Thanks! It helps to know I'm understanding things correctly. > > The backend isn't bad really, it's written by someone who very much > knew what they were doing, which is necessary. > > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > Understood. > > Actually, btw, the front/middleend could do more easy > optimizations, like some of the ones I already commited, and > really, all the constant propagation that m3x86.m3 does, via its > stack stuff and remembering if something is "immediate". I should > look into that some time....... I'd be leery of complicating the front/middle-ends with optimizations given that backends can do them (ie, gcc/m3x86). > > > - Jay > > > > From: hosking at cs.purdue.edu > > Date: Thu, 29 Nov 2007 10:59:26 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] "please confirm my understanding" > > > > > > On Nov 29, 2007, at 6:15 AM, Jay wrote: > > > > > please confirm my understanding > > > > > > I don't feel great being a lone reader/changer of code esp. that I > > > didn't write and that lacks > > > sufficient documentation for my small brain/confidence. (I'm not > > > stupid, but this isn't trivial stuff either.) > > > > If you are talking about the native x86 (non-gcc) backend then I > > concur that it is pretty unreadable. Hence my lack of enthusiasm in > > working on it myself. > > > > > I am bound to make mistakes. > > > > We all do! > > > > > In the context of Modula-3 code gen interfaces, and the word > > > interfaces, which apparently are identical/analogous/whatever: > > > > > > There is: > > > > > > Shift (aka, my bad naming, "generic" shift) > > > > Yes, shift by n>0 is shift left. n<0 is shift right. > > > > > LeftShift > > > RightShift > > > > > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > > or 0 .. 63 (given > > > particular word sizes and depending on types..) > > > The "front end" checks constants against these. > > > The "front end" inserts checks for variables against these. > > > The back end can assume 0 .. 31 or 0 .. 63. > > > > Yes, depending on word-size. > > > > > It looks like the x86 back end does redundant masks against 31, at > > > least when shifting by a constant, > > > only in its own data, not in the codegen. Just a small waste of > > > time in the compiler, no negative affect on codegen. > > > > > > "generic" Shift accepts any number for a shift count. > > > Negative numbers mean a right shift. > > > Positive numbers mean a left shift. > > > If the shift count is >31|63 or <-31|63, the result is not an > > > error, but zero. > > > > Yes. > > > > > In all cases, right shifts are unsigned, zero filling. > > > > Yes. > > > > > There is no shift operation that propagates the sign bit. > > > In the Modula-3 language even. Perhaps, yes, integer division. But > > > the frontend does not optimize > > > there and turn multiplication or division into shifts, I think, > > > haven't read much of the frontend. The backend could. > > > > Correct. I think the thinking was that a decent back-end would turn > > integer division by a power of 2 into an arithmetic right shift (the > > gcc backend certainly does). > > > > > Rotate is presumably similar, but I have not looked at it. > > > (LeftRotate, RightRotate, Rotate...) > > > > Weird thing with these is the way the high/low bits are rotated > > around, so sign can change! > > > > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > > > very redundanty code, could be combined. > > > > > > The layering is /roughly/ > > > m3x86 on top > > > stackx86 in the middle > > > codex86 at the bottom > > > > > > However m3x86 does call through to codex86 directly. > > > They are largely one layer. There is no strict division. > > > "stack" is a simple way to implement some optimizations and > stategies > > > around constant propagation and register allocation. > > > > > > It is a stack of "operands", which may be constants, globals, or > > > locals. > > > If something is needed in a register, a register will be freed up. > > > If something is later needed and the register hasn't been spilled, > > > it will be > > > reused. If not, not. > > > > > > Presently the operands are assumed to be of word size, 32 bits, > > > register size. > > > That is largely a convenience, and very convenient. > > > I will expand it to allow two word operands. > > > It could be expanded to arbitrarily, at least to "fill" "all" the > > > registers, for some > > > not particularly interesting but theoretically useful scenarios -- > > > passing "medium" > > > sized structs around by value or such. There are ABI concerns > > > though, this could > > > only be amongst local functions that aren't visible/used > > > externally (aka "custom calling conventions"). > > > > You can make some assumptions about how the front-end uses the > middle- > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > is 8 bits, etc. > > > > > The "generic" shift (vs. left_shift, right_shift) is > implemented in > > > stackx86 > > > while left_shift, right_shift are in m3x86. All three functions > are > > > very similar, > > > could be combined, and there is no good reason for some to be in > > > one layer > > > vs. the other and it's a just a pointless inconsistency. > > > > > > Granted, "generic" shift is a good bit different, it has to check > > > the sign and the magnitude, > > > whereas left and right can just blindly do the operation with no > > > comparisons or branches. > > > > > > Some of this I gather from attempting to compile code with shifts > > > -- esp. the frontend checking of stuff, which then lead me to look > > > at word.i3 > > > which declares subranges for the parameters. > > > > > > Is Bill Kalsow around? > > > > Good question. Farshad Nayeri may know where he ended up. > > > > > Or the other original authors? > > > > I know Michel Dagenais had a student who adapted the native x86 > > backend for use on Linux with PM3. I don't remember the student's > name. > > > > > Everyone just figured stuff out from the code, comments, and > > > "literature" (I ordered another copy of Nelson's good book. :) ) > > > > > > > > > - Jay > > > > > > > > > Connect and share in new ways with Windows Live. Connect now! > > > > > You keep typing, we keep giving. Download Messenger and join the > i?m Initiative now. Join in! From hosking at cs.purdue.edu Fri Nov 30 15:12:23 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:12:23 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: Message-ID: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> CMass (Bill Kalsow) were the ones to do the x86 backend I think. On Nov 30, 2007, at 2:28 AM, Jay wrote: > I thought the last Digital release used the non-gcc backend for > Linux x86. My mistake I see. > The next thing to look into is the Critical Mass release, which I > can't get to at the moment. > > - Jay > > Get the power of Windows + Web with the new Windows Live. Power up! From hosking at cs.purdue.edu Fri Nov 30 15:17:27 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:17:27 -0500 Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <625C608A-B7F8-4F7E-A657-EBE2288B77BB@cs.purdue.edu> On Nov 30, 2007, at 8:25 AM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Olaf Wagner wrote: > >> http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Aha. > >> It seems to be set from M3_OPTIONS in cm3.cfg: >> >> s.m3_options := GetConfigArray (s, "M3_OPTIONS"); >> >> So I'd try to set it there. Perhaps >> >> cm3 -D'M3_OPTIONS=[ "NoChecks" ]" >> >> will work, too. > > > $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' > LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: > ) > Fatal Error: package build failed > > > But, the following works: > $ cm3 -O -D'M3_OPTIONS+=-NoChecks' > > where there must be no space between = and -. > > Many thanks for the help! > > I'm trying to read the code that cm3 produces, because I thought > that the > simple loop I wrote needs too much time. I'm sitting in front of an > Intel > machine and I do not really understand the Intel assembly code (I'm > used > to Motorola :-), but according to the line numbering (.loc > directive) it > seems that 'ROUND' and friends needs lot of time. The count of > assembly > commands is reduced by -NoChecks but still around 20 commands. It > seems > that ROUND, FLOOR and CEILING are implemented manually (checks for > negative numbers), whereas TRUNC is the shortest, but still about 9 > commands. I do not know whether Intel processors have primitives for > several rounding modes. I think the issue here is that GCC's round/trunc/ceiling don't match the M3 spec particularly well. I'd have to look more closely. From jay.krell at cornell.edu Fri Nov 30 15:44:42 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 14:44:42 +0000 Subject: [M3devel] non-gcc backend In-Reply-To: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: Well that I can contradict. Digital (Bill Kalsow) did the x86 backend.Attached is from boot-LINUXELF.tar.bz2 (originally some other compression). 2) Unpack "boot-XYZ.tar.gz": gunzip < boot-XYZ.tar.gz | tar xpof - 3) Inside the boot-XYZ directory that gets created, unpack "m3cc.tar.gz". It's the gcc-based backend. cd boot-XYZ gunzip < ../m3cc.tar.gz | tar xpof - On Windows 95 and Windows NT, m3cc is not used. This step should be skipped. I think a C producing backend would be useful, to quickly get Windows IA64 and AMD64 support... - Jay > From: hosking at cs.purdue.edu> Date: Fri, 30 Nov 2007 09:12:23 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] non-gcc backend> > CMass (Bill Kalsow) were the ones to do the x86 backend I think.> > On Nov 30, 2007, at 2:28 AM, Jay wrote:> > > I thought the last Digital release used the non-gcc backend for > > Linux x86. My mistake I see.> > The next thing to look into is the Critical Mass release, which I > > can't get to at the moment.> >> > - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: NOTES URL: From hosking at cs.purdue.edu Fri Nov 30 17:49:25 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 11:49:25 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: On Nov 30, 2007, at 9:44 AM, Jay wrote: > Well that I can contradict. Digital (Bill Kalsow) did the x86 backend. > Attached is from boot-LINUXELF.tar.bz2 (originally some other > compression). > > 2) Unpack "boot-XYZ.tar.gz": > gunzip < boot-XYZ.tar.gz | tar xpof - > 3) Inside the boot-XYZ directory that gets created, > unpack "m3cc.tar.gz". It's the gcc-based backend. > cd boot-XYZ > gunzip < ../m3cc.tar.gz | tar xpof - > On Windows 95 and Windows NT, m3cc is not used. This step should > be skipped. > > I think a C producing backend would be useful, to quickly get > Windows IA64 and AMD64 support... There was a C-producing backend in the bad old days. Is it still around anywhere? Also, I know there were experimental BURS-based backends too. An alternative to C might be C-- or llvm. > > > - Jay > > > > > From: hosking at cs.purdue.edu > > Date: Fri, 30 Nov 2007 09:12:23 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] non-gcc backend > > > > CMass (Bill Kalsow) were the ones to do the x86 backend I think. > > > > On Nov 30, 2007, at 2:28 AM, Jay wrote: > > > > > I thought the last Digital release used the non-gcc backend for > > > Linux x86. My mistake I see. > > > The next thing to look into is the Critical Mass release, which I > > > can't get to at the moment. > > > > > > - Jay > > > Get the power of Windows + Web with the new Windows Live. Power up! > From wagner at elegosoft.com Fri Nov 30 20:24:12 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 30 Nov 2007 20:24:12 +0100 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Message-ID: <20071130202412.8mewmacdssoso04s@mail.elegosoft.com> Quoting Tony Hosking : > Shouldn't Jay's notes go somewhere on the CM3 Web-site? Sure they should. I would suggest a Windows-specific chapter or link in http://modula3.elegosoft.com/cm3/installation.html, as well as a news item on the first page. Jay, could you extend the HTML documentation on your own and check it into the reporitory, or do you need help? It's all in the cm3/www package. Once it's checked in, we can ship it to our WWW server. Thanks in advance, Olaf > > On Nov 29, 2007, at 8:48 PM, Jay wrote: > >> some more notes on the win32 system >> >>> setup your C++ compiler/linker >> >> You can/should "play dumb", skip that, and just run upgrade. >> See what errors you get. >> I tried to put in the right amount of up front sanity checking. >> >> What you need in particular are >> >> cl and link on the %PATH%. >> See, cminstall would have you specify full paths, my configuration >> uses %PATH%. >> If using VS2005 (8) or newer, mt on the path. >> >> %LIB% is a semicolon delimited list of directories. >> That is a feature of the Microsoft linker. >> msvcrt.lib must be in one of them. >> >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, >> 7.0, 7.1, 8.0 -- should work. >> I have tested all of them some and many required small changes in >> one particular spot, >> that actually is only used by "maintainers" >> (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). >> I use 8.0 the most lately. >> I haven't done much with 9.0. >> >> Another thing, fairly redundant: >> >> C:\dev2\cm3\m3-win>more vcredist.txt >> On computers without Visual C++ 2005 or CLR 2.0 installed, download >> and run the setup for the Visual C++ runtime -- vcredist_x86.exe >> -- from either >> >> RTM (release to manufacturing): >> >> http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE >> >> or Service Pack 1: >> >> http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 >> >> You can find those searching the web for vcredist, no real need to >> recort the URLs. That's about it. >> >> - Jay >> >> Your smile counts. The more smiles you share, the more we donate. Join in! -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From agrj at aes.com.br Fri Nov 30 20:28:42 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:28:42 -0200 Subject: [M3devel] Modula 3 and Mac os X Message-ID: Dear All, this is my first message, sorry for the "beginner" question. is there any Modula 3 distribution that is capable of running in a Mac OS X enviroment? if yes, where can I get it and how to install. thanks in advance, Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 20:42:33 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 14:42:33 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: References: Message-ID: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a daily basis. Unfortunately, the most recent release of CM3 does not support Intel Macs (and is somewhat lacking even for PowerPC Macs). I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from the current CVS head of CM3 following the instructions for CM3. On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > Dear All, > > this is my first message, sorry for the "beginner" question. > > is there any Modula 3 distribution that is capable of running in a > Mac OS X enviroment? if yes, where can I get it and how to install. > > thanks in advance, > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > From agrj at aes.com.br Fri Nov 30 20:48:58 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:48:58 -0200 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Message-ID: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Thanks I will try. I have also a Macbook pro with OS X 10.5.1. would you think it work? thanks again Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a > daily basis. Unfortunately, the most recent release of CM3 does not > support Intel Macs (and is somewhat lacking even for PowerPC Macs). > I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ > hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from > the current CVS head of CM3 following the instructions for CM3. > > On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > >> Dear All, >> >> this is my first message, sorry for the "beginner" question. >> >> is there any Modula 3 distribution that is capable of running in a >> Mac OS X enviroment? if yes, where can I get it and how to install. >> >> thanks in advance, >> >> Aryldo G Russo Jr >> Gerente de Pesquisa e Desenvolvimento >> Grupo AeS >> CRE 6006 - CSSBB 5770 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 21:21:52 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 15:21:52 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Message-ID: <523F0686-A41F-49CB-A89A-E06145AA557F@cs.purdue.edu> I have heard that there may be problems generally with porting software to 10.5 resulting from changes in some of the low-level interfaces. I have not had a chance to try on 10.5 yet. On Nov 30, 2007, at 2:48 PM, Aryldo G Russo Jr wrote: > Thanks > > I will try. > > I have also a Macbook pro with OS X 10.5.1. would you think it work? > > thanks again > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > > Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > >> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a >> daily basis. Unfortunately, the most recent release of CM3 does >> not support Intel Macs (and is somewhat lacking even for PowerPC >> Macs). I have a bootstrap compiler available at ftp:// >> ftp.cs.purdue.edu:pub/hosking/m3/I386_DARWIN/cm3.gz. You can use >> this to bootstrap from the current CVS head of CM3 following the >> instructions for CM3. >> >> On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: >> >>> Dear All, >>> >>> this is my first message, sorry for the "beginner" question. >>> >>> is there any Modula 3 distribution that is capable of running in >>> a Mac OS X enviroment? if yes, where can I get it and how to >>> install. >>> >>> thanks in advance, >>> >>> Aryldo G Russo Jr >>> Gerente de Pesquisa e Desenvolvimento >>> Grupo AeS >>> CRE 6006 - CSSBB 5770 >>> >>> >> > From rcoleburn at scires.com Fri Nov 30 23:24:25 2007 From: rcoleburn at scires.com (Randy Coleburn) Date: Fri, 30 Nov 2007 17:24:25 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <4750474F.1E75.00D7.1@scires.com> Jay: Thanks for all your help. Actually, the last time I tried to install cm3, I used the 5.26 tarballs and tried to build, but ran into some compile errors. I'll try it again and report back the actual errors I get (if any). As for Microsoft Visual Studio, yes I'm familiar with setting it up. Are you saying that the cm3install program should no longer be used? I've used this in the past. The big issue I've run into is making sure to give old style 8.3 pathnames without spaces and to edit the cm3.cfg file to find all the libraries and stuff using paths without spaces. I've also set some environment vars, in particular the TEMP and TMP vars, to use paths without spaces. I will try to be very careful to document everything I do in great detail. Perhaps we can use this to give out a better recipe to folks on how to get cm3 working on Windows. Regards, Randy >>> Jay 11/29/2007 8:48 PM >>> some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade. See what errors you get. I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%. If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories. That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). I use 8.0 the most lately. I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txt On computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! ( about:www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 2 21:37:38 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 2 Nov 2007 20:37:38 +0000 Subject: [M3devel] iterating over sets? In-Reply-To: References: Message-ID: I was asking about Modula-3 syntax and built in mechanisms. Here are the ways to implement this sort of thing. There are two main scenarios: a small set this can be either 0..n or n..m "small" is n or m-n a big set again 0..n or n..m offseting the start is trivial A small set should be represented by an array of some integer type,such as array of 8 bit int, or 16 bit int, or 32 bit, or 64 bit int It should support operations such as: Operations my question needs: FindFirstSetBit FindNextSetBit(start) Operation of course needed: GetBit(offset) Operations other uses of this data structure would want, though maybe not a "set": FindFirstClearBit FindNextClearBit(start) FindClearBits(start,count) FindSetBits(start,count) SetBits(start,count) ClearBits(start,count) You might want to combine some of them -- FindClearBitsAndSet, FindSetBitsAndClear. Operations that Modula-3 already has: union intersect difference symmetric_difference I was asked stuff about this as an interview question years ago. Depending on processor support, one implementation is an array of bytes and youhave roughly the following small tables: typedef unsigned char byte;byte MaximumBitsSet[256];byte MaximumBitsClear[256];byte BitsSetLeft[256];byte BitsClearLeft[256];byte BitsSetRight[256];byte BitsClearRight[256];byte OffsetOfMaximumBitsSet[256];byte OffsetOfMaximumBitsClear[256]; Some of this might be redundant.You could pack them the other way: typedef struct BitInfo_t { byte MaximumBitsSet; // or 3 bit bitfield byte MaximumBitsClear; etc.} BitInfo_t; BitInfo_t BitInfo[256]; >From here you can reasonably easily reasonably efficiently implementthe functions I identified. Now, if your processor supports intructions to compute some of thesefigures efficiently, esp. on a 32 bit or 64 bit integer, that mightbe more efficient. There's a term here "population count" and an instructionin some processors. Maybe also "lzcnt" -- leading zero count. If the set does not start at 0, you just offset things at some point. Easy. For a large set, this will use too much memory.You can use simply a sorted array of integers.And use binary search against that.Not terrible. Or you can use an array of offset, length pairs."extents" perhaps this is called.You would sort this by offset, and again use binary search.This would tend to be more compact. You could be adaptive.You could set some thresholds of size or density at which you would switchthe representation from one to the other.Of course you if I am frequently adding/removing items to a set, you don'twant to frequently change the representation. I'm still pondering 64 bit integer support in the x86 back end.The basic dilemna is a stack of pairs or the existing stack of singletons wheresometimes you'd use two stack items at a time. I'm leaning towarda stack of pairs. After that we can discuss something like: FindFirstMemberInSet FindNextMemberInSet and adding that to the language, etc. FIRST and NEXT seem natural but I believe FIRST already meansthe first possible value, not the first present value. On Windows, run link /dump /exports %windir%\system32\ntdll.dll | findstr /i bit.You'll see some of this stuff and more. - Jay > Date: Wed, 31 Oct 2007 23:09:11 +0100> From: lemming at henning-thielemann.de> Subject: Re: [M3devel] iterating over sets?> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> > > On Wed, 31 Oct 2007, Jay wrote:> > > Let's say I had> >> > TYPE T = SET OF { 0 .. 256 };> >> > Must I say:> >> > VAR t: T;> > FOR i := FIRST(t) TO LAST(t)> > IF i IN t DO> > something with i> > END> > END> > You may speed up search by splitting the set into subsets.> > E.g.> > IF t * T{16..31} = T{} THEN> skip this block completely> ELSE> inspect that block in detail> END; _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Mon Nov 5 16:05:14 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Mon, 05 Nov 2007 16:05:14 +0100 (MET) Subject: [M3devel] m3.org Message-ID: Does the domain have a new owner? From wagner at elegosoft.com Mon Nov 5 17:06:32 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Mon, 05 Nov 2007 17:06:32 +0100 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: <20071105170632.1cuq7pj8mccgc8w0@mail.elegosoft.com> Quoting Henning Thielemann : > > Does the domain have a new owner? No, it still belongs to Farshad Nayeri, and he wants to keep it. All content has been moved to modula3.org several months ago. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From darko at darko.org Mon Nov 5 18:26:20 2007 From: darko at darko.org (Darko) Date: Mon, 5 Nov 2007 09:26:20 -0800 Subject: [M3devel] m3.org In-Reply-To: References: Message-ID: Looks like it. modula3.org is being used instead. On 05/11/2007, at 7:05 AM, Henning Thielemann wrote: > > Does the domain have a new owner? From wagner at elegosoft.com Fri Nov 9 12:45:25 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:45:25 +0100 Subject: [M3devel] Fwd: install problems Message-ID: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Sorry, I'm afraid there's currently no one here at Elego to look into this; perhaps anybody here on m3devel can help out? I myself am busy at a customer. Thanks in advance, Olaf ----- Forwarded message from radugrigore at gmail.com ----- Date: Fri, 9 Nov 2007 10:02:28 +0000 From: Radu Grigore Reply-To: Radu Grigore Subject: install problems To: m3-support at elego.de OK, I stopped trying the CVS and followed the installation notes. It stopes working here: rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship CM3C = /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap rehearsecode replayheap showheap shownew showthread pkl-fonts juno-machine juno-compiler juno-app cube calculator fisheye mentor === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship -DROOT='/home/rg/workspace/cm3' +++ Segmentation fault (core dumped) *** execution of failed *** -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- A non-text attachment was scrubbed... Name: Install.log Type: text/x-log Size: 9440 bytes Desc: not available URL: From wagner at elegosoft.com Fri Nov 9 12:47:14 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 09 Nov 2007 12:47:14 +0100 Subject: [M3devel] Fwd: Re: install problems Message-ID: <20071109124714.cocmjgc4pc8c08cw@mail.elegosoft.com> Seem's I've been too pessimistic, Stefan has taken charge :-) Olaf ----- Forwarded message from stsp at elego.de ----- Date: Fri, 9 Nov 2007 11:31:07 +0100 From: Stefan Sperling Reply-To: Stefan Sperling Subject: Re: install problems To: Radu Grigore Cc: m3-support at elego.de On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner ----- End forwarded message ----- -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 -------------- next part -------------- On Fri, Nov 09, 2007 at 10:02:28AM +0000, Radu Grigore wrote: > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: What platform? Which notes exactly? The notes may be out of date with respect to current CVS, I think they still assume 5.4 behaviour and as far as I understand some changes have been made since that require a different bootstrapping process. I don't know if the docs have been updated to reflect this. > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** Someone else on the list may have a better idea of what this could be, I'm not following cm3 development closely. Some ideas though: If you run linux, try: export LD_POINTER_GUARD=0 In any case, a backtrace would be great to help people diagnose this. Please run: $ cd /home/rg/workspace/cm3/m3-libs/m3gc-simple $ gdb /path/to/cm3 [some gdb output here] gdb > run -build -DROOT='/home/rg/workspace/cm3' [it crashes] gdb> where [interesting output, please send us this] -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From stsp at elego.de Fri Nov 9 15:13:11 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 15:13:11 +0100 Subject: [M3devel] [radugrigore@gmail.com: Re: install problems] Message-ID: <20071109141311.GF27811@jack.stsp.lan> Olaf, why did you forward Radu's request to the m3devel list? Is only elego staff on m3-support? If so, why? Just in case people missed his response, here it is. I don't know what his problem could be, may be someone who has an idea could respond and make it clear that further replies should go the m3devel list directly? Thanks. ----- Forwarded message from Radu Grigore ----- Date: Fri, 9 Nov 2007 11:30:42 +0000 From: Radu Grigore To: Stefan Sperling Subject: Re: install problems Cc: m3-support at elego.de Thanks for the reply! On Nov 9, 2007 10:31 AM, Stefan Sperling wrote: > What platform? Ubuntu gutsy. Linux rg-ucd 2.6.22-14-386 #1 Sun Oct 14 22:36:54 GMT 2007 i686 GNU/Linux > Which notes exactly? http://modula3.elegosoft.com/cm3/installation.html (Please note that I am not subscribed to this list. I wasn't even aware that it _is_ a list. I sent an email only because of the note at the end of the webpage linked above. Oh, you should probably know that the web form mentioned in the same paragraph on that webpage insists on "all mandatory fields being filled in" even when _all_ fields are filled in.) > Someone else on the list may have a better idea of what > this could be, I'm not following cm3 development closely. After ./do-cm3-core.sh buildship // seem to work fine ./install-cm3-compiler.sh upgrade running cm3 crashes every time actually. It just so happened that ./do-cm3-std.sh buildship was the next command that was supposed to be run. (Might be relevant: the command "./install-cm3-compiler.sh upgrade" didn't work because I installed cm3 in /homr/rg/tools/cm3 instead of /usr/local/cm3 and the latter is hardcoded in sysinfo.sh. The same for the lib directory. It did seem to work after fixing those.) > In any case, a backtrace would be great to help people > diagnose this. Please run: The backtrace doesn't seem useful: (gdb) where #0 0x9e841069 in ?? () Cannot access memory at address 0x405fcfa2 It crashes quite fast: rg at rg-ucd:src$ strace cm3 execve("/home/rg/tools/cm3/bin/cm3", ["cm3"], [/* 36 vars */]) = 0 uname({sys="Linux", node="rg-ucd", ...}) = 0 brk(0) = 0x8b1f000 brk(0x8b1fcb0) = 0x8b1fcb0 set_thread_area({entry_number:-1 -> 6, base_addr:0x8b1f830, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 brk(0x8b40cb0) = 0x8b40cb0 brk(0x8b41000) = 0x8b41000 gettimeofday({1194607166, 865750}, NULL) = 0 gettimeofday({1194607166, 865831}, NULL) = 0 rt_sigaction(SIGHUP, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGINT, {0x820cc21, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGQUIT, {0x820cc81, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGSEGV, {0x820cce6, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 rt_sigaction(SIGTERM, {0x820cb46, [], SA_SIGINFO}, {SIG_DFL}, 8) = 0 mmap2(NULL, 270336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7f34000 --- SIGSEGV (Segmentation fault) @ 0 (0) --- --- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV (core dumped) +++ Same output with LD_POINTER_GUARD=0. -- regards, radu http://rgrig.blogspot.com/ ----- End forwarded message ----- -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From hosking at cs.purdue.edu Fri Nov 9 15:28:28 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 9 Nov 2007 09:28:28 -0500 Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> Message-ID: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> WHat's your build target? On Nov 9, 2007, at 6:45 AM, Olaf Wagner wrote: > Sorry, > > I'm afraid there's currently no one here at Elego to look into this; > perhaps anybody here on m3devel can help out? > I myself am busy at a customer. > > Thanks in advance, > > Olaf > > ----- Forwarded message from radugrigore at gmail.com ----- > Date: Fri, 9 Nov 2007 10:02:28 +0000 > From: Radu Grigore > Reply-To: Radu Grigore > Subject: install problems > To: m3-support at elego.de > > OK, I stopped trying the CVS and followed the installation notes. It > stopes working here: > > rg at rg-ucd:scripts$ ./do-cm3-std.sh buildship > CM3C = > /home/rg/workspace/cm3/scripts/pkgmap.sh -c "cm3 -build > -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' " m3gc-simple m3core libm3 > patternmatching m3middle m3quake m3scanner m3tools m3cgcat m3cggen > m3gdb m3bundle arithmetic bitvector digraph parseparams realgeometry > set slisp sortedtableextras table-list tempfiles tcp udp libsio libbuf > debug listfuncs embutils m3tk-misc http binIO commandrw m3tk mtex > m3totex m3tohtml m3scan m3markup m3browser cmpdir cmpfp dirfp uniq > netobj netobjd stubgen events rdwr sharedobj sharedobjgen odbc > postgres95 db smalldb stable stablegen X11R4 ui PEX vbtkit cmvbt > jvideo videovbt web formsvbtpixmaps formsvbt formsview formsedit > codeview mg mgkit opengl anim3D zeus m3zume synloc synex metasyn > obliqrt obliqparse obliqprint obliq obliqlibemb obliqlibm3 obliqlibui > obliqlibanim obliqsrvstd obliqsrvui obliqbinmin obliqbinstd obliqbinui > obliqbinanim visualobliq vocgi voquery vorun webvbt recordheap > rehearsecode replayheap showheap shownew showthread pkl-fonts > juno-machine juno-compiler juno-app cube calculator fisheye mentor > === package /home/rg/workspace/cm3/m3-libs/m3gc-simple === > +++ cm3 -build -DROOT='/home/rg/workspace/cm3' && cm3 -ship > -DROOT='/home/rg/workspace/cm3' +++ > Segmentation fault (core dumped) > *** execution of failed *** > > > -- > regards, > radu > http://rgrig.blogspot.com/ > > > ----- End forwarded message ----- > > > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > > > Thank you for using Critical Mass CM3. This program > will configure and install the system. > > cminstall_root is set to /home/rg/temp > If this is not correct, please restart the installer with > -root > > The installer will ask you some questions about the locations of > programs > and libraries. Usually it will display a default inside [], which > can be > accepted with . > If the installer has found several choices, you may cycle through them > with `+' or `.' for the next and `-' for the previous one. > You may of course also enter a completely different value. > > > Where would you like the system installed? [/usr/local/cm3] > What should be the default text editor for new Reactor users? > checking for executable with environment variable EDITOR... not found > checking for executable emacsclient... found > checking for executable emacs... found > checking for executable vi... found > checking for executable textedit... not found > checking for executable xedit... not found > checking for executable emacsclient in directory /usr/local/emacs/ > bin... not found > checking for executable emacsclient in directory /usr/local/bin... > not found > checking for executable emacs in directory /usr/local/emacs/bin... > not found > checking for executable emacs in directory /usr/local/bin... not found > checking for executable vi in directory /usr/bin... found > checking for executable xedit in directory /usr/local/X11R5/bin... > not found > checking for executable textedit in directory /usr/openwin/bin... > not found > checking for executable xedit in directory /usr/openwin/bin... not > found > checking for executable xedit in directory /usr/X11/bin... not found > checking for executable xedit in directory /usr/bin/X11... not found > > 1: /usr/bin/emacsclient > 2: /usr/bin/emacs > 3: /usr/bin/vi > What should be the default text editor for new Reactor users? > [/usr/bin/emacsclient](1 of 3) /usr/bin/vi > > Where should Reactor be installed? > setting INSTALL_ROOT to /usr/local/cm3 > Where are the flex/bison libraries? > looking for library file(s): libfl.a > checking for library files in directory /usr/lib... found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the flex/bison libraries? [/usr/lib](1 of 1) > > Where are the Postgres95 libraries? > looking for library file(s): libpq.so > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) > The libraries libpq.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the Postgres95 libraries? [/usr/lib](1 of 1) /home/rg/lib/ > links > > Where are the OpenGL libraries? > looking for library file(s): libGLU.so > looking for library file(s): libGL.so libGLU.so > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/lib... found > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) > The libraries libGL.so libGLU.so are not present in the chosen > directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/lib > Where are the OpenGL libraries? [/usr/lib](1 of 1) /home/rg/lib/links > > Where are the ODBC libraries? > looking for library file(s): libodbc.so > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/pgsql/lib... not > found > checking for library files in directory /usr/local/postgres95/ > lib... not found > checking for directory /usr/local/lib... found > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) > The libraries libodbc.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/local/lib > Where are the ODBC libraries? [/usr/local/lib](1 of 1) /home/rg/lib/ > links > > Where are the Motif libraries? > looking for library file(s): libXm.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the Motif libraries? [/usr/X11R6/lib](1 of 2) /home/rg/ > lib/links > > Where are the X11 libraries? > looking for library file(s): libXaw.so > looking for library file(s): libXmu.so libXaw.so > looking for library file(s): libXext.so libXmu.so libXaw.so > looking for library file(s): libXt.so libXext.so libXmu.so libXaw.so > looking for library file(s): libSM.so libXt.so libXext.so libXmu.so > libXaw.so > looking for library file(s): libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so > looking for library file(s): libX11.so libICE.so libSM.so libXt.so > libXext.so libXmu.so libXaw.so > checking for library files in directory /usr/X11/lib... not found > checking for library files in directory /usr/X11R6/lib... not found > checking for library files in directory /usr/lib... not found > checking for library files in directory /usr/local/lib... not found > checking for library files in directory /usr/local/gnu/lib... not > found > checking for directory /usr/X11/lib... not found > checking for directory /usr/X11R6/lib... found > checking for directory /usr/lib... found > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) > The libraries libX11.so libICE.so libSM.so libXt.so libXext.so > libXmu.so libXaw.so are not present in the chosen directory. > Would you like to change the library names? [yes] no > Would you like to continue nonetheless? [yes] no > > Please enter the name of a directory. > > 1: /usr/X11R6/lib > 2: /usr/lib > Where are the X11 libraries? [/usr/X11R6/lib](1 of 2) /home/rg/lib/ > links > > Where is your C compiler? > checking for executable gcc... found > checking for executable gcc in directory /bin... not found > checking for executable gcc in directory /usr/bin... found > checking for executable gcc in directory /usr/local... not found > checking for executable gcc in directory /usr/local/bin... not found > checking for executable gcc in directory /usr/local/gnu... not found > checking for executable cc... found > checking for executable cc in directory /bin... not found > checking for executable cc in directory /usr/bin... found > checking for executable cc in directory /usr/local... not found > checking for executable cc in directory /usr/local/bin... not found > checking for executable cc in directory /usr/local/gnu... not found > > 1: /usr/bin/gcc > 2: /usr/bin/cc > Where is your C compiler? [/usr/bin/gcc](1 of 2) > > Where is your library archiver? > checking for executable ar... found > checking for executable ar in directory /usr/bin... found > checking for executable ar in directory /bin... not found > checking for executable ar in directory /usr/local... not found > checking for executable ar in directory /usr/local/bin... not found > checking for executable ar in directory /usr/local/gnu... not found > > 1: /usr/bin/ar > Where is your library archiver? [/usr/bin/ar](1 of 1) > > Where is your assembler? > checking for executable as... found > checking for executable as in directory /usr/bin... found > checking for executable as in directory /bin... not found > checking for executable as in directory /usr/local... not found > checking for executable as in directory /usr/local/bin... not found > checking for executable as in directory /usr/local/gnu... not found > > 1: /usr/bin/as > Where is your assembler? [/usr/bin/as](1 of 1) > > > Installing CM3 in: /usr/local/cm3 > This may take a few minutes... > > CM3 is now installed. > > Before you begin, here's a few reminders: > > 1) The CM3 compiler executable is in: > /usr/local/cm3/bin/cm3 > You may need to modify your PATH environment variable to find it. > And on Unix, you may need to type "rehash" to your shell. > > 2) CM3's shared libraries and any you create and ship are in: > /usr/local/cm3/lib > On most Unix systems you need to set the LD_LIBRARY_PATH > (on Darwin / MacOS X it's called DYLD_LIBRARY_PATH) > environment variable before running programs that use > these shared libraries. > > 3) Your system configuration file is: > /usr/local/cm3/bin/cm3.cfg > At any point in time, you may edit it to modify or update your > installation. > > 4) A copy of this installation dialogue is in: > /usr/local/cm3/Install.log > > 5) If you had trouble with this installation or need more > assistance, > please send us a transcript of this installation via e-mail at > "m3-support at elego.de". > > Thank you. From stsp at elego.de Fri Nov 9 16:42:12 2007 From: stsp at elego.de (Stefan Sperling) Date: Fri, 9 Nov 2007 16:42:12 +0100 Subject: [M3devel] Fwd: install problems In-Reply-To: <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> References: <20071109124525.grv7tp8kggc80ook@mail.elegosoft.com> <974D6FE6-AF59-4046-8E78-EB7D2DE0CD7E@cs.purdue.edu> Message-ID: <20071109154212.GH27811@jack.stsp.lan> On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 187 bytes Desc: not available URL: From dabenavidesd at yahoo.es Sat Nov 10 04:14:37 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Sat, 10 Nov 2007 04:14:37 +0100 (CET) Subject: [M3devel] Fwd: install problems In-Reply-To: <20071109154212.GH27811@jack.stsp.lan> Message-ID: <610753.84071.qm@web27102.mail.ukl.yahoo.com> Hi all: Maybe I can help you. After all the help you have gave to me, I can contribute; first Im not sure but maybe Radu has some problem with cm3.cfg file and the way I have used the new cm3 binary is more "manual" than the cminstall process which should adjust the cm3.cfg file. The first thing to do is dowload the appropiate libraries/programs to be able to compile the cm3 standard. The packages I have used for the Ubuntu Feisty are these: http://es.geocities.com/dabenavidesd/cm3Manual.html#SECTION00020000000000000000 The above guide is for users of ubuntu feisty (older than gutsy), but the only version dependant thing are the names of some packages, but normally it should work for the gutsy, I can try it on these weekend as soon as I can. After that tough the instructions are in spanish you can see the line commands I have used, please inform me if there is something worng, and I will take account of that and change the "instructions". I will do a english version if it is really important (I think yes). Bye On Fri, Nov 09, 2007 at 09:28:28AM -0500, Tony Hosking wrote: > WHat's your build target? Does not look like you had Radu Grigore in either To or Cc header... He's not on any m3 list! -- Stefan Sperling Software Developer elego Software Solutions GmbH HRB 77719 Gustav-Meyer-Allee 25, Gebaeude 12 Tel: +49 30 23 45 86 96 13355 Berlin Fax: +49 30 23 45 86 95 http://www.elego.de Geschaeftsfuehrer: Olaf Wagner Stefan Sperling escribi?: --------------------------------- ?Descubre una nueva forma de obtener respuestas a tus preguntas! Entra en Yahoo! Respuestas. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sat Nov 10 12:33:03 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 03:33:03 -0800 Subject: [M3devel] leap-second issue with Date.i3 Message-ID: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Hello everyone, I just ... added a workaround for a nasty bug I had in some code of my own. My code used Unix's localtime to convert a Time.T to a Date.T using the zoneinfo files. I'm not sure if there's a "normal" way to do this in M3, so I have some messy stuff involving mutexes, static storage, etc. (Note one has to be careful when linking this stuff into a program with the normal M3 conversion codes---Date.FromTime and Date.ToTime---which also use (other) hidden mutexes to protect some of the same data structures!) The issue is this. I just realized that localtime sometimes returns "60" for the seconds---namely, during a leap second! Just copying this into a Date.T will lead to a range error and a program crash. Do we really want Modula-3 users to have to restart their servers the moment after popping the champagne corks? (Ok, well during New Year's Eve in my time zone, but still...) Does anyone know how Date.T handles/should handle this? As correct as it is, I find it somewhat unsatisfying to change the seconds field to [0..60], because off-by-one errors are so common in programming... it's probably The Right Thing to do, though. Mika From hosking at cs.purdue.edu Sat Nov 10 17:22:21 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Sat, 10 Nov 2007 11:22:21 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: I see no problem with changing seconds to [0..60]. That matches the POSIX spec nicely enough. On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes--- > Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From hendrik at topoi.pooq.com Sat Nov 10 21:11:01 2007 From: hendrik at topoi.pooq.com (hendrik at topoi.pooq.com) Date: Sat, 10 Nov 2007 15:11:01 -0500 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: <200711101133.lAABX3td046525@camembert.async.caltech.edu> References: <200711101133.lAABX3td046525@camembert.async.caltech.edu> Message-ID: <20071110201101.GB1273@topoi.pooq.com> On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: > Hello everyone, > > I just ... added a workaround for a nasty bug I had in some code > of my own. My code used Unix's localtime to convert a Time.T to a > Date.T using the zoneinfo files. I'm not sure if there's a "normal" > way to do this in M3, so I have some messy stuff involving mutexes, > static storage, etc. (Note one has to be careful when linking this > stuff into a program with the normal M3 conversion codes---Date.FromTime > and Date.ToTime---which also use (other) hidden mutexes to protect > some of the same data structures!) > > The issue is this. I just realized that localtime sometimes returns > "60" for the seconds---namely, during a leap second! Just copying > this into a Date.T will lead to a range error and a program crash. > Do we really want Modula-3 users to have to restart their servers > the moment after popping the champagne corks? (Ok, well during > New Year's Eve in my time zone, but still...) Does that mean that each time zone, as midnight creeps around the world, will insert the leap second at its own midnight, resulting in time-zone differences of 59 minutes and 59 seconds? -- hendrik > > Does anyone know how Date.T handles/should handle this? As correct > as it is, I find it somewhat unsatisfying to change the seconds > field to [0..60], because off-by-one errors are so common in > programming... it's probably The Right Thing to do, though. > > Mika From mika at async.caltech.edu Sat Nov 10 21:40:33 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sat, 10 Nov 2007 12:40:33 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 15:11:01 EST." <20071110201101.GB1273@topoi.pooq.com> Message-ID: <200711102040.lAAKeXoK067937@camembert.async.caltech.edu> hendrik at topoi.pooq.com writes: >On Sat, Nov 10, 2007 at 03:33:03AM -0800, Mika Nystrom wrote: ... >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) > >Does that mean that each time zone, as midnight creeps around the world, >will insert the leap second at its own midnight, resulting in time-zone >differences of 59 minutes and 59 seconds? No, I think it happens at midnight UTC... during New Year's Eve here in California, early New Year's Day in CET. > >-- hendrik ... From jay.krell at cornell.edu Mon Nov 12 01:51:55 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 00:51:55 +0000 Subject: [M3devel] small array in modula-3? Message-ID: What is the right way to have a variably sized but always small array in Modula-3?My array will only ever have 1 or 2 elements.I'd like to always allocate room for 2 elements, and have there be a size. It seems I have a choice of a) an "open" arrayb) wrap it up in a record I'd like so have, like: TYPE A = ARRAY [0..1] OF FOO; And be able to say: VAR a : A; .. a.size FOR i := 0 TO a.size DO do something with a[i] It seems I have no option but, like: TYPE A = RECORD a: ARRAY[0..1] OF FOO; size := 1; (* usually of size 1, sometimes 2 *)END and then FOR i := 0 TO a.size DO do something with a.a[i]; That is "ok". Not great -- what to call the inner a? But then furthermore, I'd like to construct constants.It seems I am stuck with either the verbose: PROCEDURE F(a:A); F( A { ARRAY[0..1] OF FOO { .. } ); OR I have to come up with a name for the embedded array.But of course, its type is really "the same" as the outer type. To wit: TYPE FooArray = ARRAY[0..1] OF Foo; TYPE FooArray = RECORD a : FooArray; size := 1;END; F( FooArray { FooArray { .. } ); But I have to come up with different names. And I don't think I can leave out the name for the constructor, like: F( FooArray { { .. } ); Though that might seem nice. Am I understanding everything? Have folks hit this before and there's a set of names that don't seem too lamethat folks use? Also -- language documentation?Nelson's green book is excellent.The stuff in the doc directory is very dry and scientific.The tutorial seems more like a reference. Or maybe I didn't read it enough.Is there better, in case I need a refresher?I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,but I don't think anyone could learn from the current online docs in the source tree. Maybe it's me, some combination of laziness and short attention span as I age.. Btw, C doesn't offer a great solution here, though it offers leaving out some type names.In C++ I could have both .size and operator[].Modula-3 seems to be missing operator overloading.It's got some builtin stuff, even array assignment and equality and I think even record assignment and equality, but it is still a bit limiting. Also, if I understand things correctly, this has long bothered me about Modula-3, though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght objects. Like, small stack allocated structs with member functions. You seem to have to chose between heap allocated garbage collected virtual member functions full featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- objects don't have to be heap allocated and member functions don't have be virtual. Or am I missing something? Anyway, I've gotten to accept C a bit more vs. C++ so I can deal witht: Type;Type_DoSomething(t); in place of:t.DoSomething(); - Jay _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Mon Nov 12 06:16:32 2007 From: jay.krell at cornell.edu (Jay) Date: Mon, 12 Nov 2007 05:16:32 +0000 Subject: [M3devel] test Message-ID: Is this working? - Jay _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Sun Nov 11 23:36:39 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Sun, 11 Nov 2007 14:36:39 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711112236.lABMad1c028825@camembert.async.caltech.edu> My only problem with it is that it is likely to break some programs, those that depend on the seconds field never exceeding 60. I think it's legitimate to ask whether it is not more reasonable to expect a well-written Modula-3 program(mer) to have used the contents of Date.i3 rather than the POSIX standard to decide how to treat the values of type Date.T.... Which are these "twilight zone" programs? I have no idea.. Mika Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Mon Nov 12 12:42:09 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 03:42:09 -0800 Subject: [M3devel] leap-second issue with Date.i3 In-Reply-To: Your message of "Sat, 10 Nov 2007 11:22:21 EST." Message-ID: <200711121142.lACBg95n060864@camembert.async.caltech.edu> Now it's not clear to me that [0..59] was wrong in the first place. The key thing to remember is that the following oft-repeated statement (from the FreeBSD time(3) man page)... The time() function returns the value of time in seconds since 0 hours, 0 minutes, 0 seconds, January 1, 1970, Coordinated Universal Time. is actually wrong. Today, the "right"(*) specification is that the time() function returns a value that is currently 23 (I think that's the number) less than the number of seconds since the Unix epoch. This is obvious if you've ever noticed that the 0th second of a minute always comes out divisible by 60 in Unix time. The leap seconds are just not representable in Unix time. POSIX localtime can't return 60 for the seconds, because the same POSIX time represents two different seconds. Wikipedia talks about this a bit. They give the example of Unix time 915,148,800, which corresponds to BOTH 23:59:60 UTC on December 31, 1998 and 00:00:00 UTC on January 1, 1999. I am a bit baffled why POSIX bothers to have the 60 in their struct tm definition, if the underlying timeval data structure just can't represent the time in question. That is, when you pass 915,148,800 to Date.FromTime you probably get 00:00:00 UTC, Jan 1, 1999, and NOT 23:59:60 UTC, Dec. 31, 1998, even though both are equally correct. There is however a cryptic comment in my localtime man page that The asctime(), ctime(), difftime(), gmtime(), localtime(), and mktime() functions conform to ISO/IEC 9899:1990 (``ISO C90''), and conform to ISO/IEC 9945-1:1996 (``POSIX.1'') provided the selected local timezone does not contain a leap-second table (see zic(8)). I read the zic man page several times and am none the wiser!!!! ... that is, I don't know if POSIX functions localtime et al. can ever return 60 for the seconds field. Possibly FreeBSD ones may if zic is fed the proper information, but then does that mess up the Unix time values? (One would think it would have to.) I really just want to be sure that my server programs don't crash because they try to do something like s : [0..59] := 60 at an inopportune moment! (And your solution accomplishes that, at least.) Mika (*) actually the correct specification for the Unix time defines it in terms of UTC. Unix time = 86400*(# of days since Jan 1, 1970) + 3600 * UTC.hour + 60 * UTC.minute + UTC.second. It follows from this definition that Unix time maps neither linearly nor single-valuedly to actual time. Tony Hosking writes: >I see no problem with changing seconds to [0..60]. That matches the >POSIX spec nicely enough. > >On Nov 10, 2007, at 6:33 AM, Mika Nystrom wrote: > >> Hello everyone, >> >> I just ... added a workaround for a nasty bug I had in some code >> of my own. My code used Unix's localtime to convert a Time.T to a >> Date.T using the zoneinfo files. I'm not sure if there's a "normal" >> way to do this in M3, so I have some messy stuff involving mutexes, >> static storage, etc. (Note one has to be careful when linking this >> stuff into a program with the normal M3 conversion codes--- > Date.FromTime >> and Date.ToTime---which also use (other) hidden mutexes to protect >> some of the same data structures!) >> >> The issue is this. I just realized that localtime sometimes returns >> "60" for the seconds---namely, during a leap second! Just copying >> this into a Date.T will lead to a range error and a program crash. >> Do we really want Modula-3 users to have to restart their servers >> the moment after popping the champagne corks? (Ok, well during >> New Year's Eve in my time zone, but still...) >> >> Does anyone know how Date.T handles/should handle this? As correct >> as it is, I find it somewhat unsatisfying to change the seconds >> field to [0..60], because off-by-one errors are so common in >> programming... it's probably The Right Thing to do, though. >> >> Mika From mika at async.caltech.edu Tue Nov 13 08:06:58 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 12 Nov 2007 23:06:58 -0800 Subject: [M3devel] time conversion re-entrancy issues Message-ID: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Hello everyone, I just ran into this on the program I'm developing. It's a crash in my own code, but I believe that the conversion routines in Date.i3 aren't immune to it either... Program received signal SIGBUS, Bus error. ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 ThreadPosix.m3:126: No such file or directory. (gdb) where #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = 1747444928; END) at ThreadPosix.m3:126 #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 #2 16_bfbfff94 in ?? () #3 16_6827e4c0 in tzsetwall () #4 16_6827e789 in localtime_r () #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, _result=RECORD year = 0; month = Jan; day = ; hour = 0; minute = 0; second = 0; offset = 2; zone = ; weekDay = ; END) at TZ.m3:47 #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, t=1194934056.6984761, prec=3, simplified=TRUE) at SafeTZ.m3:23 What's going on is that I'm converting a Time.T to a Date.T using my own conversion routine, which eventually calls the Unix localtime_r function (same procedure, done a bit more elaborately, as in the standard implementation of Date.FromTime). The problem is that localtime apparently under certain circumstances can call tzsetwall, which can take a while to run, as it involves reading timezone info from /usr/share/zoneinfo. My diagnosis is that the thread doing the conversion yielded, and then something in ThreadPosix (OK this is an old version, but the current version works the same) calls gettimeofday. And apparently gettimeofday isn't re-entrant w.r.t. tzsetwall. Is there a portable (i.e., across M3 versions) way of stopping all threadswitching activity while a call into some nasty C code is proceeding? I don't see how one can avoid it here... Mika From lemming at henning-thielemann.de Tue Nov 13 15:31:30 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Tue, 13 Nov 2007 15:31:30 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Mon, 12 Nov 2007, Jay wrote: > What is the right way to have a variably sized but always small array in > Modula-3?My array will only ever have 1 or 2 elements.I'd like to always > allocate room for 2 elements, and have there be a size. How about SUBARRAY of a two-element array? From hosking at cs.purdue.edu Tue Nov 13 17:57:29 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:57:29 -0500 Subject: [M3devel] small array in modula-3? In-Reply-To: References: Message-ID: On Nov 13, 2007, at 9:31 AM, Henning Thielemann wrote: > > On Mon, 12 Nov 2007, Jay wrote: > >> What is the right way to have a variably sized but always small >> array in >> Modula-3?My array will only ever have 1 or 2 elements.I'd like to >> always >> allocate room for 2 elements, and have there be a size. > > How about SUBARRAY of a two-element array? Yes indeed! From hosking at cs.purdue.edu Tue Nov 13 17:56:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Tue, 13 Nov 2007 11:56:05 -0500 Subject: [M3devel] time conversion re-entrancy issues In-Reply-To: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> References: <200711130706.lAD76wQK008889@camembert.async.caltech.edu> Message-ID: <49D06EC8-37FE-4876-A84E-A854E754A749@cs.purdue.edu> On Nov 13, 2007, at 2:06 AM, Mika Nystrom wrote: > Hello everyone, > > I just ran into this on the program I'm developing. It's a crash > in my > own code, but I believe that the conversion routines in Date.i3 aren't > immune to it either... > > > Program received signal SIGBUS, Bus error. > ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; tv_usec = > 1747444928; > END) at ThreadPosix.m3:126 > ThreadPosix.m3:126: No such file or directory. > (gdb) where > #0 ThreadPosix.UTimeNow (_result=RECORD tv_sec = 138291084; > tv_usec = 1747444928; END) at ThreadPosix.m3:126 > #1 16_8190658 in ThreadPosix.switch_thread () at ThreadPosix.m3:772 > #2 16_bfbfff94 in ?? () > #3 16_6827e4c0 in tzsetwall () > #4 16_6827e789 in localtime_r () > #5 16_81354ac in TZ.Localtime (t=16_832c3ec, timeArg=1194934056, > _result=RECORD year = 0; month = Jan; > day = ; hour = 0; minute > = 0; > second = 0; offset = 2; zone = Bad address>; > weekDay = ; END) at TZ.m3:47 > #6 16_8135d0b in TZ.FormatSubsecond (tz=16_832c3ec, > t=1194934056.6984761, > prec=3, simplified=TRUE) at SafeTZ.m3:23 > > What's going on is that I'm converting a Time.T to a Date.T using > my own conversion routine, which eventually calls the Unix > localtime_r function (same procedure, done a bit more elaborately, > as in the standard implementation of Date.FromTime). > > The problem is that localtime apparently under certain circumstances > can call tzsetwall, which can take a while to run, as it involves > reading > timezone info from /usr/share/zoneinfo. My diagnosis is that the > thread > doing the conversion yielded, and then something in ThreadPosix > (OK this is an old version, but the current version works the same) > calls gettimeofday. And apparently gettimeofday isn't re-entrant > w.r.t. > tzsetwall. > > Is there a portable (i.e., across M3 versions) way of stopping all > threadswitching activity while a call into some nasty C code is > proceeding? I don't see how one can avoid it here... Not really a portable way to do it. SchedulerPosix.DisableSwitching works when using ThreadPosix. For ThreadPThread SchedulerPosix.DisableSwitching is a no-op but the libraries should be thread-safe anyway so it probably works there too. What you really need is a lock somewhere. From mika at async.caltech.edu Tue Nov 13 21:41:40 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Tue, 13 Nov 2007 12:41:40 -0800 Subject: [M3devel] opening files under Win32 Message-ID: <200711132041.lADKfedp052254@camembert.async.caltech.edu> Hello again everyone, This may be a silly question, but does anyone out there in Modula-3-land know how to get more "Unix-like" semantics in opening files on Windows? I am using an old version of Modula-3 under "NT386GNU"/Cygwin and I'd like to open a file (for reading only) while another process has it open for writing (via FileWr.Open). Ideally, the method wouldn't change the writer at all, because I kind of like the fact that I have exclusive write access to the file (which avoids having to do all kinds of other external locking that is necessary when running the same program on Unix). I know what I'm trying to do is possible, because the Cygwin tools (like less, cp, etc.) can read the contents of the file, no problem, but when I try to open it with FileRd.Open, it doesn't work... Mika From rodney.bates at wichita.edu Fri Nov 16 01:39:18 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Thu, 15 Nov 2007 18:39:18 -0600 Subject: [M3devel] small array in modula-3? Message-ID: <473CE6B6.3030402@wichita.edu> Jay wrote: > What is the right way to have a variably sized but always small array in Modula-3? > My array will only ever have 1 or 2 elements. > I'd like to always allocate room for 2 elements, and have there be a size. > > It seems I have a choice of > > a) an "open" array Heap allocated, I presume? If the max size is only 2 elements, this is pretty extravagant, as a heap allocated open array will have 4 extra behind-the-scenes words of space overhead, plus maybe heap fragmentation, and time overhead of allocation, collection, and maybe reduced locality of reference. > b) wrap it up in a record > > I'd like so have, like: > > TYPE A = ARRAY [0..1] OF FOO; > > And be able to say: > > VAR > a : A; > > .. > a.size > FOR i := 0 TO a.size DO > do something with a[i] > > It seems I have no option but, like: > > TYPE A = RECORD > a: ARRAY[0..1] OF FOO; > size := 1; (* usually of size 1, sometimes 2 *) > END > > and then > FOR i := 0 TO a.size DO > do something with a.a[i]; > > That is "ok". Not great -- what to call the inner a? > But then furthermore, I'd like to construct constants. > It seems I am stuck with either the verbose: > > PROCEDURE F(a:A); > > F( A { ARRAY[0..1] OF FOO { .. } ); > > OR I have to come up with a name for the embedded array. > But of course, its type is really "the same" as the outer type. Ignoring the fact that the types are different linguistically (one a record type, the other an array), the types are different at a deep semantic level too. The inner array has static size, the outer one (call it a "variable array", perhaps) has dynamically changeable size, even more easily changed after it is created than a heap-allocated open array. This is a significant semantic difference, so it also makes program design sense to view them as different types. > > To wit: > > TYPE FooArray = ARRAY[0..1] OF Foo; > > TYPE FooArray = RECORD > a : FooArray; > size := 1; > END; > > F( FooArray { FooArray { .. } ); > > But I have to come up with different names. > > And I don't think I can leave out the name for the constructor, like: > > F( FooArray { { .. } ); Yes, this is a limitation in Modula-3. Ada allows value constructors to omit inner type names in cases like this, and it is convenient. But it also crosses a really major line on complexity of the language semantics, since type analysis information now flows not only upward, but also downward in expression typing. I am mostly content to live with this as one bit of the price of avoiding a horribly over complex language. Ordinary procedures can do pretty much all of the things done by exotic and complex language stuff like C++ constructors. If you don't want to write the ponderous nested value constructor, write a constructor procedure and call it. As Antony suggested, you can make it accept an open array formal, which then codes just like a simple array value constructor. You could even make it elaborate and general, e.g.: PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F = VAR LSize : CARDINAL ; VAR LResult : A ; BEGIN LSize := NUMBER ( Val ) <* ASSERT LSize <= NUMBER ( FooArray ) *> ; LResult . size := LSize ; SUBARRAY ( LResult . a , 0 , LSize ) := SUBARRAY ( Val , FIRST ( Val ) , LSize ) ; RETURN LResult END MakeF Alternatively, since your maximum element count is so small, you could write a constructor procedure that took two formals of type FOO, with at least the second one optional. (This would require a distinguished value of type FOO that would be used to mean "omitted".) And, of course, if you want to use abstraction, you can put the types, constructor procedures, and various other procedures for manipulating the variable sized array in a module, behind an interface. An additional limitation of Modula-3 in this regard, is that you can't make the type F opaque, unless you heap allocate it, which we were trying to avoid. Ada would allow you to do this, but it's another example of a convenience with high cost. It forces the equivalent of the revelation to be located in the equivalent of the interface, but makes it illegal to write client code that depends on what the revelation is. This in turn creates a source code control nightmare in a large project, because now someone who wants to make what is really a purely internal, implementation change, nevertheless has to check out the interface, and if you aren't in denial mode, that means implementers of all the client code have to go to extra trouble to somehow find out that what appears to be an interface change actually doesn't affect them after all. > > Though that might seem nice. > > Am I understanding everything? > > Have folks hit this before and there's a set of names that don't seem too lame > that folks use? > > Also -- language documentation? > Nelson's green book is excellent. > The stuff in the doc directory is very dry and scientific. > The tutorial seems more like a reference. Or maybe I didn't read it enough. > Is there better, in case I need a refresher? > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference, > but I don't think anyone could learn from the current online docs in the source tree. > > Maybe it's me, some combination of laziness and short attention span > as I age.. > > Btw, C doesn't offer a great solution here, though it offers leaving out some type names. > In C++ I could have both .size and operator[]. > Modula-3 seems to be missing operator overloading. > It's got some builtin stuff, even array assignment and equality and I think > even record assignment and equality, but it is still a bit limiting. I have raved on this before, but, having had lots of painful experience with user-defined overloading in Ada and C++, I can say with authority, that it is a programming language disaster. It interacts with just about everything else in the language, in very complicated ways, and all it buys you is saving time/energy thinking up distinct names for procedures/functions. Even this, aside from the effects on the language, is a net loss, by the time you consider readability along with writability. User-defined overloaded operators provide a slight readability benefit, _if_ used with great restraint and discipline, something you can rely on not happening. Meanwhile, the language complexity can easily double or worse. And, with the exception of compiler writers and language lawyers who spend hundreds of hours on just this, programmers don't understand the rules, not even close. > > Also, if I understand things correctly, this has long bothered me about Modula-3, > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght > objects. Like, small stack allocated structs with member functions. You seem to have > to chose between heap allocated garbage collected virtual member functions full > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids -- > objects don't have to be heap allocated and member functions don't have be virtual. > Or am I missing something? C++'s supposedly lighter weight forms of classes/structs with their special member functions buy nothing that plain records, plain procedures, and interfaces/modules don't already provide, again, at significant and gratuitous language complexity. Except when methods/member functions actually dispatch dynamically, there is nothing that the above won't do, and when you create a class instance as a local variable (i.e., on the stack), it is necessarily not polymorphic, that is, it can't change its "allocated" or dynamic type among various subtypes at runtime. This in turn means it can't dispatch. So, just use plain procedures, an interface and a module, and you will get everything a lighter-weight C++ class would give you. > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with > t: Type; > Type_DoSomething(t); > > in place of: > t.DoSomething(); Exactly. The special "receiver object" in a true method call has significant semantic differences from an ordinary parameter and introduces new complexities and non-orthogonalities. It has some very valuable uses too. But to then create degenerate forms of it that still carry a lot of these complexities, but are equivalent in programing power to plain old parameters is just bad program design and bad language design. Objects and methods are indeed cool for situations that utilize their semantic complexity. But it's deeply uncool to try to look superficially cool by using an inappropriately sophisticated construct when the problem doesn't justify it. Some OO proponents have gone way over the deep end here. > > - Jay > > > ------------------------------------------------------------------------ > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From jay.krell at cornell.edu Fri Nov 16 05:08:22 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:08:22 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: Rodney, thank you, this is interesting. I definitely don't want to pay for heap allocation for a tiny array. I don't know about "subarray". It looks like it takes and returns arrays. It's not a type. I ordered another copy of the Nelson book so I don't have to find mine. Good idea "MakeT" I forgot about that pattern. I'll try it out. The record and array I propose are not all that different really. I just heard of something new. Have you heard of it? "Duck typing". If it acts/quacks/walks like a duck, it is a duck. This is in very dynamic languages like Ruby. You apply object.method and if object defines something named "method", then it "must" have "the" meaning you intend. Kind of like how C++ templates "accept as parameters whatever happens to work". Operator overloading is great for strings and "math". Maybe I should try to have this language debate from scratch again..? I still am conflcted. Modules seem overly heavyweight. I don't want Module1.T, Module2.T, I want T1, T2. C++ stack structs with non virtual member functions: class Rect_t { Rect_t() : top(0), left(0), right(0), bottom(0) { } int Height() { return bottom - top; } int Width() { return right - left; } int top, left, bottom, right; }; seems "good". And it seems not really all that complicated for the compiler to flow the static type information around to resolve the functions.. Rect_t r; r.Height() => Rect_Height(&r); ..and would be inlined anyway. I do find some compelling features in Modula-3. Mainly that it compiles to native code and has OPTIONAL safety, optional garbage collection, and that the syntax of modules/interfaces allows fast compilation -- no longer reparsing the same headers over and over and over and over. Operator overloading btw..have seen "template SafeInt"? It acts like a primitive integer, but raises exceptions upon overflow. For this to work very much requires operator overloading. A point, of course, is to be able to have user defined types that can act like the built in types.. - Jay > Date: Thu, 15 Nov 2007 18:39:18 -0600> From: rodney.bates at wichita.edu> To: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > Jay wrote:> > > What is the right way to have a variably sized but always small array in Modula-3?> > My array will only ever have 1 or 2 elements.> > I'd like to always allocate room for 2 elements, and have there be a size.> >> > It seems I have a choice of> >> > a) an "open" array> > Heap allocated, I presume? If the max size is only 2 elements,> this is pretty extravagant, as a heap allocated open array will> have 4 extra behind-the-scenes words of space overhead, plus> maybe heap fragmentation, and time overhead of allocation,> collection, and maybe reduced locality of reference.> > > b) wrap it up in a record> >> > I'd like so have, like:> >> > TYPE A = ARRAY [0..1] OF FOO;> >> > And be able to say:> >> > VAR> > a : A;> >> > ..> > a.size> > FOR i := 0 TO a.size DO> > do something with a[i]> >> > It seems I have no option but, like:> >> > TYPE A = RECORD> > a: ARRAY[0..1] OF FOO;> > size := 1; (* usually of size 1, sometimes 2 *)> > END> >> > and then> > FOR i := 0 TO a.size DO> > do something with a.a[i];> >> > That is "ok". Not great -- what to call the inner a?> > But then furthermore, I'd like to construct constants.> > It seems I am stuck with either the verbose:> >> > PROCEDURE F(a:A);> >> > F( A { ARRAY[0..1] OF FOO { .. } );> >> > OR I have to come up with a name for the embedded array.> > But of course, its type is really "the same" as the outer type.> > > Ignoring the fact that the types are different linguistically> (one a record type, the other an array), the types are different> at a deep semantic level too. The inner array has static> size, the outer one (call it a "variable array", perhaps)> has dynamically changeable size, even more easily changed> after it is created than a heap-allocated open array. This> is a significant semantic difference, so it also makes program> design sense to view them as different types.> > >> > To wit:> >> > TYPE FooArray = ARRAY[0..1] OF Foo;> >> > TYPE FooArray = RECORD> > a : FooArray;> > size := 1;> > END;> >> > F( FooArray { FooArray { .. } );> >> > But I have to come up with different names.> >> > And I don't think I can leave out the name for the constructor, like:> >> > F( FooArray { { .. } );> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> to omit inner type names in cases like this, and it is convenient. But> it also crosses a really major line on complexity of the language semantics,> since type analysis information now flows not only upward, but also downward> in expression typing. I am mostly content to live with this as one bit of> the price of avoiding a horribly over complex language.> > Ordinary procedures can do pretty much all of the things done by exotic> and complex language stuff like C++ constructors. If you don't want to write> the ponderous nested value constructor, write a constructor procedure and> call it. As Antony suggested, you can make it accept an open array formal,> which then codes just like a simple array value constructor. You could even> make it elaborate and general, e.g.:> > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > = VAR LSize : CARDINAL> ; VAR LResult : A> > ; BEGIN> LSize := NUMBER ( Val )> <* ASSERT LSize <= NUMBER ( FooArray ) *>> ; LResult . size := LSize> ; SUBARRAY ( LResult . a , 0 , LSize )> := SUBARRAY ( Val , FIRST ( Val ) , LSize )> ; RETURN LResult> END MakeF> > Alternatively, since your maximum element count is so small, you could> write a constructor procedure that took two formals of type FOO, with> at least the second one optional. (This would require a distinguished> value of type FOO that would be used to mean "omitted".)> > And, of course, if you want to use abstraction, you can put the types,> constructor procedures, and various other procedures for manipulating> the variable sized array in a module, behind an interface.> > An additional limitation of Modula-3 in this regard, is that you can't> make the type F opaque, unless you heap allocate it, which we were trying> to avoid. Ada would allow you to do this, but it's another example of> a convenience with high cost. It forces the equivalent of the revelation> to be located in the equivalent of the interface, but makes it illegal> to write client code that depends on what the revelation is.> > This in turn creates a source code control nightmare in a large project,> because now someone who wants to make what is really a purely internal,> implementation change, nevertheless has to check out the interface, and> if you aren't in denial mode, that means implementers of all the client> code have to go to extra trouble to somehow find out that what appears> to be an interface change actually doesn't affect them after all.> > >> > Though that might seem nice.> >> > Am I understanding everything?> >> > Have folks hit this before and there's a set of names that don't seem too lame> > that folks use?> >> > Also -- language documentation?> > Nelson's green book is excellent.> > The stuff in the doc directory is very dry and scientific.> > The tutorial seems more like a reference. Or maybe I didn't read it enough.> > Is there better, in case I need a refresher?> > I think I got it, via Nelson's book from memory (wonder if I can find mine..) and the reference,> > but I don't think anyone could learn from the current online docs in the source tree.> >> > Maybe it's me, some combination of laziness and short attention span> > as I age..> >> > Btw, C doesn't offer a great solution here, though it offers leaving out some type names.> > In C++ I could have both .size and operator[].> > Modula-3 seems to be missing operator overloading.> > It's got some builtin stuff, even array assignment and equality and I think> > even record assignment and equality, but it is still a bit limiting.> > > I have raved on this before, but, having had lots of painful experience with> user-defined overloading in Ada and C++, I can say with authority, that it is> a programming language disaster. It interacts with just about everything> else in the language, in very complicated ways, and all it buys you is saving> time/energy thinking up distinct names for procedures/functions. Even this,> aside from the effects on the language, is a net loss, by the time you consider> readability along with writability.> > User-defined overloaded operators provide a slight readability benefit, _if_> used with great restraint and discipline, something you can rely on not happening.> Meanwhile, the language complexity can easily double or worse. And, with the> exception of compiler writers and language lawyers who spend hundreds of hours> on just this, programmers don't understand the rules, not even close.> > >> > Also, if I understand things correctly, this has long bothered me about Modula-3,> > though I'm more tolerant now -- Modula-3 doesn't seem to allow for lighter wieght> > objects. Like, small stack allocated structs with member functions. You seem to have> > to chose between heap allocated garbage collected virtual member functions full> > featured objects, or featureless dumb structs. It's nice how C++ allow hybrids --> > objects don't have to be heap allocated and member functions don't have be virtual.> > Or am I missing something?> > > C++'s supposedly lighter weight forms of classes/structs with their special> member functions buy nothing that plain records, plain procedures, and> interfaces/modules don't already provide, again, at significant and gratuitous> language complexity. Except when methods/member functions actually dispatch> dynamically, there is nothing that the above won't do, and when you create a> class instance as a local variable (i.e., on the stack), it is necessarily> not polymorphic, that is, it can't change its "allocated" or dynamic type> among various subtypes at runtime. This in turn means it can't dispatch.> > So, just use plain procedures, an interface and a module, and you will get> everything a lighter-weight C++ class would give you.> > > >> > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal with> > t: Type;> > Type_DoSomething(t);> >> > in place of:> > t.DoSomething();> > > Exactly. The special "receiver object" in a true method call has significant> semantic differences from an ordinary parameter and introduces new complexities> and non-orthogonalities. It has some very valuable uses too.> > But to then create degenerate forms of it that still carry a lot of these> complexities, but are equivalent in programing power to plain old> parameters is just bad program design and bad language design. Objects and> methods are indeed cool for situations that utilize their semantic complexity.> But it's deeply uncool to try to look superficially cool by using an> inappropriately sophisticated construct when the problem doesn't justify it.> Some OO proponents have gone way over the deep end here.> > >> > - Jay> >> >> > ------------------------------------------------------------------------> > Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare! Try now! > > > > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu> > -- > -------------------------------------------------------------> Rodney M. Bates, retired assistant professor> Dept. of Computer Science, Wichita State University> Wichita, KS 67260-0083> 316-978-3922> rodney.bates at wichita.edu _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:15:27 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:15:27 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: <473CE6B6.3030402@wichita.edu> References: <473CE6B6.3030402@wichita.edu> Message-ID: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Is it really four words? I would have thought it might need a type reference and a size, what are the others for? On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > Jay wrote: > > > What is the right way to have a variably sized but always small > array in Modula-3? > > My array will only ever have 1 or 2 elements. > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > It seems I have a choice of > > > > a) an "open" array > > Heap allocated, I presume? If the max size is only 2 elements, > this is pretty extravagant, as a heap allocated open array will > have 4 extra behind-the-scenes words of space overhead, plus > maybe heap fragmentation, and time overhead of allocation, > collection, and maybe reduced locality of reference. > > > b) wrap it up in a record > > > > I'd like so have, like: > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > And be able to say: > > > > VAR > > a : A; > > > > .. > > a.size > > FOR i := 0 TO a.size DO > > do something with a[i] > > > > It seems I have no option but, like: > > > > TYPE A = RECORD > > a: ARRAY[0..1] OF FOO; > > size := 1; (* usually of size 1, sometimes 2 *) > > END > > > > and then > > FOR i := 0 TO a.size DO > > do something with a.a[i]; > > > > That is "ok". Not great -- what to call the inner a? > > But then furthermore, I'd like to construct constants. > > It seems I am stuck with either the verbose: > > > > PROCEDURE F(a:A); > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > OR I have to come up with a name for the embedded array. > > But of course, its type is really "the same" as the outer type. > > > Ignoring the fact that the types are different linguistically > (one a record type, the other an array), the types are different > at a deep semantic level too. The inner array has static > size, the outer one (call it a "variable array", perhaps) > has dynamically changeable size, even more easily changed > after it is created than a heap-allocated open array. This > is a significant semantic difference, so it also makes program > design sense to view them as different types. > > > > > To wit: > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > TYPE FooArray = RECORD > > a : FooArray; > > size := 1; > > END; > > > > F( FooArray { FooArray { .. } ); > > > > But I have to come up with different names. > > > > And I don't think I can leave out the name for the constructor, > like: > > > > F( FooArray { { .. } ); > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > to omit inner type names in cases like this, and it is convenient. > But > it also crosses a really major line on complexity of the language > semantics, > since type analysis information now flows not only upward, but also > downward > in expression typing. I am mostly content to live with this as one > bit of > the price of avoiding a horribly over complex language. > > Ordinary procedures can do pretty much all of the things done by > exotic > and complex language stuff like C++ constructors. If you don't > want to write > the ponderous nested value constructor, write a constructor > procedure and > call it. As Antony suggested, you can make it accept an open array > formal, > which then codes just like a simple array value constructor. You > could even > make it elaborate and general, e.g.: > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > = VAR LSize : CARDINAL > ; VAR LResult : A > > ; BEGIN > LSize := NUMBER ( Val ) > <* ASSERT LSize <= NUMBER ( FooArray ) *> > ; LResult . size := LSize > ; SUBARRAY ( LResult . a , 0 , LSize ) > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > ; RETURN LResult > END MakeF > > Alternatively, since your maximum element count is so small, you could > write a constructor procedure that took two formals of type FOO, with > at least the second one optional. (This would require a distinguished > value of type FOO that would be used to mean "omitted".) > > And, of course, if you want to use abstraction, you can put the types, > constructor procedures, and various other procedures for manipulating > the variable sized array in a module, behind an interface. > > An additional limitation of Modula-3 in this regard, is that you can't > make the type F opaque, unless you heap allocate it, which we were > trying > to avoid. Ada would allow you to do this, but it's another example of > a convenience with high cost. It forces the equivalent of the > revelation > to be located in the equivalent of the interface, but makes it illegal > to write client code that depends on what the revelation is. > > This in turn creates a source code control nightmare in a large > project, > because now someone who wants to make what is really a purely > internal, > implementation change, nevertheless has to check out the interface, > and > if you aren't in denial mode, that means implementers of all the > client > code have to go to extra trouble to somehow find out that what appears > to be an interface change actually doesn't affect them after all. > > > > > Though that might seem nice. > > > > Am I understanding everything? > > > > Have folks hit this before and there's a set of names that don't > seem too lame > > that folks use? > > > > Also -- language documentation? > > Nelson's green book is excellent. > > The stuff in the doc directory is very dry and scientific. > > The tutorial seems more like a reference. Or maybe I didn't read > it enough. > > Is there better, in case I need a refresher? > > I think I got it, via Nelson's book from memory (wonder if I can > find mine..) and the reference, > > but I don't think anyone could learn from the current online docs > in the source tree. > > > > Maybe it's me, some combination of laziness and short attention span > > as I age.. > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > In C++ I could have both .size and operator[]. > > Modula-3 seems to be missing operator overloading. > > It's got some builtin stuff, even array assignment and equality > and I think > > even record assignment and equality, but it is still a bit > limiting. > > > I have raved on this before, but, having had lots of painful > experience with > user-defined overloading in Ada and C++, I can say with authority, > that it is > a programming language disaster. It interacts with just about > everything > else in the language, in very complicated ways, and all it buys you > is saving > time/energy thinking up distinct names for procedures/functions. > Even this, > aside from the effects on the language, is a net loss, by the time > you consider > readability along with writability. > > User-defined overloaded operators provide a slight readability > benefit, _if_ > used with great restraint and discipline, something you can rely on > not happening. > Meanwhile, the language complexity can easily double or worse. > And, with the > exception of compiler writers and language lawyers who spend > hundreds of hours > on just this, programmers don't understand the rules, not even close. > > > > > Also, if I understand things correctly, this has long bothered me > about Modula-3, > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > objects. Like, small stack allocated structs with member > functions. You seem to have > > to chose between heap allocated garbage collected virtual member > functions full > > featured objects, or featureless dumb structs. It's nice how C++ > allow hybrids -- > > objects don't have to be heap allocated and member functions > don't have be virtual. > > Or am I missing something? > > > C++'s supposedly lighter weight forms of classes/structs with their > special > member functions buy nothing that plain records, plain procedures, and > interfaces/modules don't already provide, again, at significant and > gratuitous > language complexity. Except when methods/member functions actually > dispatch > dynamically, there is nothing that the above won't do, and when you > create a > class instance as a local variable (i.e., on the stack), it is > necessarily > not polymorphic, that is, it can't change its "allocated" or > dynamic type > among various subtypes at runtime. This in turn means it can't > dispatch. > > So, just use plain procedures, an interface and a module, and you > will get > everything a lighter-weight C++ class would give you. > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can deal > with > > t: Type; > > Type_DoSomething(t); > > > > in place of: > > t.DoSomething(); > > > Exactly. The special "receiver object" in a true method call has > significant > semantic differences from an ordinary parameter and introduces new > complexities > and non-orthogonalities. It has some very valuable uses too. > > But to then create degenerate forms of it that still carry a lot of > these > complexities, but are equivalent in programing power to plain old > parameters is just bad program design and bad language design. > Objects and > methods are indeed cool for situations that utilize their semantic > complexity. > But it's deeply uncool to try to look superficially cool by using an > inappropriately sophisticated construct when the problem doesn't > justify it. > Some OO proponents have gone way over the deep end here. > > > > > - Jay > > > > > > > ---------------------------------------------------------------------- > -- > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! trial.aspx?s_cid=wl_hotmailnews> > > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu > > -- > ------------------------------------------------------------- > Rodney M. Bates, retired assistant professor > Dept. of Computer Science, Wichita State University > Wichita, KS 67260-0083 > 316-978-3922 > rodney.bates at wichita.edu From darko at darko.org Fri Nov 16 05:29:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:29:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Not sure what the problem is with modules. If you want to avoid the dot you can name the type something unique then import that type name. You can create an interface with all the nice type names and import all those names in modules by adding an EXPORTS clause too. Personally I think M3, with a couple of extensions, wouldn't need unsafe anything. The unsafe features are there mostly because of legacy interfaces. I forget the name but the folk who wrote an OS in M3 found it very effective with only couple of minor points with regards to interfacing to C code they built on top of, I think one of them was being able to pass NIL to a VAR parameter, which is a common C idiom (and an annoying one for M3 users who then can't use VAR). On 15/11/2007, at 8:08 PM, Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book > so I don't have to find mine. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". > If it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named > "method", then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever > happens to work". > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; > > seems "good". > > And it seems not really all that complicated for the compiler to > flow the static type information around to resolve the functions.. > > Rect_t r; > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > I do find some compelling features in Modula-3. Mainly that it > compiles to native code and has OPTIONAL safety, optional garbage > collection, and that the syntax of modules/interfaces allows fast > compilation -- no longer reparsing the same headers over and over > and over and over. > > Operator overloading btw..have seen "template SafeInt"? It acts > like a primitive integer, but raises exceptions upon overflow. > For this to work very much requires operator overloading. > > A point, of course, is to be able to have user defined types that > can act like the built in types.. > > - Jay > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > From: rodney.bates at wichita.edu > > To: m3devel at elegosoft.com > > Subject: Re: [M3devel] small array in modula-3? > > > > Jay wrote: > > > > > What is the right way to have a variably sized but always small > array in Modula-3? > > > My array will only ever have 1 or 2 elements. > > > I'd like to always allocate room for 2 elements, and have there > be a size. > > > > > > It seems I have a choice of > > > > > > a) an "open" array > > > > Heap allocated, I presume? If the max size is only 2 elements, > > this is pretty extravagant, as a heap allocated open array will > > have 4 extra behind-the-scenes words of space overhead, plus > > maybe heap fragmentation, and time overhead of allocation, > > collection, and maybe reduced locality of reference. > > > > > b) wrap it up in a record > > > > > > I'd like so have, like: > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > And be able to say: > > > > > > VAR > > > a : A; > > > > > > .. > > > a.size > > > FOR i := 0 TO a.size DO > > > do something with a[i] > > > > > > It seems I have no option but, like: > > > > > > TYPE A = RECORD > > > a: ARRAY[0..1] OF FOO; > > > size := 1; (* usually of size 1, sometimes 2 *) > > > END > > > > > > and then > > > FOR i := 0 TO a.size DO > > > do something with a.a[i]; > > > > > > That is "ok". Not great -- what to call the inner a? > > > But then furthermore, I'd like to construct constants. > > > It seems I am stuck with either the verbose: > > > > > > PROCEDURE F(a:A); > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > OR I have to come up with a name for the embedded array. > > > But of course, its type is really "the same" as the outer type. > > > > > > Ignoring the fact that the types are different linguistically > > (one a record type, the other an array), the types are different > > at a deep semantic level too. The inner array has static > > size, the outer one (call it a "variable array", perhaps) > > has dynamically changeable size, even more easily changed > > after it is created than a heap-allocated open array. This > > is a significant semantic difference, so it also makes program > > design sense to view them as different types. > > > > > > > > To wit: > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > TYPE FooArray = RECORD > > > a : FooArray; > > > size := 1; > > > END; > > > > > > F( FooArray { FooArray { .. } ); > > > > > > But I have to come up with different names. > > > > > > And I don't think I can leave out the name for the constructor, > like: > > > > > > F( FooArray { { .. } ); > > > > > > Yes, this is a limitation in Modula-3. Ada allows value constructors > > to omit inner type names in cases like this, and it is > convenient. But > > it also crosses a really major line on complexity of the language > semantics, > > since type analysis information now flows not only upward, but > also downward > > in expression typing. I am mostly content to live with this as > one bit of > > the price of avoiding a horribly over complex language. > > > > Ordinary procedures can do pretty much all of the things done by > exotic > > and complex language stuff like C++ constructors. If you don't > want to write > > the ponderous nested value constructor, write a constructor > procedure and > > call it. As Antony suggested, you can make it accept an open > array formal, > > which then codes just like a simple array value constructor. You > could even > > make it elaborate and general, e.g.: > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > = VAR LSize : CARDINAL > > ; VAR LResult : A > > > > ; BEGIN > > LSize := NUMBER ( Val ) > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > ; LResult . size := LSize > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > ; RETURN LResult > > END MakeF > > > > Alternatively, since your maximum element count is so small, you > could > > write a constructor procedure that took two formals of type FOO, > with > > at least the second one optional. (This would require a > distinguished > > value of type FOO that would be used to mean "omitted".) > > > > And, of course, if you want to use abstraction, you can put the > types, > > constructor procedures, and various other procedures for > manipulating > > the variable sized array in a module, behind an interface. > > > > An additional limitation of Modula-3 in this regard, is that you > can't > > make the type F opaque, unless you heap allocate it, which we > were trying > > to avoid. Ada would allow you to do this, but it's another > example of > > a convenience with high cost. It forces the equivalent of the > revelation > > to be located in the equivalent of the interface, but makes it > illegal > > to write client code that depends on what the revelation is. > > > > This in turn creates a source code control nightmare in a large > project, > > because now someone who wants to make what is really a purely > internal, > > implementation change, nevertheless has to check out the > interface, and > > if you aren't in denial mode, that means implementers of all the > client > > code have to go to extra trouble to somehow find out that what > appears > > to be an interface change actually doesn't affect them after all. > > > > > > > > Though that might seem nice. > > > > > > Am I understanding everything? > > > > > > Have folks hit this before and there's a set of names that > don't seem too lame > > > that folks use? > > > > > > Also -- language documentation? > > > Nelson's green book is excellent. > > > The stuff in the doc directory is very dry and scientific. > > > The tutorial seems more like a reference. Or maybe I didn't > read it enough. > > > Is there better, in case I need a refresher? > > > I think I got it, via Nelson's book from memory (wonder if I > can find mine..) and the reference, > > > but I don't think anyone could learn from the current online > docs in the source tree. > > > > > > Maybe it's me, some combination of laziness and short attention > span > > > as I age.. > > > > > > Btw, C doesn't offer a great solution here, though it offers > leaving out some type names. > > > In C++ I could have both .size and operator[]. > > > Modula-3 seems to be missing operator overloading. > > > It's got some builtin stuff, even array assignment and equality > and I think > > > even record assignment and equality, but it is still a bit > limiting. > > > > > > I have raved on this before, but, having had lots of painful > experience with > > user-defined overloading in Ada and C++, I can say with > authority, that it is > > a programming language disaster. It interacts with just about > everything > > else in the language, in very complicated ways, and all it buys > you is saving > > time/energy thinking up distinct names for procedures/functions. > Even this, > > aside from the effects on the language, is a net loss, by the > time you consider > > readability along with writability. > > > > User-defined overloaded operators provide a slight readability > benefit, _if_ > > used with great restraint and discipline, something you can rely > on not happening. > > Meanwhile, the language complexity can easily double or worse. > And, with the > > exception of compiler writers and language lawyers who spend > hundreds of hours > > on just this, programmers don't understand the rules, not even > close. > > > > > > > > Also, if I understand things correctly, this has long bothered > me about Modula-3, > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > for lighter wieght > > > objects. Like, small stack allocated structs with member > functions. You seem to have > > > to chose between heap allocated garbage collected virtual > member functions full > > > featured objects, or featureless dumb structs. It's nice how C+ > + allow hybrids -- > > > objects don't have to be heap allocated and member functions > don't have be virtual. > > > Or am I missing something? > > > > > > C++'s supposedly lighter weight forms of classes/structs with > their special > > member functions buy nothing that plain records, plain > procedures, and > > interfaces/modules don't already provide, again, at significant > and gratuitous > > language complexity. Except when methods/member functions > actually dispatch > > dynamically, there is nothing that the above won't do, and when > you create a > > class instance as a local variable (i.e., on the stack), it is > necessarily > > not polymorphic, that is, it can't change its "allocated" or > dynamic type > > among various subtypes at runtime. This in turn means it can't > dispatch. > > > > So, just use plain procedures, an interface and a module, and you > will get > > everything a lighter-weight C++ class would give you. > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > deal with > > > t: Type; > > > Type_DoSomething(t); > > > > > > in place of: > > > t.DoSomething(); > > > > > > Exactly. The special "receiver object" in a true method call has > significant > > semantic differences from an ordinary parameter and introduces > new complexities > > and non-orthogonalities. It has some very valuable uses too. > > > > But to then create degenerate forms of it that still carry a lot > of these > > complexities, but are equivalent in programing power to plain old > > parameters is just bad program design and bad language design. > Objects and > > methods are indeed cool for situations that utilize their > semantic complexity. > > But it's deeply uncool to try to look superficially cool by using an > > inappropriately sophisticated construct when the problem doesn't > justify it. > > Some OO proponents have gone way over the deep end here. > > > > > > > > - Jay > > > > > > > > > > ---------------------------------------------------------------------- > -- > > > Boo! Scare away worms, viruses and so much more! Try Windows > Live OneCare! Try now! > > s_cid=wl_hotmailnews> > > > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > > -- > > ------------------------------------------------------------- > > Rodney M. Bates, retired assistant professor > > Dept. of Computer Science, Wichita State University > > Wichita, KS 67260-0083 > > 316-978-3922 > > rodney.bates at wichita.edu > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > OneCare! Try now! From jay.krell at cornell.edu Fri Nov 16 05:40:40 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 16 Nov 2007 04:40:40 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: But if I don't want to pay for heap allocation, I can't say: VAR T: v; v.DoSomething(); Only IMPORT T FROM M; VAR T: v; M.DoSomething(v); Right? SPIN I think you mean. Anyone build it and bring it up? I was long curious but never did.. - Jay > CC: m3devel at elegosoft.com> From: darko at darko.org> Subject: Re: [M3devel] small array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.krell at cornell.edu> > Not sure what the problem is with modules. If you want to avoid the > dot you can name the type something unique then import that type > name. You can create an interface with all the nice type names and > import all those names in modules by adding an EXPORTS clause too.> > Personally I think M3, with a couple of extensions, wouldn't need > unsafe anything. The unsafe features are there mostly because of > legacy interfaces. I forget the name but the folk who wrote an OS in > M3 found it very effective with only couple of minor points with > regards to interfacing to C code they built on top of, I think one of > them was being able to pass NIL to a VAR parameter, which is a common > C idiom (and an annoying one for M3 users who then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > > Rodney, thank you, this is interesting.> > I definitely don't want to pay for heap allocation for a tiny array.> > I don't know about "subarray". It looks like it takes and returns > > arrays. It's not a type. I ordered another copy of the Nelson book > > so I don't have to find mine.> >> > Good idea "MakeT" I forgot about that pattern. I'll try it out.> >> > The record and array I propose are not all that different really.> > I just heard of something new. Have you heard of it? "Duck typing". > > If it acts/quacks/walks like a duck, it is a duck.> > This is in very dynamic languages like Ruby.> > You apply object.method and if object defines something named > > "method", then it "must" have "the" meaning you intend.> > Kind of like how C++ templates "accept as parameters whatever > > happens to work".> >> > Operator overloading is great for strings and "math".> >> > Maybe I should try to have this language debate from scratch again..?> >> > I still am conflcted.> >> > Modules seem overly heavyweight.> > I don't want Module1.T, Module2.T, I want T1, T2.> >> > C++ stack structs with non virtual member functions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(0) { }> >> > int Height() { return bottom - top; }> > int Width() { return right - left; }> > int top, left, bottom, right;> > };> >> > seems "good".> >> > And it seems not really all that complicated for the compiler to > > flow the static type information around to resolve the functions..> >> > Rect_t r;> > r.Height() => Rect_Height(&r); ..and would be inlined anyway.> >> > I do find some compelling features in Modula-3. Mainly that it > > compiles to native code and has OPTIONAL safety, optional garbage > > collection, and that the syntax of modules/interfaces allows fast > > compilation -- no longer reparsing the same headers over and over > > and over and over.> >> > Operator overloading btw..have seen "template SafeInt"? It acts > > like a primitive integer, but raises exceptions upon overflow.> > For this to work very much requires operator overloading.> >> > A point, of course, is to be able to have user defined types that > > can act like the built in types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:18 -0600> > > From: rodney.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > Subject: Re: [M3devel] small array in modula-3?> > >> > > Jay wrote:> > >> > > > What is the right way to have a variably sized but always small > > array in Modula-3?> > > > My array will only ever have 1 or 2 elements.> > > > I'd like to always allocate room for 2 elements, and have there > > be a size.> > > >> > > > It seems I have a choice of> > > >> > > > a) an "open" array> > >> > > Heap allocated, I presume? If the max size is only 2 elements,> > > this is pretty extravagant, as a heap allocated open array will> > > have 4 extra behind-the-scenes words of space overhead, plus> > > maybe heap fragmentation, and time overhead of allocation,> > > collection, and maybe reduced locality of reference.> > >> > > > b) wrap it up in a record> > > >> > > > I'd like so have, like:> > > >> > > > TYPE A = ARRAY [0..1] OF FOO;> > > >> > > > And be able to say:> > > >> > > > VAR> > > > a : A;> > > >> > > > ..> > > > a.size> > > > FOR i := 0 TO a.size DO> > > > do something with a[i]> > > >> > > > It seems I have no option but, like:> > > >> > > > TYPE A = RECORD> > > > a: ARRAY[0..1] OF FOO;> > > > size := 1; (* usually of size 1, sometimes 2 *)> > > > END> > > >> > > > and then> > > > FOR i := 0 TO a.size DO> > > > do something with a.a[i];> > > >> > > > That is "ok". Not great -- what to call the inner a?> > > > But then furthermore, I'd like to construct constants.> > > > It seems I am stuck with either the verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name for the embedded array.> > > > But of course, its type is really "the same" as the outer type.> > >> > >> > > Ignoring the fact that the types are different linguistically> > > (one a record type, the other an array), the types are different> > > at a deep semantic level too. The inner array has static> > > size, the outer one (call it a "variable array", perhaps)> > > has dynamically changeable size, even more easily changed> > > after it is created than a heap-allocated open array. This> > > is a significant semantic difference, so it also makes program> > > design sense to view them as different types.> > >> > > >> > > > To wit:> > > >> > > > TYPE FooArray = ARRAY[0..1] OF Foo;> > > >> > > > TYPE FooArray = RECORD> > > > a : FooArray;> > > > size := 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );> > > >> > > > But I have to come up with different names.> > > >> > > > And I don't think I can leave out the name for the constructor, > > like:> > > >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, this is a limitation in Modula-3. Ada allows value constructors> > > to omit inner type names in cases like this, and it is > > convenient. But> > > it also crosses a really major line on complexity of the language > > semantics,> > > since type analysis information now flows not only upward, but > > also downward> > > in expression typing. I am mostly content to live with this as > > one bit of> > > the price of avoiding a horribly over complex language.> > >> > > Ordinary procedures can do pretty much all of the things done by > > exotic> > > and complex language stuff like C++ constructors. If you don't > > want to write> > > the ponderous nested value constructor, write a constructor > > procedure and> > > call it. As Antony suggested, you can make it accept an open > > array formal,> > > which then codes just like a simple array value constructor. You > > could even> > > make it elaborate and general, e.g.:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = VAR LSize : CARDINAL> > > ; VAR LResult : A> > >> > > ; BEGIN> > > LSize := NUMBER ( Val )> > > <* ASSERT LSize <= NUMBER ( FooArray ) *>> > > ; LResult . size := LSize> > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > := SUBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RETURN LResult> > > END MakeF> > >> > > Alternatively, since your maximum element count is so small, you > > could> > > write a constructor procedure that took two formals of type FOO, > > with> > > at least the second one optional. (This would require a > > distinguished> > > value of type FOO that would be used to mean "omitted".)> > >> > > And, of course, if you want to use abstraction, you can put the > > types,> > > constructor procedures, and various other procedures for > > manipulating> > > the variable sized array in a module, behind an interface.> > >> > > An additional limitation of Modula-3 in this regard, is that you > > can't> > > make the type F opaque, unless you heap allocate it, which we > > were trying> > > to avoid. Ada would allow you to do this, but it's another > > example of> > > a convenience with high cost. It forces the equivalent of the > > revelation> > > to be located in the equivalent of the interface, but makes it > > illegal> > > to write client code that depends on what the revelation is.> > >> > > This in turn creates a source code control nightmare in a large > > project,> > > because now someone who wants to make what is really a purely > > internal,> > > implementation change, nevertheless has to check out the > > interface, and> > > if you aren't in denial mode, that means implementers of all the > > client> > > code have to go to extra trouble to somehow find out that what > > appears> > > to be an interface change actually doesn't affect them after all.> > >> > > >> > > > Though that might seem nice.> > > >> > > > Am I understanding everything?> > > >> > > > Have folks hit this before and there's a set of names that > > don't seem too lame> > > > that folks use?> > > >> > > > Also -- language documentation?> > > > Nelson's green book is excellent.> > > > The stuff in the doc directory is very dry and scientific.> > > > The tutorial seems more like a reference. Or maybe I didn't > > read it enough.> > > > Is there better, in case I need a refresher?> > > > I think I got it, via Nelson's book from memory (wonder if I > > can find mine..) and the reference,> > > > but I don't think anyone could learn from the current online > > docs in the source tree.> > > >> > > > Maybe it's me, some combination of laziness and short attention > > span> > > > as I age..> > > >> > > > Btw, C doesn't offer a great solution here, though it offers > > leaving out some type names.> > > > In C++ I could have both .size and operator[].> > > > Modula-3 seems to be missing operator overloading.> > > > It's got some builtin stuff, even array assignment and equality > > and I think> > > > even record assignment and equality, but it is still a bit > > limiting.> > >> > >> > > I have raved on this before, but, having had lots of painful > > experience with> > > user-defined overloading in Ada and C++, I can say with > > authority, that it is> > > a programming language disaster. It interacts with just about > > everything> > > else in the language, in very complicated ways, and all it buys > > you is saving> > > time/energy thinking up distinct names for procedures/functions. > > Even this,> > > aside from the effects on the language, is a net loss, by the > > time you consider> > > readability along with writability.> > >> > > User-defined overloaded operators provide a slight readability > > benefit, _if_> > > used with great restraint and discipline, something you can rely > > on not happening.> > > Meanwhile, the language complexity can easily double or worse. > > And, with the> > > exception of compiler writers and language lawyers who spend > > hundreds of hours> > > on just this, programmers don't understand the rules, not even > > close.> > >> > > >> > > > Also, if I understand things correctly, this has long bothered > > me about Modula-3,> > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > > objects. Like, small stack allocated structs with member > > functions. You seem to have> > > > to chose between heap allocated garbage collected virtual > > member functions full> > > > featured objects, or featureless dumb structs. It's nice how C+ > > + allow hybrids --> > > > objects don't have to be heap allocated and member functions > > don't have be virtual.> > > > Or am I missing something?> > >> > >> > > C++'s supposedly lighter weight forms of classes/structs with > > their special> > > member functions buy nothing that plain records, plain > > procedures, and> > > interfaces/modules don't already provide, again, at significant > > and gratuitous> > > language complexity. Except when methods/member functions > > actually dispatch> > > dynamically, there is nothing that the above won't do, and when > > you create a> > > class instance as a local variable (i.e., on the stack), it is > > necessarily> > > not polymorphic, that is, it can't change its "allocated" or > > dynamic type> > > among various subtypes at runtime. This in turn means it can't > > dispatch.> > >> > > So, just use plain procedures, an interface and a module, and you > > will get> > > everything a lighter-weight C++ class would give you.> > >> > >> > > >> > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > deal with> > > > t: Type;> > > > Type_DoSomething(t);> > > >> > > > in place of:> > > > t.DoSomething();> > >> > >> > > Exactly. The special "receiver object" in a true method call has > > significant> > > semantic differences from an ordinary parameter and introduces > > new complexities> > > and non-orthogonalities. It has some very valuable uses too.> > >> > > But to then create degenerate forms of it that still carry a lot > > of these> > > complexities, but are equivalent in programing power to plain old> > > parameters is just bad program design and bad language design. > > Objects and> > > methods are indeed cool for situations that utilize their > > semantic complexity.> > > But it's deeply uncool to try to look superficially cool by using an> > > inappropriately sophisticated construct when the problem doesn't > > justify it.> > > Some OO proponents have gone way over the deep end here.> > >> > > >> > > > - Jay> > > >> > > >> > > > > > ---------------------------------------------------------------------- > > --> > > > Boo! Scare away worms, viruses and so much more! Try Windows > > Live OneCare! Try now!> > > > s_cid=wl_hotmailnews>> > >> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------------------------------------------------------> > > Rodney M. Bates, retired assistant professor> > > Dept. of Computer Science, Wichita State University> > > Wichita, KS 67260-0083> > > 316-978-3922> > > rodney.bates at wichita.edu> >> >> > Boo! Scare away worms, viruses and so much more! Try Windows Live > > OneCare! Try now!> _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From darko at darko.org Fri Nov 16 05:54:06 2007 From: darko at darko.org (Darko) Date: Thu, 15 Nov 2007 20:54:06 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <5F3751E8-9726-403A-AFBB-26A28FE08D0E@darko.org> Message-ID: <430632D5-F522-4B12-BED7-FB65291896BD@darko.org> M3 doesn't have class methods or what have you but you can give v a method which isn't instance specific which is the same diff and doesn't really cost anything. If you read "How M3 Got Its Spots" I think the chapter is called they make a reference to this, and not a very kind one. I don't think they liked the idea. On 15/11/2007, at 8:40 PM, Jay wrote: > But if I don't want to pay for heap allocation, I can't say: > > VAR T: v; > > v.DoSomething(); > > Only IMPORT T FROM M; > > VAR T: v; > > M.DoSomething(v); > > Right? > > SPIN I think you mean. > Anyone build it and bring it up? I was long curious but never did.. > > - Jay > > > > > CC: m3devel at elegosoft.com > > From: darko at darko.org > > Subject: Re: [M3devel] small array in modula-3? > > Date: Thu, 15 Nov 2007 20:29:06 -0800 > > To: jay.krell at cornell.edu > > > > Not sure what the problem is with modules. If you want to avoid the > > dot you can name the type something unique then import that type > > name. You can create an interface with all the nice type names and > > import all those names in modules by adding an EXPORTS clause too. > > > > Personally I think M3, with a couple of extensions, wouldn't need > > unsafe anything. The unsafe features are there mostly because of > > legacy interfaces. I forget the name but the folk who wrote an OS in > > M3 found it very effective with only couple of minor points with > > regards to interfacing to C code they built on top of, I think > one of > > them was being able to pass NIL to a VAR parameter, which is a > common > > C idiom (and an annoying one for M3 users who then can't use VAR). > > > > > > On 15/11/2007, at 8:08 PM, Jay wrote: > > > > > Rodney, thank you, this is interesting. > > > I definitely don't want to pay for heap allocation for a tiny > array. > > > I don't know about "subarray". It looks like it takes and returns > > > arrays. It's not a type. I ordered another copy of the Nelson book > > > so I don't have to find mine. > > > > > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > > > > > The record and array I propose are not all that different really. > > > I just heard of something new. Have you heard of it? "Duck > typing". > > > If it acts/quacks/walks like a duck, it is a duck. > > > This is in very dynamic languages like Ruby. > > > You apply object.method and if object defines something named > > > "method", then it "must" have "the" meaning you intend. > > > Kind of like how C++ templates "accept as parameters whatever > > > happens to work". > > > > > > Operator overloading is great for strings and "math". > > > > > > Maybe I should try to have this language debate from scratch > again..? > > > > > > I still am conflcted. > > > > > > Modules seem overly heavyweight. > > > I don't want Module1.T, Module2.T, I want T1, T2. > > > > > > C++ stack structs with non virtual member functions: > > > class Rect_t > > > { > > > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > > > > > int Height() { return bottom - top; } > > > int Width() { return right - left; } > > > int top, left, bottom, right; > > > }; > > > > > > seems "good". > > > > > > And it seems not really all that complicated for the compiler to > > > flow the static type information around to resolve the functions.. > > > > > > Rect_t r; > > > r.Height() => Rect_Height(&r); ..and would be inlined anyway. > > > > > > I do find some compelling features in Modula-3. Mainly that it > > > compiles to native code and has OPTIONAL safety, optional garbage > > > collection, and that the syntax of modules/interfaces allows fast > > > compilation -- no longer reparsing the same headers over and over > > > and over and over. > > > > > > Operator overloading btw..have seen "template SafeInt"? It acts > > > like a primitive integer, but raises exceptions upon overflow. > > > For this to work very much requires operator overloading. > > > > > > A point, of course, is to be able to have user defined types that > > > can act like the built in types.. > > > > > > - Jay > > > > > > > > > > Date: Thu, 15 Nov 2007 18:39:18 -0600 > > > > From: rodney.bates at wichita.edu > > > > To: m3devel at elegosoft.com > > > > Subject: Re: [M3devel] small array in modula-3? > > > > > > > > Jay wrote: > > > > > > > > > What is the right way to have a variably sized but always > small > > > array in Modula-3? > > > > > My array will only ever have 1 or 2 elements. > > > > > I'd like to always allocate room for 2 elements, and have > there > > > be a size. > > > > > > > > > > It seems I have a choice of > > > > > > > > > > a) an "open" array > > > > > > > > Heap allocated, I presume? If the max size is only 2 elements, > > > > this is pretty extravagant, as a heap allocated open array will > > > > have 4 extra behind-the-scenes words of space overhead, plus > > > > maybe heap fragmentation, and time overhead of allocation, > > > > collection, and maybe reduced locality of reference. > > > > > > > > > b) wrap it up in a record > > > > > > > > > > I'd like so have, like: > > > > > > > > > > TYPE A = ARRAY [0..1] OF FOO; > > > > > > > > > > And be able to say: > > > > > > > > > > VAR > > > > > a : A; > > > > > > > > > > .. > > > > > a.size > > > > > FOR i := 0 TO a.size DO > > > > > do something with a[i] > > > > > > > > > > It seems I have no option but, like: > > > > > > > > > > TYPE A = RECORD > > > > > a: ARRAY[0..1] OF FOO; > > > > > size := 1; (* usually of size 1, sometimes 2 *) > > > > > END > > > > > > > > > > and then > > > > > FOR i := 0 TO a.size DO > > > > > do something with a.a[i]; > > > > > > > > > > That is "ok". Not great -- what to call the inner a? > > > > > But then furthermore, I'd like to construct constants. > > > > > It seems I am stuck with either the verbose: > > > > > > > > > > PROCEDURE F(a:A); > > > > > > > > > > F( A { ARRAY[0..1] OF FOO { .. } ); > > > > > > > > > > OR I have to come up with a name for the embedded array. > > > > > But of course, its type is really "the same" as the outer > type. > > > > > > > > > > > > Ignoring the fact that the types are different linguistically > > > > (one a record type, the other an array), the types are different > > > > at a deep semantic level too. The inner array has static > > > > size, the outer one (call it a "variable array", perhaps) > > > > has dynamically changeable size, even more easily changed > > > > after it is created than a heap-allocated open array. This > > > > is a significant semantic difference, so it also makes program > > > > design sense to view them as different types. > > > > > > > > > > > > > > To wit: > > > > > > > > > > TYPE FooArray = ARRAY[0..1] OF Foo; > > > > > > > > > > TYPE FooArray = RECORD > > > > > a : FooArray; > > > > > size := 1; > > > > > END; > > > > > > > > > > F( FooArray { FooArray { .. } ); > > > > > > > > > > But I have to come up with different names. > > > > > > > > > > And I don't think I can leave out the name for the > constructor, > > > like: > > > > > > > > > > F( FooArray { { .. } ); > > > > > > > > > > > > Yes, this is a limitation in Modula-3. Ada allows value > constructors > > > > to omit inner type names in cases like this, and it is > > > convenient. But > > > > it also crosses a really major line on complexity of the > language > > > semantics, > > > > since type analysis information now flows not only upward, but > > > also downward > > > > in expression typing. I am mostly content to live with this as > > > one bit of > > > > the price of avoiding a horribly over complex language. > > > > > > > > Ordinary procedures can do pretty much all of the things done by > > > exotic > > > > and complex language stuff like C++ constructors. If you don't > > > want to write > > > > the ponderous nested value constructor, write a constructor > > > procedure and > > > > call it. As Antony suggested, you can make it accept an open > > > array formal, > > > > which then codes just like a simple array value constructor. You > > > could even > > > > make it elaborate and general, e.g.: > > > > > > > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F > > > > > > > > = VAR LSize : CARDINAL > > > > ; VAR LResult : A > > > > > > > > ; BEGIN > > > > LSize := NUMBER ( Val ) > > > > <* ASSERT LSize <= NUMBER ( FooArray ) *> > > > > ; LResult . size := LSize > > > > ; SUBARRAY ( LResult . a , 0 , LSize ) > > > > := SUBARRAY ( Val , FIRST ( Val ) , LSize ) > > > > ; RETURN LResult > > > > END MakeF > > > > > > > > Alternatively, since your maximum element count is so small, you > > > could > > > > write a constructor procedure that took two formals of type FOO, > > > with > > > > at least the second one optional. (This would require a > > > distinguished > > > > value of type FOO that would be used to mean "omitted".) > > > > > > > > And, of course, if you want to use abstraction, you can put the > > > types, > > > > constructor procedures, and various other procedures for > > > manipulating > > > > the variable sized array in a module, behind an interface. > > > > > > > > An additional limitation of Modula-3 in this regard, is that you > > > can't > > > > make the type F opaque, unless you heap allocate it, which we > > > were trying > > > > to avoid. Ada would allow you to do this, but it's another > > > example of > > > > a convenience with high cost. It forces the equivalent of the > > > revelation > > > > to be located in the equivalent of the interface, but makes it > > > illegal > > > > to write client code that depends on what the revelation is. > > > > > > > > This in turn creates a source code control nightmare in a large > > > project, > > > > because now someone who wants to make what is really a purely > > > internal, > > > > implementation change, nevertheless has to check out the > > > interface, and > > > > if you aren't in denial mode, that means implementers of all the > > > client > > > > code have to go to extra trouble to somehow find out that what > > > appears > > > > to be an interface change actually doesn't affect them after > all. > > > > > > > > > > > > > > Though that might seem nice. > > > > > > > > > > Am I understanding everything? > > > > > > > > > > Have folks hit this before and there's a set of names that > > > don't seem too lame > > > > > that folks use? > > > > > > > > > > Also -- language documentation? > > > > > Nelson's green book is excellent. > > > > > The stuff in the doc directory is very dry and scientific. > > > > > The tutorial seems more like a reference. Or maybe I didn't > > > read it enough. > > > > > Is there better, in case I need a refresher? > > > > > I think I got it, via Nelson's book from memory (wonder if I > > > can find mine..) and the reference, > > > > > but I don't think anyone could learn from the current online > > > docs in the source tree. > > > > > > > > > > Maybe it's me, some combination of laziness and short > attention > > > span > > > > > as I age.. > > > > > > > > > > Btw, C doesn't offer a great solution here, though it offers > > > leaving out some type names. > > > > > In C++ I could have both .size and operator[]. > > > > > Modula-3 seems to be missing operator overloading. > > > > > It's got some builtin stuff, even array assignment and > equality > > > and I think > > > > > even record assignment and equality, but it is still a bit > > > limiting. > > > > > > > > > > > > I have raved on this before, but, having had lots of painful > > > experience with > > > > user-defined overloading in Ada and C++, I can say with > > > authority, that it is > > > > a programming language disaster. It interacts with just about > > > everything > > > > else in the language, in very complicated ways, and all it buys > > > you is saving > > > > time/energy thinking up distinct names for procedures/functions. > > > Even this, > > > > aside from the effects on the language, is a net loss, by the > > > time you consider > > > > readability along with writability. > > > > > > > > User-defined overloaded operators provide a slight readability > > > benefit, _if_ > > > > used with great restraint and discipline, something you can rely > > > on not happening. > > > > Meanwhile, the language complexity can easily double or worse. > > > And, with the > > > > exception of compiler writers and language lawyers who spend > > > hundreds of hours > > > > on just this, programmers don't understand the rules, not even > > > close. > > > > > > > > > > > > > > Also, if I understand things correctly, this has long bothered > > > me about Modula-3, > > > > > though I'm more tolerant now -- Modula-3 doesn't seem to allow > > > for lighter wieght > > > > > objects. Like, small stack allocated structs with member > > > functions. You seem to have > > > > > to chose between heap allocated garbage collected virtual > > > member functions full > > > > > featured objects, or featureless dumb structs. It's nice > how C+ > > > + allow hybrids -- > > > > > objects don't have to be heap allocated and member functions > > > don't have be virtual. > > > > > Or am I missing something? > > > > > > > > > > > > C++'s supposedly lighter weight forms of classes/structs with > > > their special > > > > member functions buy nothing that plain records, plain > > > procedures, and > > > > interfaces/modules don't already provide, again, at significant > > > and gratuitous > > > > language complexity. Except when methods/member functions > > > actually dispatch > > > > dynamically, there is nothing that the above won't do, and when > > > you create a > > > > class instance as a local variable (i.e., on the stack), it is > > > necessarily > > > > not polymorphic, that is, it can't change its "allocated" or > > > dynamic type > > > > among various subtypes at runtime. This in turn means it can't > > > dispatch. > > > > > > > > So, just use plain procedures, an interface and a module, and > you > > > will get > > > > everything a lighter-weight C++ class would give you. > > > > > > > > > > > > > > > > > > Anyway, I've gotten to accept C a bit more vs. C++ so I can > > > deal with > > > > > t: Type; > > > > > Type_DoSomething(t); > > > > > > > > > > in place of: > > > > > t.DoSomething(); > > > > > > > > > > > > Exactly. The special "receiver object" in a true method call has > > > significant > > > > semantic differences from an ordinary parameter and introduces > > > new complexities > > > > and non-orthogonalities. It has some very valuable uses too. > > > > > > > > But to then create degenerate forms of it that still carry a lot > > > of these > > > > complexities, but are equivalent in programing power to plain > old > > > > parameters is just bad program design and bad language design. > > > Objects and > > > > methods are indeed cool for situations that utilize their > > > semantic complexity. > > > > But it's deeply uncool to try to look superficially cool by > using an > > > > inappropriately sophisticated construct when the problem doesn't > > > justify it. > > > > Some OO proponents have gone way over the deep end here. > > > > > > > > > > > > > > - Jay > > > > > > > > > > > > > > > > > > > ---------------------------------------------------------------------- > > > -- > > > > > Boo! Scare away worms, viruses and so much more! Try Windows > > > Live OneCare! Try now! > > > > > > s_cid=wl_hotmailnews> > > > > > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > -- > > > > ------------------------------------------------------------- > > > > Rodney M. Bates, retired assistant professor > > > > Dept. of Computer Science, Wichita State University > > > > Wichita, KS 67260-0083 > > > > 316-978-3922 > > > > rodney.bates at wichita.edu > > > > > > > > > Boo! Scare away worms, viruses and so much more! Try Windows Live > > > OneCare! Try now! > > > > > Climb to the top of the charts! Play Star Shuffle: the word > scramble challenge with star power. Play Now! From lemming at henning-thielemann.de Fri Nov 16 09:42:26 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 09:42:26 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Jay wrote: > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. This way generic modules would not work. They require that the parameter modules have exactly the same interface. 'T' everywhere looked strange to me at first, but I get used to it and now I also use that naming in other languages (namely Haskell). Btw. Haskell has a restricted kind of operator overloading by so called type classes. Although sometimes useful, people tend to overuse it. From rodney.bates at wichita.edu Fri Nov 16 22:42:35 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:42:35 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> Message-ID: <473E0ECB.504@wichita.edu> Jay wrote: > Rodney, thank you, this is interesting. > I definitely don't want to pay for heap allocation for a tiny array. > I don't know about "subarray". It looks like it takes and returns > arrays. It's not a type. I ordered another copy of the Nelson book so I > don't have to find mine. SUBARRAY is an expression. It accesses a subrange of the elements of an array. You can use it on the left of assignment or on the right. > > Good idea "MakeT" I forgot about that pattern. I'll try it out. > > The record and array I propose are not all that different really. > I just heard of something new. Have you heard of it? "Duck typing". If > it acts/quacks/walks like a duck, it is a duck. > This is in very dynamic languages like Ruby. > You apply object.method and if object defines something named "method", > then it "must" have "the" meaning you intend. > Kind of like how C++ templates "accept as parameters whatever happens to > work". This kind of thinking about software will work sometimes, but it's a recipe for disaster overall. It's quite too hard already to get the bugs out of software without people invoking things with only a guess what they mean. "If it looks like a duck ..." is absolutely not reliable in software. That's also the problem with over complex languages: people write massive amounts of code with only guesses about what the language constructs mean. > > Operator overloading is great for strings and "math". > > Maybe I should try to have this language debate from scratch again..? > > I still am conflcted. > > Modules seem overly heavyweight. > I don't want Module1.T, Module2.T, I want T1, T2. ; IMPORT Module1 ; IMPORT Module2 ... ; TYPE T1 = Module1 . T ; TYPE T2 = Module2 . T Now you can use T1 and T2 all over the place. Of course, if it weren't for two modules each having a different T, you could just say FROM Module1 IMPORT T, so T is available without qualification, but unlike above, is not renamed. (This is pasted in from Jay's other post on this topic) >But if I don't want to pay for heap allocation, I can't say: >VAR T: v; >v.DoSomething(); >Only IMPORT T FROM M; >VAR T: v; >M.DoSomething(v); > Right? If you don't want to have to write the module name as a qualifier, you can rename a procedure too, with a constant declaration (Procedures in Modula-3 are actually the same thing a constants of procedure type.) CONST DoSomething = M.DoSomething ... DoSomething ( v ) Having been almost forced (for other reasons I'll skip for now) in Ada to consistently use qualified references like M.DoSomething, I've come to believe that is the right way to code, even though it's more writing. It makes old code/somebody else's code _much_ easier to read. Using unqualified names is turning the priorities upside-down and saying writability trumps readability. Only if it's referred to _very_ often, do I use unqualified names (in which case, I also make them short). One limitation in Modula-3 is that you can't rename an exception or (well, not in the most general way) a variable from an imported module. I discussed this once in a list of language wants, but expressed ambivalence, particularly about variable renames. > > C++ stack structs with non virtual member functions: > class Rect_t > { > Rect_t() : top(0), left(0), right(0), bottom(0) { } > > int Height() { return bottom - top; } > int Width() { return right - left; } > int top, left, bottom, right; > }; The nonvirtual member functions greatly complicate the language, and provide nothing that plain, nonmember functions don't provide. -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From lemming at henning-thielemann.de Fri Nov 16 22:24:15 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 16 Nov 2007 22:24:15 +0100 (MET) Subject: [M3devel] small array in modula-3? In-Reply-To: <473E0ECB.504@wichita.edu> References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: On Fri, 16 Nov 2007, Rodney M. Bates wrote: > If you don't want to have to write the module name as a qualifier, you can > rename a procedure too, with a constant declaration (Procedures in Modula-3 > are actually the same thing a constants of procedure type.) > > CONST DoSomething = M.DoSomething > ... > DoSomething ( v ) It would have been nice if PROCEDURE declarations would reflect this, like in functional languages. Say CONST Sin = PROCEDURE (x: LONGREAL;): LONGREAL BEGIN ... RETURN y; END; This would also be the key for anonymous functions or loops as higher order functions. Just an idea, it's certainly simpler just to use a functional language. :-) From rodney.bates at wichita.edu Fri Nov 16 22:54:56 2007 From: rodney.bates at wichita.edu (Rodney M. Bates) Date: Fri, 16 Nov 2007 15:54:56 -0600 Subject: [M3devel] small array in modula-3? In-Reply-To: <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> References: <473CE6B6.3030402@wichita.edu> <84073BA3-0A90-4D01-845A-F504249BE027@darko.org> Message-ID: <473E11B0.3060103@wichita.edu> Darko wrote: > Is it really four words? I would have thought it might need a type > reference and a size, what are the others for? > One word for the pointer in the stack variable or wherever the real data would be, if not heap allocated. One word at negative offset in the heap object for the allocator/collector to keep track of memory. This is as low as heap manager space overhead gets, as far as I know. In any case, unless somebody figured out how to get it down to zero, there would still just about have to be a full word because of alignment. One word of "shape" for each open dimension, when the object is an open array. This example is one-dimensional, so it's one word total. One word (actually appears before the shape (which varies in size), so its location is consistent for all open array heap objects). This is a pointer to the zero-th actual array element. For a heap allocated open array, this is redundant, as it always points to the word following the shape. I presume the implementors did this because open array formal parameters need a consistent representation, regardless of whether the formal is an open array, a fixed array, or a SUBARRAY. It should be possible to implement less extravagantly, but it would complicate the compiler with more combinations of cases to handle. > > On 15/11/2007, at 4:39 PM, Rodney M. Bates wrote: > >> Jay wrote: >> >> > What is the right way to have a variably sized but always small >> array in Modula-3? >> > My array will only ever have 1 or 2 elements. >> > I'd like to always allocate room for 2 elements, and have there be >> a size. >> > >> > It seems I have a choice of >> > >> > a) an "open" array >> >> Heap allocated, I presume? If the max size is only 2 elements, >> this is pretty extravagant, as a heap allocated open array will >> have 4 extra behind-the-scenes words of space overhead, plus >> maybe heap fragmentation, and time overhead of allocation, >> collection, and maybe reduced locality of reference. >> -- ------------------------------------------------------------- Rodney M. Bates, retired assistant professor Dept. of Computer Science, Wichita State University Wichita, KS 67260-0083 316-978-3922 rodney.bates at wichita.edu From mika at async.caltech.edu Fri Nov 16 23:07:13 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Fri, 16 Nov 2007 14:07:13 -0800 Subject: [M3devel] small array in modula-3? In-Reply-To: Your message of "Fri, 16 Nov 2007 16:39:44 GMT." Message-ID: <200711162207.lAGM7D2N050225@camembert.async.caltech.edu> Naw, it's DoSomething(x); DoSomethingElse(y) It's not the same function. Not even in C++! It's just another example of overloading... Jay writes: >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/plain; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > >> VAR v : T;> DoSomething(v);> > What's the big deal if it's DoSomething(v)= > or v.DoSomething()? VAR x : T1; VAR y : T2; DoSomething(x); DoSomething(y)= >; >isn't legal, right? >=20 >So I have to: > M1.DoSomething(x); M2.DoSomething(y); >right? Constantly repeating types, or modules, on function names? >=20 > - Jay >=20 > > > >> To: jay.krell at cornell.edu> Subject: Re: [M3devel] small array in modula-3= >? > Date: Thu, 15 Nov 2007 21:00:13 -0800> From: mika at async.caltech.edu> > = >Why not > > FROM M IMPORT T, DoSomething;> > VAR v : T;> DoSomething(v);> >= > What's the big deal if it's DoSomething(v) or v.DoSomething()?> > If anyth= >ing, "DoSomething(v)" tells me that the call can be statically> resolved, w= >hereas v.DoSomething() tells me that something odd can> happen at runtime--= >-that is, I cannot be sure I understand this> code simply by looking for a = >routine called "DoSomething" and reading> that, but have to be more careful= >. This distinction is unclear in> C++. What, in fact, is the distinction in= > C++ between DoSomething(v)> and v.DoSomething()? None, right? Just two way= >s of saying the> same thing... why?> > The Modula-2+ work on the Firefly is= > also close enough to be "almost"> Modula-3...> > Regarding UNSAFE: most in= >terfaces to C code are (or should be)> UNSAFE because there are ways of cal= >ling them that can lead to> unchecked runtime errors. I don't see how you c= >an live without> UNSAFE if you ever want to link with other people's C libr= >aries...> > Mika> > Jay writes:> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_>= > >Content-Type: text/plain; charset=3D"iso-8859-1"> >Content-Transfer-Encod= >ing: quoted-printable> >> >But if I don't want to pay for heap allocation, = >I can't say:> >=3D20> >VAR T: v;> >=3D20> >v.DoSomething();> >=3D20> >Only = >IMPORT T FROM M;> >=3D20> >VAR T: v;> >=3D20> >M.DoSomething(v);> >=3D20> >= >Right?> >SPIN I think you mean.> >Anyone build it and bring it up? I was lo= >ng curious but never did..> >=3D20> > - Jay> >> >> >> >> CC: m3devel at elegos= >oft.com> From: darko at darko.org> Subject: Re: [M3devel] =3D> >small array in= > modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: jay.kr=3D> >ell at corn= >ell.edu> > Not sure what the problem is with modules. If you want t=3D> >o = >avoid the > dot you can name the type something unique then import that t= >=3D> >ype > name. You can create an interface with all the nice type names = >and > =3D> >import all those names in modules by adding an EXPORTS clause t= >oo.> > Perso=3D> >nally I think M3, with a couple of extensions, wouldn't n= >eed > unsafe anyth=3D> >ing. The unsafe features are there mostly because o= >f > legacy interfaces. I=3D> > forget the name but the folk who wrote an OS= > in > M3 found it very effecti=3D> >ve with only couple of minor points wit= >h > regards to interfacing to C code=3D> > they built on top of, I think on= >e of > them was being able to pass NIL to =3D> >a VAR parameter, which is a= > common > C idiom (and an annoying one for M3 us=3D> >ers who then can't us= >e VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:> > =3D> >> Rodney, thank= > you, this is interesting.> > I definitely don't want to pay=3D> > for heap= > allocation for a tiny array.> > I don't know about "subarray". It=3D> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered ano=3D= >> >ther copy of the Nelson book > > so I don't have to find mine.> >> > Goo= >d i=3D> >dea "MakeT" I forgot about that pattern. I'll try it out.> >> > Th= >e record =3D> >and array I propose are not all that different really.> > I = >just heard of s=3D> >omething new. Have you heard of it? "Duck typing". > >= > If it acts/quacks/wa=3D> >lks like a duck, it is a duck.> > This is in ver= >y dynamic languages like Ru=3D> >by.> > You apply object.method and if obje= >ct defines something named > > "m=3D> >ethod", then it "must" have "the" me= >aning you intend.> > Kind of like how C=3D> >++ templates "accept as parame= >ters whatever > > happens to work".> >> > Ope=3D> >rator overloading is gre= >at for strings and "math".> >> > Maybe I should try=3D> > to have this lang= >uage debate from scratch again..?> >> > I still am conflc=3D> >ted.> >> > M= >odules seem overly heavyweight.> > I don't want Module1.T, Modu=3D> >le2.T,= > I want T1, T2.> >> > C++ stack structs with non virtual member funct=3D> >= >ions:> > class Rect_t> > {> > Rect_t() : top(0), left(0), right(0), bottom(= >=3D> >0) { }> >> > int Height() { return bottom - top; }> > int Width() { r= >eturn =3D> >right - left; }> > int top, left, bottom, right;> > };> >> > se= >ems "good".>=3D> > >> > And it seems not really all that complicated for th= >e compiler to > > =3D> >flow the static type information around to resolve = >the functions..> >> > Re=3D> >ct_t r;> > r.Height() =3D3D> Rect_Height(&r);= > ..and would be inlined anyway.>=3D> > >> > I do find some compelling featu= >res in Modula-3. Mainly that it > > co=3D> >mpiles to native code and has O= >PTIONAL safety, optional garbage > > collect=3D> >ion, and that the syntax = >of modules/interfaces allows fast > > compilation =3D> >-- no longer repars= >ing the same headers over and over > > and over and over=3D> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D> > like a= > primitive integer, but raises exceptions upon overflow.> > For this=3D> > = >to work very much requires operator overloading.> >> > A point, of course,= >=3D> > is to be able to have user defined types that > > can act like the b= >uilt i=3D> >n types..> >> > - Jay> >> >> > > Date: Thu, 15 Nov 2007 18:39:1= >8 -0600> > >=3D> > From: rodney.bates at wichita.edu> > > To: m3devel at elegosof= >t.com> > > Subject=3D> >: Re: [M3devel] small array in modula-3?> > >> > > = >Jay wrote:> > >> > > > W=3D> >hat is the right way to have a variably sized= > but always small > > array in=3D> > Modula-3?> > > > My array will only ev= >er have 1 or 2 elements.> > > > I'd =3D> >like to always allocate room for = >2 elements, and have there > > be a size.>=3D> > > > >> > > > It seems I ha= >ve a choice of> > > >> > > > a) an "open" array>=3D> > > >> > > Heap alloca= >ted, I presume? If the max size is only 2 elements,> >=3D> > > this is pret= >ty extravagant, as a heap allocated open array will> > > hav=3D> >e 4 extra= > behind-the-scenes words of space overhead, plus> > > maybe heap f=3D> >rag= >mentation, and time overhead of allocation,> > > collection, and maybe r=3D= >> >educed locality of reference.> > >> > > > b) wrap it up in a record> > >= > >>=3D> > > > > I'd like so have, like:> > > >> > > > TYPE A =3D3D ARRAY [0= >..1] OF FOO=3D> >;> > > >> > > > And be able to say:> > > >> > > > VAR> > >= > > a : A;> > > >>=3D> > > > > ..> > > > a.size> > > > FOR i :=3D3D 0 TO a.s= >ize DO> > > > do somethin=3D> >g with a[i]> > > >> > > > It seems I have no= > option but, like:> > > >> > > =3D> >> TYPE A =3D3D RECORD> > > > a: ARRAY[= >0..1] OF FOO;> > > > size :=3D3D 1; (* us=3D> >ually of size 1, sometimes 2= > *)> > > > END> > > >> > > > and then> > > > FO=3D> >R i :=3D3D 0 TO a.size= > DO> > > > do something with a.a[i];> > > >> > > > That=3D> > is "ok". Not = >great -- what to call the inner a?> > > > But then furthermor=3D> >e, I'd l= >ike to construct constants.> > > > It seems I am stuck with either =3D> >th= >e verbose:> > > >> > > > PROCEDURE F(a:A);> > > >> > > > F( A { ARRAY[0..= >=3D> >1] OF FOO { .. } );> > > >> > > > OR I have to come up with a name fo= >r the =3D> >embedded array.> > > > But of course, its type is really "the s= >ame" as the =3D> >outer type.> > >> > >> > > Ignoring the fact that the typ= >es are different l=3D> >inguistically> > > (one a record type, the other an= > array), the types are d=3D> >ifferent> > > at a deep semantic level too. T= >he inner array has static> > >=3D> > size, the outer one (call it a "variab= >le array", perhaps)> > > has dynamic=3D> >ally changeable size, even more e= >asily changed> > > after it is created tha=3D> >n a heap-allocated open arr= >ay. This> > > is a significant semantic differen=3D> >ce, so it also makes = >program> > > design sense to view them as different ty=3D> >pes.> > >> > > = >>> > > > To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[0..1]=3D> > OF Foo= >;> > > >> > > > TYPE FooArray =3D3D RECORD> > > > a : FooArray;> > > >=3D> = >> size :=3D3D 1;> > > > END;> > > >> > > > F( FooArray { FooArray { .. } );= >> >=3D> > > >> > > > But I have to come up with different names.> > > >> > = >> > And I=3D> > don't think I can leave out the name for the constructor, >= > > like:> > > >=3D> >> > > > F( FooArray { { .. } );> > >> > >> > > Yes, th= >is is a limitation in=3D> > Modula-3. Ada allows value constructors> > > to= > omit inner type names in c=3D> >ases like this, and it is > > convenient. = >But> > > it also crosses a really=3D> > major line on complexity of the lan= >guage > > semantics,> > > since type an=3D> >alysis information now flows n= >ot only upward, but > > also downward> > > in=3D> > expression typing. I am= > mostly content to live with this as > > one bit of=3D> >> > > the price of= > avoiding a horribly over complex language.> > >> > > Ord=3D> >inary proced= >ures can do pretty much all of the things done by > > exotic> >=3D> > > and= > complex language stuff like C++ constructors. If you don't > > want =3D> >= >to write> > > the ponderous nested value constructor, write a constructor >= >=3D> > > procedure and> > > call it. As Antony suggested, you can make it a= >ccept =3D> >an open > > array formal,> > > which then codes just like a sim= >ple array va=3D> >lue constructor. You > > could even> > > make it elaborat= >e and general, e.g=3D> .:> > >> > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) = >: F> > >> > > =3D3D VAR L=3D> >Size : CARDINAL> > > ; VAR LResult : A> > >>= > > > ; BEGIN> > > LSize :=3D3D NU=3D> >MBER ( Val )> > > <* ASSERT LSize <= >=3D3D NUMBER ( FooArray ) *>> > > ; LResul=3D> >t . size :=3D3D LSize> > > = >; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S=3D> >UBARRAY ( Val , F= >IRST ( Val ) , LSize )> > > ; RETURN LResult> > > END Make=3D> >F> > >> > >= > Alternatively, since your maximum element count is so small, yo=3D> >u > >= > could> > > write a constructor procedure that took two formals of typ=3D> = >>e FOO, > > with> > > at least the second one optional. (This would require= > =3D> >a > > distinguished> > > value of type FOO that would be used to mea= >n "omit=3D> >ted".)> > >> > > And, of course, if you want to use abstractio= >n, you can pu=3D> >t the > > types,> > > constructor procedures, and variou= >s other procedures =3D> >for > > manipulating> > > the variable sized array= > in a module, behind an i=3D> >nterface.> > >> > > An additional limitation= > of Modula-3 in this regard, is=3D> > that you > > can't> > > make the type= > F opaque, unless you heap allocate i=3D> >t, which we > > were trying> > >= > to avoid. Ada would allow you to do this, =3D> >but it's another > > examp= >le of> > > a convenience with high cost. It force=3D> >s the equivalent of = >the > > revelation> > > to be located in the equivalent=3D> > of the interf= >ace, but makes it > > illegal> > > to write client code that =3D> >depends = >on what the revelation is.> > >> > > This in turn creates a source =3D> >co= >de control nightmare in a large > > project,> > > because now someone who= >=3D> > wants to make what is really a purely > > internal,> > > implementat= >ion ch=3D> >ange, nevertheless has to check out the > > interface, and> > >= > if you aren=3D> >'t in denial mode, that means implementers of all the > >= > client> > > code =3D> >have to go to extra trouble to somehow find out tha= >t what > > appears> > > =3D> >to be an interface change actually doesn't af= >fect them after all.> > >> > >=3D> > >> > > > Though that might seem nice.>= > > > >> > > > Am I understanding eve=3D> >rything?> > > >> > > > Have folks= > hit this before and there's a set of name=3D> >s that > > don't seem too l= >ame> > > > that folks use?> > > >> > > > Also --=3D> > language documentati= >on?> > > > Nelson's green book is excellent.> > > > Th=3D> >e stuff in the = >doc directory is very dry and scientific.> > > > The tutoria=3D> >l seems m= >ore like a reference. Or maybe I didn't > > read it enough.> > > >=3D> > Is= > there better, in case I need a refresher?> > > > I think I got it, via =3D= >> >Nelson's book from memory (wonder if I > > can find mine..) and the refe= >ren=3D> >ce,> > > > but I don't think anyone could learn from the current o= >nline > >=3D> > docs in the source tree.> > > >> > > > Maybe it's me, some = >combination of =3D> >laziness and short attention > > span> > > > as I age.= >.> > > >> > > > Btw, =3D> >C doesn't offer a great solution here, though it= > offers > > leaving out som=3D> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D> >Modula-3 seems to be missing operato= >r overloading.> > > > It's got some bui=3D> >ltin stuff, even array assignm= >ent and equality > > and I think> > > > even =3D> >record assignment and eq= >uality, but it is still a bit > > limiting.> > >> >=3D> > >> > > I have rav= >ed on this before, but, having had lots of painful > > ex=3D> >perience wit= >h> > > user-defined overloading in Ada and C++, I can say with =3D> >> > au= >thority, that it is> > > a programming language disaster. It interact=3D> >= >s with just about > > everything> > > else in the language, in very complic= >=3D> >ated ways, and all it buys > > you is saving> > > time/energy thinkin= >g up d=3D> >istinct names for procedures/functions. > > Even this,> > > asi= >de from the =3D> >effects on the language, is a net loss, by the > > time y= >ou consider> > > r=3D> >eadability along with writability.> > >> > > User-d= >efined overloaded operat=3D> >ors provide a slight readability > > benefit,= > _if_> > > used with great res=3D> >traint and discipline, something you ca= >n rely > > on not happening.> > > Me=3D> >anwhile, the language complexity = >can easily double or worse. > > And, with =3D> >the> > > exception of compi= >ler writers and language lawyers who spend > > h=3D> >undreds of hours> > >= > on just this, programmers don't understand the rules,=3D> > not even > > c= >lose.> > >> > > >> > > > Also, if I understand things correc=3D> >tly, this= > has long bothered > > me about Modula-3,> > > > though I'm more t=3D> >ole= >rant now -- Modula-3 doesn't seem to allow > > for lighter wieght> > > >=3D= >> > objects. Like, small stack allocated structs with member > > functions.= > Yo=3D> >u seem to have> > > > to chose between heap allocated garbage coll= >ected vir=3D> >tual > > member functions full> > > > featured objects, or f= >eatureless dumb=3D> > structs. It's nice how C+ > > + allow hybrids --> > >= > > objects don't have=3D> > to be heap allocated and member functions > > d= >on't have be virtual.> > > =3D> >> Or am I missing something?> > >> > >> > = >> C++'s supposedly lighter weight=3D> > forms of classes/structs with > > t= >heir special> > > member functions buy =3D> >nothing that plain records, pl= >ain > > procedures, and> > > interfaces/modul=3D> >es don't already provide= >, again, at significant > > and gratuitous> > > lan=3D> >guage complexity. = >Except when methods/member functions > > actually dispatc=3D> >h> > > dynam= >ically, there is nothing that the above won't do, and when > > =3D> >you cr= >eate a> > > class instance as a local variable (i.e., on the stack), =3D> >= >it is > > necessarily> > > not polymorphic, that is, it can't change its "a= >=3D> >llocated" or > > dynamic type> > > among various subtypes at runtime.= > This =3D> >in turn means it can't > > dispatch.> > >> > > So, just use pla= >in procedure=3D> >s, an interface and a module, and you > > will get> > > e= >verything a lighte=3D> >r-weight C++ class would give you.> > >> > >> > > >= >> > > > Anyway, I've got=3D> >ten to accept C a bit more vs. C++ so I can >= > > deal with> > > > t: Type;> =3D> >> > > Type_DoSomething(t);> > > >> > > = >> in place of:> > > > t.DoSomething(=3D> >);> > >> > >> > > Exactly. The sp= >ecial "receiver object" in a true method c=3D> >all has > > significant> > = >> semantic differences from an ordinary paramete=3D> >r and introduces > > = >new complexities> > > and non-orthogonalities. It has =3D> >some very valua= >ble uses too.> > >> > > But to then create degenerate forms =3D> >of it tha= >t still carry a lot > > of these> > > complexities, but are equiva=3D> >len= >t in programing power to plain old> > > parameters is just bad program d=3D= >> >esign and bad language design. > > Objects and> > > methods are indeed c= >ool=3D> > for situations that utilize their > > semantic complexity.> > > B= >ut it's d=3D> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D> >tely sophisticated construct when the problem doesn't = >> > justify it.> > > =3D> >Some OO proponents have gone way over the deep e= >nd here.> > >> > > >> > > >=3D> > - Jay> > > >> > > >> > > > > > ----------= >---------------------------------=3D> >--------------------------- > > --> = >> > > Boo! Scare away worms, viruses an=3D> >d so much more! Try Windows > = >> Live OneCare! Try now!> > > >.live.com/standard/en-us= >/purchase/trial.aspx? > > s_cid=3D3Dwl_hotmailnews>> =3D> >> >> > >> > > --= >> > > -----------------------------------------------------=3D> >--------> = >> > Rodney M. Bates, retired assistant professor> > > Dept. of Co=3D> >mput= >er Science, Wichita State University> > > Wichita, KS 67260-0083> > > 3=3D>= > >16-978-3922> > > rodney.bates at wichita.edu> > >> > > --> > > -------------= >--=3D> >----------------------------------------------> > > Rodney M. Bates= >, retire=3D> >d assistant professor> > > Dept. of Computer Science, Wichita= > State Univers=3D> >ity> > > Wichita, KS 67260-0083> > > 316-978-3922> > > = >rodney.bates at wichita=3D> >.edu> >> >> > Boo! Scare away worms, viruses and = >so much more! Try Windows =3D> >Live > > OneCare! Try now!>=3D20> >________= >_________________________________________________________> >Climb to the to= >p of the charts!=3DA0 Play Star Shuffle:=3DA0 the word scramble =3D> >chall= >enge with star power.> >http://club.live.com/star_shuffle.aspx?icid=3D3Dsta= >rshuffle_wlmailtextlink_oc=3D> >t=3D> >> >--_0109391c-2ffe-4cfe-9165-c2a246= >28c3c7_> >Content-Type: text/html; charset=3D"iso-8859-1"> >Content-Transfe= >r-Encoding: quoted-printable> >> >> >> >> >> >'>But if I don't want to pay for heap allocation, I=3D> > can't say:
> >= > 
> >VAR T: v;
> > 
> >v.DoSomething();
> > 
= >> >Only IMPORT T FROM M;
> > 
> >VAR T: v;
> > 
> >M.= >DoSomething(v);
> > 
> >Right?

> >SPIN I think you mean.<= >BR>> >Anyone build it and bring it up? I was long curious but never did..R>> > 
> > - Jay


> >> >
> ><= >BR>> >> CC: m3devel at elegosoft.com
> From: darko at darko.org
> = >Subjec=3D> >t: Re: [M3devel] small array in modula-3?
> Date: Thu, 15= > Nov 2007 20=3D> >:29:06 -0800
> To: jay.krell at cornell.edu
> R>> Not sure wh=3D> >at the problem is with modules. If you want to avoi= >d the
> dot you c=3D> >an name the type something unique then import= > that type
> name. You =3D> >can create an interface with all the ni= >ce type names and
> import al=3D> >l those names in modules by addin= >g an EXPORTS clause too.
>
> =3D> >Personally I think M3, with= > a couple of extensions, wouldn't need
> =3D> >unsafe anything. The = >unsafe features are there mostly because of
> l=3D> >egacy interface= >s. I forget the name but the folk who wrote an OS in
>=3D> >; M3 foun= >d it very effective with only couple of minor points with
>=3D> > re= >gards to interfacing to C code they built on top of, I think one of
=3D= >> >> them was being able to pass NIL to a VAR parameter, which is a comm= >on =3D> >
> C idiom (and an annoying one for M3 users who then can't = >use VAR).=3D> >
>
>
> On 15/11/2007, at 8:08 PM, Jay wr= >ote:
> >R>> > Rodney, thank you, this is interesting.>> > I definite=3D> >ly don't want to pay for heap allocation for a t= >iny array.
> > I d=3D> >on't know about "subarray". It looks like = >it takes and returns
> >=3D> >; arrays. It's not a type. I ordered= > another copy of the Nelson book
&g=3D> >t; > so I don't have to fin= >d mine.
> >
> > Good idea "=3D> >MakeT" I forgot about th= >at pattern. I'll try it out.
> >
> &=3D> >gt; The record and= > array I propose are not all that different really.
&g=3D> >t; > I ju= >st heard of something new. Have you heard of it? "Duck typing".=3D> >
&= >gt; > If it acts/quacks/walks like a duck, it is a duck.
> &=3D> >= >gt; This is in very dynamic languages like Ruby.
> > You apply obj= >=3D> >ect.method and if object defines something named
> > "metho= >d", th=3D> >en it "must" have "the" meaning you intend.
> > Kind o= >f like how C=3D> >++ templates "accept as parameters whatever
> >= > happens to work".=3D> >
> >
> > Operator overloading is = >great for strings and "m=3D> >ath".
> >
> > Maybe I shoul= >d try to have this language de=3D> >bate from scratch again..?
> >= >
> > I still am conflcted.<=3D> >BR>> >
> > Modules= > seem overly heavyweight.
> > I d=3D> >on't want Module1.T, Module= >2.T, I want T1, T2.
> >
> > C+=3D> >+ stack structs with = >non virtual member functions:
> > class Rect_=3D> >t
> > = >{
> > Rect_t() : top(0), left(0), right(0), bottom(=3D> >0) { }>> >
> > int Height() { return bottom - top; }
&=3D> >gt;= > > int Width() { return right - left; }
> > int top, left, b=3D= >> >ottom, right;
> > };
> >
> > seems "good".>&g=3D> >t; >
> > And it seems not really all that complicated = >for the c=3D> >ompiler to
> > flow the static type information ar= >ound to resolve=3D> > the functions..
> >
> > Rect_t r;R>> > r.Height(=3D> >) =3D3D> Rect_Height(&r); ..and would be = >inlined anyway.
> ><=3D> >BR>> > I do find some compelling f= >eatures in Modula-3. Mainly that it=3D> >
> > compiles to native = >code and has OPTIONAL safety, optional ga=3D> >rbage
> > collecti= >on, and that the syntax of modules/interfaces a=3D> >llows fast
> &g= >t; compilation -- no longer reparsing the same header=3D> >s over and over = >
> > and over and over.
> >
> > =3D> >Operator o= >verloading btw..have seen "template SafeInt"? It acts
> &g=3D> >t; l= >ike a primitive integer, but raises exceptions upon overflow.
> &=3D>= > >gt; For this to work very much requires operator overloading.
> >= >;<=3D> >BR>> > A point, of course, is to be able to have user defined= > types t=3D> >hat
> > can act like the built in types..
> &= >gt;
> &g=3D> >t; - Jay
> >
> >
> > > Da= >te: Thu, 15 Nov 2007=3D> > 18:39:18 -0600
> > > From: rodney.ba= >tes at wichita.edu
> &g=3D> >t; > To: m3devel at elegosoft.com
> &= >gt; > Subject: Re: [M3devel] =3D> >small array in modula-3?
> >= > >
> > > Jay wrote:
=3D> >> > >
> > >= >; > What is the right way to have a varia=3D> >bly sized but always smal= >l
> > array in Modula-3?
> > &g=3D> >t; > My array wi= >ll only ever have 1 or 2 elements.
> > > >=3D> >; I'd like to= > always allocate room for 2 elements, and have there
> =3D> >> be= > a size.
> > > >
> > > > It seems I ha=3D> >v= >e a choice of
> > > >
> > > > a) an "open" a= >=3D> >rray
> > >
> > > Heap allocated, I presume? I= >f the =3D> >max size is only 2 elements,
> > > this is pretty e= >xtravagant, =3D> >as a heap allocated open array will
> > > hav= >e 4 extra behind-t=3D> >he-scenes words of space overhead, plus
> >= >; > maybe heap fragme=3D> >ntation, and time overhead of allocation,
= >> > > collection, and=3D> > maybe reduced locality of reference.R>> > >
> > > &=3D> >gt; b) wrap it up in a record
= >> > > >
> > > >=3D> > I'd like so have, like:>> > > >
> > > > TYPE=3D> > A =3D3D ARRAY [0..1]= > OF FOO;
> > > >
> > > > A=3D> >nd be able to= > say:
> > > >
> > > > VAR
>=3D> >; > = >> > a : A;
> > > >
> > > > .. >>= >> > > > a.size
> > > > FOR i :=3D3D 0 TO a.size = >D=3D> >O
> > > > do something with a[i]
> > > &g= >t;
&=3D> >gt; > > > It seems I have no option but, like:
>= >; > > &=3D> >gt;
> > > > TYPE A =3D3D RECORD
> &= >gt; > > a: ARRA=3D> >Y[0..1] OF FOO;
> > > > size :=3D= >3D 1; (* usually of size 1, s=3D> >ometimes 2 *)
> > > > END= >
> > > >
> >=3D> >; > > and then
> > = >> > FOR i :=3D3D 0 TO a.size DO
&g=3D> >t; > > > do somet= >hing with a.a[i];
> > > >
> =3D> >> > > That = >is "ok". Not great -- what to call the inner a?
>=3D> > > > >= >; But then furthermore, I'd like to construct constants.
&=3D> >gt; >= > > > It seems I am stuck with either the verbose:
> >=3D> >; = >> >
> > > > PROCEDURE F(a:A);
> > > >= >=3D> >
> > > > F( A { ARRAY[0..1] OF FOO { .. } );
> &= >gt; &g=3D> >t; >
> > > > OR I have to come up with a name= > for the emb=3D> >edded array.
> > > > But of course, its ty= >pe is really "the =3D> >same" as the outer type.
> > >
> = >> >
> > &=3D> >gt; Ignoring the fact that the types are diff= >erent linguistically
> &=3D> >gt; > (one a record type, the other = >an array), the types are different >R>> > > at a deep semant= >ic level too. The inner array has static >R>> > > size, the = >outer one (call it a "variable array", perhaps)<=3D> >BR>> > > has= > dynamically changeable size, even more easily changed=3D> >
> > &= >gt; after it is created than a heap-allocated open array. Th=3D> >is
>= >; > > is a significant semantic difference, so it also makes=3D> > pr= >ogram
> > > design sense to view them as different types.> >>> > >
> > > >
> > > > To wit:>&g=3D> >t; > > >
> > > > TYPE FooArray =3D3D ARRAY= >[0..1] OF F=3D> >oo;
> > > >
> > > > TYPE Foo= >Array =3D3D RECORD<=3D> >BR>> > > > a : FooArray;
> > = >> > size :=3D3D 1; >>> > > > END;
> > >= >; >
> > > > F( =3D> >FooArray { FooArray { .. } );
>= >; > > >
> > > >=3D> > But I have to come up with di= >fferent names.
> > > >
>=3D> > > > > And I do= >n't think I can leave out the name for the construc=3D> >tor,
> >= > like:
> > > >
> > > > F( F=3D> >ooArray { { = >.. } );
> > >
> > >
> > > Y=3D> >es, th= >is is a limitation in Modula-3. Ada allows value constructors
>=3D> >= > > > to omit inner type names in cases like this, and it is
> = >=3D> >> convenient. But
> > > it also crosses a really major= > line =3D> >on complexity of the language
> > semantics,
> = >> > si=3D> >nce type analysis information now flows not only upward, = >but
> > =3D> >also downward
> > > in expression typin= >g. I am mostly content t=3D> >o live with this as
> > one bit of<= >BR>> > > the price of=3D> > avoiding a horribly over complex langu= >age.
> > >
> > =3D> >> Ordinary procedures can do p= >retty much all of the things done by
&=3D> >gt; > exotic
> >= >; > and complex language stuff like C++ const=3D> >ructors. If you don't= >
> > want to write
> > > the pon=3D> >derous nested v= >alue constructor, write a constructor
> > procedur=3D> >e and
= >> > > call it. As Antony suggested, you can make it accep=3D> >t a= >n open
> > array formal,
> > > which then codes ju=3D= >> >st like a simple array value constructor. You
> > could evenR>&=3D> >gt; > > make it elaborate and general, e.g.:
> > &g= >t;
>=3D> >; > > PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F
&g= >t; > > >>> > > =3D3D VAR LSize : CARDINAL
> >= >; > ; VAR LResult : =3D> >A
> > >
> > > ; BEGIN<= >BR>> > > LSize :=3D3D =3D> >NUMBER ( Val )
> > > <*= > ASSERT LSize <=3D3D NUMBER ( FooArr=3D> >ay ) *>
> > > ;= > LResult . size :=3D3D LSize
> > > =3D> >; SUBARRAY ( LResult .= > a , 0 , LSize )
> > > :=3D3D SUBARRAY ( Va=3D> >l , FIRST ( Va= >l ) , LSize )
> > > ; RETURN LResult
> >=3D> > > EN= >D MakeF
> > >
> > > Alternatively, since yo=3D> >ur= > maximum element count is so small, you
> > could
> > = >=3D> >> write a constructor procedure that took two formals of type FOO,= >
&=3D> >gt; > with
> > > at least the second one optiona= >l. (This wou=3D> >ld require a
> > distinguished
> > >= >; value of type FO=3D> >O that would be used to mean "omitted".)
> &g= >t; >
> > >=3D> >; And, of course, if you want to use abstract= >ion, you can put the
> =3D> >> types,
> > > construct= >or procedures, and various other pro=3D> >cedures for
> > manipul= >ating
> > > the variable sized=3D> > array in a module, behind = >an interface.
> > >
> > >=3D> >; An additional limit= >ation of Modula-3 in this regard, is that you
>=3D> > > can't
= >> > > make the type F opaque, unless you heap alloc=3D> >ate it, w= >hich we
> > were trying
> > > to avoid. Ada =3D> >wou= >ld allow you to do this, but it's another
> > example of
&g=3D= >> >t; > > a convenience with high cost. It forces the equivalent of t= >he =3D> >
> > revelation
> > > to be located in the eq= >uivalent =3D> >of the interface, but makes it
> > illegal
>= > > > to w=3D> >rite client code that depends on what the revelation i= >s.
> > ><=3D> >BR>> > > This in turn creates a source = >code control nightmare in a=3D> > large
> > project,
> >= > > because now someone who wan=3D> >ts to make what is really a purely <= >BR>> > internal,
> > >=3D> >; implementation change, never= >theless has to check out the
> > in=3D> >terface, and
> >= >; > if you aren't in denial mode, that means imp=3D> >lementers of all t= >he
> > client
> > > code have to go=3D> > to extra tr= >ouble to somehow find out that what
> > appears
&g=3D> >t; >= >; > to be an interface change actually doesn't affect them after a=3D> >= >ll.
> > >
> > > >
> > > > Though = >=3D> >that might seem nice.
> > > >
> > > > A= >m I un=3D> >derstanding everything?
> > > >
> > >= >; > Have =3D> >folks hit this before and there's a set of names that >> > don't s=3D> >eem too lame
> > > > that folks use?= >
> > > ><=3D> >BR>> > > > Also -- language docum= >entation?
> > > &g=3D> >t; Nelson's green book is excellent.>> > > > The stuff in th=3D> >e doc directory is very dry and s= >cientific.
> > > > The tuto=3D> >rial seems more like a refe= >rence. Or maybe I didn't
> > read it e=3D> >nough.
> > &= >gt; > Is there better, in case I need a refresher?<=3D> >BR>> > &g= >t; > I think I got it, via Nelson's book from memory (won=3D> >der if I = >
> > can find mine..) and the reference,
> > >=3D> >; &= >gt; but I don't think anyone could learn from the current online
>=3D= >> >; > docs in the source tree.
> > > >
> > >= > &g=3D> >t; Maybe it's me, some combination of laziness and short attention= >
>=3D> > > span
> > > > as I age..
> > &g= >t; >
>=3D> > > > > Btw, C doesn't offer a great solution = >here, though it offer=3D> >s
> > leaving out some type names.
= >> > > > In C++ =3D> >I could have both .size and operator[].>> > > > Modula-3 see=3D> >ms to be missing operator overloadin= >g.
> > > > It's got some=3D> > builtin stuff, even array ass= >ignment and equality
> > and I thin=3D> >k
> > > >= > even record assignment and equality, but it is sti=3D> >ll a bit
> = >> limiting.
> > >
> > >
>=3D> >; > > = >I have raved on this before, but, having had lots of painful >R>>= > > experience with
> > > user-defined overloading in A=3D> >= >da and C++, I can say with
> > authority, that it is
> >= >=3D> > > a programming language disaster. It interacts with just about <= >BR>>=3D> >; > everything
> > > else in the language, in ve= >ry complicat=3D> >ed ways, and all it buys
> > you is saving
&= >gt; > > time=3D> >/energy thinking up distinct names for procedures/f= >unctions.
> > =3D> >Even this,
> > > aside from the e= >ffects on the language, is a n=3D> >et loss, by the
> > time you = >consider
> > > readabili=3D> >ty along with writability.
>= >; > >
> > > User-defined=3D> > overloaded operators provi= >de a slight readability
> > benefit, _=3D> >if_
> > >= > used with great restraint and discipline, something y=3D> >ou can rely >> > on not happening.
> > > Meanwhile, th=3D> >e languag= >e complexity can easily double or worse.
> > And, with t=3D> >he<= >BR>> > > exception of compiler writers and language lawyers who=3D= >> > spend
> > hundreds of hours
> > > on just this, p= >rog=3D> >rammers don't understand the rules, not even
> > close.<= >BR>> &=3D> >gt; >
> > > >
> > > > Also,= > if I understan=3D> >d things correctly, this has long bothered
> &g= >t; me about Modula-3,=3D> >
> > > > though I'm more tolerant= > now -- Modula-3 doesn't se=3D> >em to allow
> > for lighter wieg= >ht
> > > > objects=3D> >. Like, small stack allocated struct= >s with member
> > functions. =3D> >You seem to have
> > = >> > to chose between heap allocated gar=3D> >bage collected virtual <= >BR>> > member functions full
> > >=3D> >; > featured ob= >jects, or featureless dumb structs. It's nice how C+
=3D> >> > + = >allow hybrids --
> > > > objects don't have to b=3D> >e heap= > allocated and member functions
> > don't have be virtual.<=3D> >= >BR>> > > > Or am I missing something?
> > >
>= >=3D> > > >
> > > C++'s supposedly lighter weight forms of= > class=3D> >es/structs with
> > their special
> > > m= >ember functi=3D> >ons buy nothing that plain records, plain
> > p= >rocedures, and
=3D> >> > > interfaces/modules don't already pro= >vide, again, at signific=3D> >ant
> > and gratuitous
> >= > > language complexity. Exc=3D> >ept when methods/member functions
&= >gt; > actually dispatch
> &=3D> >gt; > dynamically, there is no= >thing that the above won't do, and when >R>> > you create a>> > > class instance as a local variab=3D> >le (i.e., on the stac= >k), it is
> > necessarily
> > > =3D> >not polymorphic= >, that is, it can't change its "allocated" or
> > =3D> >dynamic t= >ype
> > > among various subtypes at runtime. This in t=3D> >urn= > means it can't
> > dispatch.
> > >
> > &=3D= >> >gt; So, just use plain procedures, an interface and a module, and you R>&=3D> >gt; > will get
> > > everything a lighter-weight C+= >+ class w=3D> >ould give you.
> > >
> > >
> &= >gt; > > >R>> > > > Anyway, I've gotten to accept C = >a bit more vs. C++ so=3D> > I can
> > deal with
> > >= > > t: Type;
> >=3D> > > > Type_DoSomething(t);
> &g= >t; > >
> > > &g=3D> >t; in place of:
> > > &g= >t; t.DoSomething();
> > > >R>> > >
> > = >> Exactly. The special "receiver object" i=3D> >n a true method call has= >
> > significant
> > > semant=3D> >ic differences fro= >m an ordinary parameter and introduces
> > new =3D> >complexities= >
> > > and non-orthogonalities. It has some very va=3D> >luable= > uses too.
> > >
> > > But to then create deg=3D> >= >enerate forms of it that still carry a lot
> > of these
> &= >=3D> >gt; > complexities, but are equivalent in programing power to plai= >n old<=3D> >BR>> > > parameters is just bad program design and bad= > language de=3D> sign.
> > Objects and
> > > methods = >are indeed cool f=3D> >or situations that utilize their
> > seman= >tic complexity.
>=3D> > > > But it's deeply uncool to try to lo= >ok superficially cool by usin=3D> >g an
> > > inappropriately s= >ophisticated construct when the pro=3D> >blem doesn't
> > justify= > it.
> > > Some OO proponents=3D> > have gone way over the deep= > end here.
> > >
> > > =3D> >>
> > >= > > - Jay
> > > >
> > > =3D> >>
> >= >; > >
> > ---------------------------------=3D> >----------= >---------------------------
> > --
> > > &g=3D> >t; B= >oo! Scare away worms, viruses and so much more! Try Windows
> &g=3D>= > >t; Live OneCare! Try now!
> > > <http://onecare.live.com/s= >ta=3D> >ndard/en-us/purchase/trial.aspx?
> > s_cid=3D3Dwl_hotmail= >news> >R>> > >
> > >
> > > --
= >> > > -=3D> >-----------------------------------------------------= >-------
> > &=3D> >gt; Rodney M. Bates, retired assistant professo= >r
> > > Dept. of=3D> > Computer Science, Wichita State Universi= >ty
> > > Wichita, KS 6=3D> >7260-0083
> > > 316-978= >-3922
> > > rodney.bates at wic=3D> >hita.edu
> > >>> > > --
> > > ---------=3D> >-----------------------= >-----------------------------
> > > Rodn=3D> >ey M. Bates, reti= >red assistant professor
> > > Dept. of Compute=3D> >r Science, = >Wichita State University
> > > Wichita, KS 67260-008=3D> >3
= >> > > 316-978-3922
> > > rodney.bates at wichita.edu=3D> = >>
> >
> >
> > Boo! Scare away worms, viruses and= =3D> >so much more! Try Windows Live
> > OneCare! Try now!
&g= >t;
=3D> >


Climb to the top of the charts!=3DA0 Play Star= > Shuffle:=3DA0 th=3D> >e word scramble challenge with star power. =3D3D'http://club.live.com/=3D> >star_shuffle.aspx?icid=3D3Dstarshuffle_wlm= >ailtextlink_oct' target=3D3D'_new'>Pl=3D> >ay Now!> >=3D>= > >> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_-- >_________________________________________________________________ >Help yourself to FREE treats served up daily at the Messenger Caf=E9. Stop = >by today. >http://www.cafemessenger.com/info/info_sweetstuff2.html?ocid=3DTXT_TAGLM_Oc= >tWLtagline= > >--_85b6c041-9539-4614-b541-8813489e58bb_ >Content-Type: text/html; charset="iso-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > > >> VAR v : T;
> DoSomething(v);
> <= >BR>> What's the big deal if it's DoSomething(v) or v.NT face=3D"">DoSomething()?

 VAR x : T1;
= > VAR y : T2;
 DoSomething(x);
 DoSomething(y);>
>isn't legal, right?

>So I have to:
>
 M1.DoSomething(x);
 M2.DoSomething(y);

>right? Constantly repeating types, or modules, on function names?

> - Jay

> >
>
>> To: jay.krell at cornell.edu
> Subject: Re: [M3devel] small array i= >n modula-3?
> Date: Thu, 15 Nov 2007 21:00:13 -0800
> From: mi= >ka at async.caltech.edu
>
> Why not
>
> FROM M IMPO= >RT T, DoSomething;
>
> VAR v : T;
> DoSomething(v);
&= >gt;
> What's the big deal if it's DoSomething(v) or = >v.DoSomething()?
>
> If anything= >, "DoSomething(v)" tells me that the call can be statically
> resolve= >d, whereas v.DoSomething() te= >lls me that something odd can
> happen at runtime---that is, I cannot= > be sure I understand this
> code simply by looking for a routine cal= >led "DoSomething" and reading
> that, but have to be more careful. Th= >is distinction is unclear in
> C++. What, in fact, is the distinction= > in C++ between DoSomething(v)
> and v.">DoSomething()? None, right? Just two ways of saying the
= >> same thing... why?
>
> The Modula-2+ work on the Firefly = >is also close enough to be "almost"
> Modula-3...
>
> Re= >garding UNSAFE: most interfaces to C code are (or should be)
> UNSAFE= > because there are ways of calling them that can lead to
> unchecked = >runtime errors. I don't see how you can live without
> UNSAFE if you = >ever want to link with other people's C libraries...
>
> Mika<= >BR>>
> Jay writes:
> >--_0109391c-2ffe-4cfe-9165-c2a2462= >8c3c7_
> >Content-Type: text/plain; charset=3D"iso-8859-1"
>= > >Content-Transfer-Encoding: quoted-printable
> >
> >B= >ut if I don't want to pay for heap allocation, I can't say:
> >=3D= >20
> >VAR T: v;
> >=3D20
> >v.ONT face=3D"">DoSomething();
> >=3D20
> >On= >ly IMPORT T FROM M;
> >=3D20
> >VAR T: v;
> >=3D= >20
> >M.DoSomething(v);
> >=3D20
> >Right?
&g= >t; >SPIN I think you mean.
> >Anyone build it and bring it up? = >I was long curious but never did..
> >=3D20
> > - Jay
= >> >
> >
> >
> >> CC: m3devel at elegosoft.= >com> From: darko at darko.org> Subject: Re: [M3devel] =3D
> >sm= >all array in modula-3?> Date: Thu, 15 Nov 2007 20:29:06 -0800> To: ja= >y.kr=3D
> >ell at cornell.edu> > Not sure what the problem is w= >ith modules. If you want t=3D
> >o avoid the > dot you can name= > the type something unique then import that t=3D
> >ype > name.= > You can create an interface with all the nice type names and > =3D
&= >gt; >import all those names in modules by adding an EXPORTS clause too.&= >gt; > Perso=3D
> >nally I think M3, with a couple of extensions= >, wouldn't need > unsafe anyth=3D
> >ing. The unsafe features a= >re there mostly because of > legacy interfaces. I=3D
> > forget= > the name but the folk who wrote an OS in > M3 found it very effecti=3D<= >BR>> >ve with only couple of minor points with > regards to interf= >acing to C code=3D
> > they built on top of, I think one of > t= >hem was being able to pass NIL to =3D
> >a VAR parameter, which is= > a common > C idiom (and an annoying one for M3 us=3D
> >ers wh= >o then can't use VAR).> > > On 15/11/2007, at 8:08 PM, Jay wrote:&= >gt; > =3D
> >> Rodney, thank you, this is interesting.> &= >gt; I definitely don't want to pay=3D
> > for heap allocation for = >a tiny array.> > I don't know about "subarray". It=3D
> > lo= >oks like it takes and returns > > arrays. It's not a type. I ordered = >ano=3D
> >ther copy of the Nelson book > > so I don't have t= >o find mine.> >> > Good i=3D
> >dea "MakeT" I forgot a= >bout that pattern. I'll try it out.> >> > The record =3D
>= >; >and array I propose are not all that different really.> > I jus= >t heard of s=3D
> >omething new. Have you heard of it? "Duck typin= >g". > > If it acts/quacks/wa=3D
> >lks like a duck, it is a = >duck.> > This is in very dynamic languages like Ru=3D
> >by.= >> > You apply object.method and if object defines something named >= >; > "m=3D
> >ethod", then it "must" have "the" meaning you inte= >nd.> > Kind of like how C=3D
> >++ templates "accept as para= >meters whatever > > happens to work".> >> > Ope=3D
>= >; >rator overloading is great for strings and "math".> >> > = >Maybe I should try=3D
> > to have this language debate from scratc= >h again..?> >> > I still am conflc=3D
> >ted.> >= >> > Modules seem overly heavyweight.> > I don't want Module1.T,= > Modu=3D
> >le2.T, I want T1, T2.> >> > C++ stack stru= >cts with non virtual member funct=3D
> >ions:> > class Rect_= >t> > {> > Rect_t() : top(0), left(0), right(0), bottom(=3D
&= >gt; >0) { }> >> > int Height() { return bottom - top; }> = >> int Width() { return =3D
> >right - left; }> > int top,= > left, bottom, right;> > };> >> > seems "good".>=3D>> > >> > And it seems not really all that complicated for t= >he compiler to > > =3D
> >flow the static type information a= >round to resolve the functions..> >> > Re=3D
> >ct_t r= >;> > r.Height() =3D3D> Rect_Height(&r); ..and would be inlined= > anyway.>=3D
> > >> > I do find some compelling featur= >es in Modula-3. Mainly that it > > co=3D
> >mpiles to native= > code and has OPTIONAL safety, optional garbage > > collect=3D
>= >; >ion, and that the syntax of modules/interfaces allows fast > > = >compilation =3D
> >-- no longer reparsing the same headers over an= >d over > > and over and over=3D
> >.> >> > Opera= >tor overloading btw..have seen "template SafeInt"? It acts > >=3D
= >> > like a primitive integer, but raises exceptions upon overflow.>= >; > For this=3D
> > to work very much requires operator overloa= >ding.> >> > A point, of course,=3D
> > is to be able t= >o have user defined types that > > can act like the built i=3D
>= >; >n types..> >> > - Jay> >> >> > > Dat= >e: Thu, 15 Nov 2007 18:39:18 -0600> > >=3D
> > From: rodn= >ey.bates at wichita.edu> > > To: m3devel at elegosoft.com> > > = >Subject=3D
> >: Re: [M3devel] small array in modula-3?> > &g= >t;> > > Jay wrote:> > >> > > > W=3D
> &= >gt;hat is the right way to have a variably sized but always small > >= > array in=3D
> > Modula-3?> > > > My array will only e= >ver have 1 or 2 elements.> > > > I'd =3D
> >like to al= >ways allocate room for 2 elements, and have there > > be a size.>= >=3D
> > > > >> > > > It seems I have a choice= > of> > > >> > > > a) an "open" array>=3D
>= > > > >> > > Heap allocated, I presume? If the max size is= > only 2 elements,> >=3D
> > > this is pretty extravagant,= > as a heap allocated open array will> > > hav=3D
> >e 4 e= >xtra behind-the-scenes words of space overhead, plus> > > maybe he= >ap f=3D
> >ragmentation, and time overhead of allocation,> >= > > collection, and maybe r=3D
> >educed locality of reference.&= >gt; > >> > > > b) wrap it up in a record> > > &g= >t;>=3D
> > > > > I'd like so have, like:> > >= > >> > > > TYPE A =3D3D ARRAY [0..1] OF FOO=3D
> >;&= >gt; > > >> > > > And be able to say:> > > >= >;> > > > VAR> > > > a : A;> > > >>= >=3D
> > > > > ..> > > > a.size> > > = >> FOR i :=3D3D 0 TO a.size DO> > > > do somethin=3D
> = >>g with a[i]> > > >> > > > It seems I have no op= >tion but, like:> > > >> > > =3D
> >> TYPE = >A =3D3D RECORD> > > > a: ARRAY[0..1] OF FOO;> > > >= > size :=3D3D 1; (* us=3D
> >ually of size 1, sometimes 2 *)> &g= >t; > > END> > > >> > > > and then> > &g= >t; > FO=3D
> >R i :=3D3D 0 TO a.size DO> > > > do s= >omething with a.a[i];> > > >> > > > That=3D
>= > > is "ok". Not great -- what to call the inner a?> > > > Bu= >t then furthermor=3D
> >e, I'd like to construct constants.> &g= >t; > > It seems I am stuck with either =3D
> >the verbose:&g= >t; > > >> > > > PROCEDURE F(a:A);> > > >&g= >t; > > > F( A { ARRAY[0..=3D
> >1] OF FOO { .. } );> &= >gt; > >> > > > OR I have to come up with a name for the = >=3D
> >embedded array.> > > > But of course, its type = >is really "the same" as the =3D
> >outer type.> > >> &= >gt; >> > > Ignoring the fact that the types are different l=3D<= >BR>> >inguistically> > > (one a record type, the other an ar= >ray), the types are d=3D
> >ifferent> > > at a deep seman= >tic level too. The inner array has static> > >=3D
> > siz= >e, the outer one (call it a "variable array", perhaps)> > > has dy= >namic=3D
> >ally changeable size, even more easily changed> >= >; > after it is created tha=3D
> >n a heap-allocated open array= >. This> > > is a significant semantic differen=3D
> >ce, = >so it also makes program> > > design sense to view them as differe= >nt ty=3D
> >pes.> > >> > > >> > > &g= >t; To wit:> > > >> > > > TYPE FooArray =3D3D ARRAY[= >0..1]=3D
> > OF Foo;> > > >> > > > TYPE Fo= >oArray =3D3D RECORD> > > > a : FooArray;> > > >=3D<= >BR>> > size :=3D3D 1;> > > > END;> > > >> = >> > > F( FooArray { FooArray { .. } );> >=3D
> > &g= >t; >> > > > But I have to come up with different names.> = >> > >> > > > And I=3D
> > don't think I can l= >eave out the name for the constructor, > > like:> > > >= >=3D
> >> > > > F( FooArray { { .. } );> > >&g= >t; > >> > > Yes, this is a limitation in=3D
> > Mod= >ula-3. Ada allows value constructors> > > to omit inner type names= > in c=3D
> >ases like this, and it is > > convenient. But>= >; > > it also crosses a really=3D
> > major line on complexi= >ty of the language > > semantics,> > > since type an=3D
&= >gt; >alysis information now flows not only upward, but > > also do= >wnward> > > in=3D
> > expression typing. I am mostly cont= >ent to live with this as > > one bit of=3D
> >> > >= > the price of avoiding a horribly over complex language.> > >> = >> > Ord=3D
> >inary procedures can do pretty much all of the= > things done by > > exotic> >=3D
> > > and complex = >language stuff like C++ constructors. If you don't > > want =3D
&g= >t; >to write> > > the ponderous nested value constructor, write= > a constructor >=3D
> > > procedure and> > > call i= >t. As Antony suggested, you can make it accept =3D
> >an open >= > array formal,> > > which then codes just like a simple array= > va=3D
> >lue constructor. You > > could even> > > = >make it elaborate and general, e.g=3D
> .:> > >> > >= >; PROCEDURE MakeF ( Val : ARRAY OF FOO ) : F> > >> > > = >=3D3D VAR L=3D
> >Size : CARDINAL> > > ; VAR LResult : A&= >gt; > >> > > ; BEGIN> > > LSize :=3D3D NU=3D
>= >; >MBER ( Val )> > > <* ASSERT LSize <=3D3D NUMBER ( FooA= >rray ) *>> > > ; LResul=3D
> >t . size :=3D3D LSize>= >; > > ; SUBARRAY ( LResult . a , 0 , LSize )> > > :=3D3D S= >=3D
> >UBARRAY ( Val , FIRST ( Val ) , LSize )> > > ; RET= >URN LResult> > > END Make=3D
> >F> > >> > = >> Alternatively, since your maximum element count is so small, yo=3D
= >> >u > > could> > > write a constructor procedure that= > took two formals of typ=3D
> >e FOO, > > with> > >= > at least the second one optional. (This would require =3D
> >a &g= >t; > distinguished> > > value of type FOO that would be used to= > mean "omit=3D
> >ted".)> > >> > > And, of cours= >e, if you want to use abstraction, you can pu=3D
> >t the > >= >; types,> > > constructor procedures, and various other procedures= > =3D
> >for > > manipulating> > > the variable size= d array in a module, behind an i=3D
> >nterface.> > >>= > > > An additional limitation of Modula-3 in this regard, is=3D
&g= >t; > that you > > can't> > > make the type F opaque, unle= >ss you heap allocate i=3D
> >t, which we > > were trying>= > > > to avoid. Ada would allow you to do this, =3D
> >but it= >'s another > > example of> > > a convenience with high cost.= > It force=3D
> >s the equivalent of the > > revelation> &= >gt; > to be located in the equivalent=3D
> > of the interface, = >but makes it > > illegal> > > to write client code that =3D<= >BR>> >depends on what the revelation is.> > >> > > = >This in turn creates a source =3D
> >code control nightmare in a l= >arge > > project,> > > because now someone who=3D
> &g= >t; wants to make what is really a purely > > internal,> > > = >implementation ch=3D
> >ange, nevertheless has to check out the &g= >t; > interface, and> > > if you aren=3D
> >'t in denia= >l mode, that means implementers of all the > > client> > > c= >ode =3D
> >have to go to extra trouble to somehow find out that wh= >at > > appears> > > =3D
> >to be an interface chang= >e actually doesn't affect them after all.> > >> > >=3D>> > >> > > > Though that might seem nice.> > &g= >t; >> > > > Am I understanding eve=3D
> >rything?&g= >t; > > >> > > > Have folks hit this before and there's= > a set of name=3D
> >s that > > don't seem too lame> >= > > > that folks use?> > > >> > > > Also --=3D= >
> > language documentation?> > > > Nelson's green boo= >k is excellent.> > > > Th=3D
> >e stuff in the doc dir= >ectory is very dry and scientific.> > > > The tutoria=3D
>= >; >l seems more like a reference. Or maybe I didn't > > read it en= >ough.> > > >=3D
> > Is there better, in case I need a = >refresher?> > > > I think I got it, via =3D
> >Nelson'= >s book from memory (wonder if I > > can find mine..) and the referen= >=3D
> >ce,> > > > but I don't think anyone could learn= > from the current online > >=3D
> > docs in the source tree.= >> > > >> > > > Maybe it's me, some combination of = >=3D
> >laziness and short attention > > span> > > &= >gt; as I age..> > > >> > > > Btw, =3D
> >C= > doesn't offer a great solution here, though it offers > > leaving ou= >t som=3D
> >e type names.> > > > In C++ I could have b= >oth .size and operator[].> > > > =3D
> >Modula-3 seems= > to be missing operator overloading.> > > > It's got some bui= >=3D
> >ltin stuff, even array assignment and equality > > an= >d I think> > > > even =3D
> >record assignment and equ= >ality, but it is still a bit > > limiting.> > >> >=3D<= >BR>> > >> > > I have raved on this before, but, having ha= >d lots of painful > > ex=3D
> >perience with> > > u= >ser-defined overloading in Ada and C++, I can say with =3D
> >>= > > authority, that it is> > > a programming language disaster. = >It interact=3D
> >s with just about > > everything> > = >> else in the language, in very complic=3D
> >ated ways, and al= >l it buys > > you is saving> > > time/energy thinking up d= >=3D
> >istinct names for procedures/functions. > > Even this= >,> > > aside from the =3D
> >effects on the language, is = >a net loss, by the > > time you consider> > > r=3D
> &= >gt;eadability along with writability.> > >> > > User-defi= >ned overloaded operat=3D
> >ors provide a slight readability > = >> benefit, _if_> > > used with great res=3D
> >traint = >and discipline, something you can rely > > on not happening.> >= > > Me=3D
> >anwhile, the language complexity can easily double = >or worse. > > And, with =3D
> >the> > > exception o= >f compiler writers and language lawyers who spend > > h=3D
> &g= >t;undreds of hours> > > on just this, programmers don't understand= > the rules,=3D
> > not even > > close.> > >> >= >; > >> > > > Also, if I understand things correc=3D
&g= >t; >tly, this has long bothered > > me about Modula-3,> > &g= >t; > though I'm more t=3D
> >olerant now -- Modula-3 doesn't se= >em to allow > > for lighter wieght> > > >=3D
> >= > objects. Like, small stack allocated structs with member > > functio= >ns. Yo=3D
> >u seem to have> > > > to chose between he= >ap allocated garbage collected vir=3D
> >tual > > member fun= >ctions full> > > > featured objects, or featureless dumb=3D
= >> > structs. It's nice how C+ > > + allow hybrids --> > &= >gt; > objects don't have=3D
> > to be heap allocated and member= > functions > > don't have be virtual.> > > =3D
> >&= >gt; Or am I missing something?> > >> > >> > > C+= >+'s supposedly lighter weight=3D
> > forms of classes/structs with= > > > their special> > > member functions buy =3D
> >= >;nothing that plain records, plain > > procedures, and> > > = >interfaces/modul=3D
> >es don't already provide, again, at signifi= >cant > > and gratuitous> > > lan=3D
> >guage comple= >xity. Except when methods/member functions > > actually dispatc=3D>> >h> > > dynamically, there is nothing that the above won'= >t do, and when > > =3D
> >you create a> > > class i= >nstance as a local variable (i.e., on the stack), =3D
> >it is >= >; > necessarily> > > not polymorphic, that is, it can't change = >its "a=3D
> >llocated" or > > dynamic type> > > amo= >ng various subtypes at runtime. This =3D
> >in turn means it can't= > > > dispatch.> > >> > > So, just use plain procedu= >re=3D
> >s, an interface and a module, and you > > will get&= >gt; > > everything a lighte=3D
> >r-weight C++ class would g= >ive you.> > >> > >> > > >> > > > = >Anyway, I've got=3D
> >ten to accept C a bit more vs. C++ so I can= > > > deal with> > > > t: Type;> =3D
> >> &= >gt; > Type_DoSomething(t);> > > >> > > > in plac= >e of:> > > > t.DoSomething(=3D
> >);> > >>= > > >> > > Exactly. The special "receiver object" in a true m= >ethod c=3D
> >all has > > significant> > > semantic= > differences from an ordinary paramete=3D
> >r and introduces >= > > new complexities> > > and non-orthogonalities. It has =3D>> >some very valuable uses too.> > >> > > But to t= >hen create degenerate forms =3D
> >of it that still carry a lot &g= >t; > of these> > > complexities, but are equiva=3D
> >= >lent in programing power to plain old> > > parameters is just bad = >program d=3D
> >esign and bad language design. > > Objects a= >nd> > > methods are indeed cool=3D
> > for situations tha= >t utilize their > > semantic complexity.> > > But it's d=3D<= >BR>> >eeply uncool to try to look superficially cool by using an> = >> > inappropria=3D
> >tely sophisticated construct when the = >problem doesn't > > justify it.> > > =3D
> >Some OO= > proponents have gone way over the deep end here.> > >> > &g= >t; >> > > >=3D
> > - Jay> > > >> >= >; > >> > > > > > ----------------------------------= >---------=3D
> >--------------------------- > > --> > = >> > Boo! Scare away worms, viruses an=3D
> >d so much more! = >Try Windows > > Live OneCare! Try now!> > > <http://oneca= >re=3D
> >.live.com/standard/en-us/purchase/trial.aspx? > > s= >_cid=3D3Dwl_hotmailnews>> =3D
> >> >> > >>= > > > --> > > -----------------------------------------------= >------=3D
> >--------> > > Rodney M. Bates, retired assis= >tant professor> > > Dept. of Co=3D
> >mputer Science, Wic= >hita State University> > > Wichita, KS 67260-0083> > > 3= >=3D
> >16-978-3922> > > rodney.bates at wichita.edu> >= > >> > > --> > > ---------------=3D
> >-------= >---------------------------------------> > > Rodney M. Bates, reti= >re=3D
> >d assistant professor> > > Dept. of Computer Sci= >ence, Wichita State Univers=3D
> >ity> > > Wichita, KS 67= >260-0083> > > 316-978-3922> > > rodney.bates at wichita=3DR>> >.edu> >> >> > Boo! Scare away worms, viruses a= >nd so much more! Try Windows =3D
> >Live > > OneCare! Try no= >w!>=3D20
> >___________________________________________________= >______________
> >Climb to the top of the charts!=3DA0 Play Star S= >huffle:=3DA0 the word scramble =3D
> >challenge with star power.R>> >http://club.live.com/star_shuffle.aspx?icid=3D3Dstarshuffle_wlma= >iltextlink_oc=3D
> >t=3D
> >
> >--_0109391c-2ffe= >-4cfe-9165-c2a24628c3c7_
> >Content-Type: text/html; charset=3D"is= >o-8859-1"
> >Content-Transfer-Encoding: quoted-printable
> &= >gt;
> ><html>
> ><head>
> ><style= >>
> >.hmmessage P
> >{
> >margin:0px;
>= > >padding:0px
> >}
> >body.hmmessage
> >{
= >> >FONT-SIZE: 10pt;
> >FONT-FAMILY:Tahoma
> >}
&= >gt; ></style>
> ></head>
> ><body class= >=3D3D'hmmessage'>But if I don't want to pay for heap allocation, I=3D>> > can't say:<BR>
> >&nbsp;<BR>
> &g= >t;VAR T: v;<BR>
> >&nbsp;<BR>
> >ce=3D"">v.DoSomething();<BR>
> &g= >t;&nbsp;<BR>
> >Only IMPORT T FROM M;<BR>
> = >>&nbsp;<BR>
> >VAR T: v;<BR>
> >&n= >bsp;<BR>
> >M.DoSomething(v);<BR>
> >&nbs= >p;<BR>
> >Right?<BR><BR>
> >SPIN I thin= >k you mean.<BR>
> >Anyone build it and bring it up? I was lo= >ng curious but never did..<BR>
> >&nbsp;<BR>
&g= >t; >&nbsp;- Jay<BR><BR><BR>
> >
> &= >gt;<HR id=3D3DstopSpelling>
> ><BR>
> >&g= >t; CC: m3devel at elegosoft.com<BR>&gt; From: darko at darko.org<BR&= >gt;&gt; Subjec=3D
> >t: Re: [M3devel] small array in modula-3?= ><BR>&gt; Date: Thu, 15 Nov 2007 20=3D
> >:29:06 -0800<= >;BR>&gt; To: jay.krell at cornell.edu<BR>&gt; <BR>&= >gt; Not sure wh=3D
> >at the problem is with modules. If you want = >to avoid the <BR>&gt; dot you c=3D
> >an name the type s= >omething unique then import that type <BR>&gt; name. You =3D
&= >gt; >can create an interface with all the nice type names and <BR>= >&gt; import al=3D
> >l those names in modules by adding an EXP= >ORTS clause too.<BR>&gt; <BR>&gt; =3D
> >Perso= >nally I think M3, with a couple of extensions, wouldn't need <BR>&= >;gt; =3D
> >unsafe anything. The unsafe features are there mostly = >because of <BR>&gt; l=3D
> >egacy interfaces. I forget t= >he name but the folk who wrote an OS in <BR>&gt=3D
> >; = >M3 found it very effective with only couple of minor points with <BR>= >&gt;=3D
> > regards to interfacing to C code they built on top= > of, I think one of <BR>=3D
> >&gt; them was being able = >to pass NIL to a VAR parameter, which is a common =3D
> ><BR>= >;&gt; C idiom (and an annoying one for M3 users who then can't use VAR)= >.=3D
> ><BR>&gt; <BR>&gt; <BR>&gt; O= >n 15/11/2007, at 8:08 PM, Jay wrote:<BR>&gt; <B=3D
> >= >;R>&gt; &gt; Rodney, thank you, this is interesting.<BR>&a= >mp;gt; &gt; I definite=3D
> >ly don't want to pay for heap all= >ocation for a tiny array.<BR>&gt; &gt; I d=3D
> >on'= >t know about "subarray". It looks like it takes and returns <BR>&= >gt; &gt=3D
> >; arrays. It's not a type. I ordered another cop= >y of the Nelson book <BR>&g=3D
> >t; &gt; so I don't= > have to find mine.<BR>&gt; &gt;<BR>&gt; &gt; G= >ood idea "=3D
> >MakeT" I forgot about that pattern. I'll try it o= >ut.<BR>&gt; &gt;<BR>&gt; &=3D
> >gt; T= >he record and array I propose are not all that different really.<BR>&= >amp;g=3D
> >t; &gt; I just heard of something new. Have you he= >ard of it? "Duck typing".=3D
> > <BR>&gt; &gt; If it= > acts/quacks/walks like a duck, it is a duck.<BR>&gt; &=3D>> >gt; This is in very dynamic languages like Ruby.<BR>&gt= >; &gt; You apply obj=3D
> >ect.method and if object defines so= >mething named <BR>&gt; &gt; "method", th=3D
> >en it= > "must" have "the" meaning you intend.<BR>&gt; &gt; Kind of l= >ike how C=3D
> >++ templates "accept as parameters whatever <BR= >>&gt; &gt; happens to work".=3D
> ><BR>&gt; &= >amp;gt;<BR>&gt; &gt; Operator overloading is great for string= >s and "m=3D
> >ath".<BR>&gt; &gt;<BR>&gt; = >&gt; Maybe I should try to have this language de=3D
> >bate fr= >om scratch again..?<BR>&gt; &gt;<BR>&gt; &gt; I= > still am conflcted.<=3D
> >BR>&gt; &gt;<BR>&a= >mp;gt; &gt; Modules seem overly heavyweight.<BR>&gt; &gt;= > I d=3D
> >on't want Module1.T, Module2.T, I want T1, T2.<BR>= >;&gt; &gt;<BR>&gt; &gt; C+=3D
> >+ stack str= >ucts with non virtual member functions:<BR>&gt; &gt; class Re= >ct_=3D
> >t<BR>&gt; &gt; {<BR>&gt; &gt= >; Rect_t() : top(0), left(0), right(0), bottom(=3D
> >0) { }<BR= >>&gt; &gt;<BR>&gt; &gt; int Height() { return bott= >om - top; }<BR>&=3D
> >gt; &gt; int Width() { return= > right - left; }<BR>&gt; &gt; int top, left, b=3D
> >= >;ottom, right;<BR>&gt; &gt; };<BR>&gt; &gt;<= >BR>&gt; &gt; seems "good".<BR>&g=3D
> >t; &am= >p;gt;<BR>&gt; &gt; And it seems not really all that complicat= >ed for the c=3D
> >ompiler to <BR>&gt; &gt; flow the= > static type information around to resolve=3D
> > the functions..&= >lt;BR>&gt; &gt;<BR>&gt; &gt; Rect_t r;<BR>&a= >mp;gt; &gt; r.Height(=3D
> >) =3D3D&gt; Rect_Height(&a= >mp;r); ..and would be inlined anyway.<BR>&gt; &gt;<=3D
= >> >BR>&gt; &gt; I do find some compelling features in Modu= >la-3. Mainly that it=3D
> > <BR>&gt; &gt; compiles t= >o native code and has OPTIONAL safety, optional ga=3D
> >rbage <= >;BR>&gt; &gt; collection, and that the syntax of modules/interfa= >ces a=3D
> >llows fast <BR>&gt; &gt; compilation -- = >no longer reparsing the same header=3D
> >s over and over <BR&g= >t;&gt; &gt; and over and over.<BR>&gt; &gt;<BR>= >&gt; &gt; =3D
> >Operator overloading btw..have seen "temp= >late SafeInt"? It acts <BR>&gt; &g=3D
> >t; like a p= >rimitive integer, but raises exceptions upon overflow.<BR>&gt; &a= >mp;=3D
> >gt; For this to work very much requires operator overloa= >ding.<BR>&gt; &gt;<=3D
> >BR>&gt; &gt;= > A point, of course, is to be able to have user defined types t=3D
> = >>hat <BR>&gt; &gt; can act like the built in types..<BR= >>&gt; &gt;<BR>&gt; &g=3D
> >t; - Jay<B= >R>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt= >; &gt; Date: Thu, 15 Nov 2007=3D
> > 18:39:18 -0600<BR>&= >amp;gt; &gt; &gt; From: rodney.bates at wichita.edu<BR>&gt; = >&g=3D
> >t; &gt; To: m3devel at elegosoft.com<BR>&g= >t; &gt; &gt; Subject: Re: [M3devel] =3D
> >small array in = >modula-3?<BR>&gt; &gt; &gt;<BR>&gt; &gt; &a= >mp;gt; Jay wrote:<BR>=3D
> >&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &gt; What is the right way to have a var= >ia=3D
> >bly sized but always small <BR>&gt; &gt; ar= >ray in Modula-3?<BR>&gt; &gt; &g=3D
> >t; &g= >t; My array will only ever have 1 or 2 elements.<BR>&gt; &gt;= > &gt; &gt=3D
> >; I'd like to always allocate room for 2 e= >lements, and have there <BR>&gt; =3D
> >&gt; be a si= >ze.<BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt;= > &gt; &gt; It seems I ha=3D
> >ve a choice of<BR>&am= >p;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t; a) an "open" a=3D
> >rray<BR>&gt; &gt; &gt;&l= >t;BR>&gt; &gt; &gt; Heap allocated, I presume? If the =3D>> >max size is only 2 elements,<BR>&gt; &gt; &gt; = >this is pretty extravagant, =3D
> >as a heap allocated open array = >will<BR>&gt; &gt; &gt; have 4 extra behind-t=3D
> &= >gt;he-scenes words of space overhead, plus<BR>&gt; &gt; &= >gt; maybe heap fragme=3D
> >ntation, and time overhead of allocati= >on,<BR>&gt; &gt; &gt; collection, and=3D
> > may= >be reduced locality of reference.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; &=3D
> >gt; b) wrap it up in a = >record<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &gt;=3D
> > I'd like so have, like:<BR>&= >;gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt= >; TYPE=3D
> > A =3D3D ARRAY [0..1] OF FOO;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; A=3D
= >> >nd be able to say:<BR>&gt; &gt; &gt; &gt;<= >;BR>&gt; &gt; &gt; &gt; VAR<BR>&gt=3D
> = >>; &gt; &gt; &gt; a : A;<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; ..<BR=3D
> = >>>&gt; &gt; &gt; &gt; a.size<BR>&gt; &g= >t; &gt; &gt; FOR i :=3D3D 0 TO a.size D=3D
> >O<BR>&= >amp;gt; &gt; &gt; &gt; do something with a[i]<BR>&gt;= > &gt; &gt; &gt;<BR>&=3D
> >gt; &gt; &= >;gt; &gt; It seems I have no option but, like:<BR>&gt; &g= >t; &gt; &=3D
> >gt;<BR>&gt; &gt; &gt; &a= >mp;gt; TYPE A =3D3D RECORD<BR>&gt; &gt; &gt; &gt; a: = >ARRA=3D
> >Y[0..1] OF FOO;<BR>&gt; &gt; &gt; &am= >p;gt; size :=3D3D 1; (* usually of size 1, s=3D
> >ometimes 2 *)&l= >t;BR>&gt; &gt; &gt; &gt; END<BR>&gt; &gt; = >&gt; &gt;<BR>&gt; &gt=3D
> >; &gt; &= >gt; and then<BR>&gt; &gt; &gt; &gt; FOR i :=3D3D 0 TO= > a.size DO<BR>&g=3D
> >t; &gt; &gt; &gt; do = >something with a.a[i];<BR>&gt; &gt; &gt; &gt;<BR&g= >t;&gt; =3D
> >&gt; &gt; &gt; That is "ok". Not gre= >at -- what to call the inner a?<BR>&gt;=3D
> > &gt; = >&gt; &gt; But then furthermore, I'd like to construct constants.<= >;BR>&=3D
> >gt; &gt; &gt; &gt; It seems I am st= >uck with either the verbose:<BR>&gt; &gt=3D
> >; &am= >p;gt; &gt;<BR>&gt; &gt; &gt; &gt; PROCEDURE F(a:A= >);<BR>&gt; &gt; &gt; &gt;=3D
> ><BR>&a= >mp;gt; &gt; &gt; &gt; F( A { ARRAY[0..1] OF FOO { .. } );<BR= >>&gt; &gt; &g=3D
> >t; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; OR I have to come up with a name for the emb=3DR>> >edded array.<BR>&gt; &gt; &gt; &gt; But of= > course, its type is really "the =3D
> >same" as the outer type.&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt;<B= >R>&gt; &gt; &=3D
> >gt; Ignoring the fact that the = >types are different linguistically<BR>&gt; &=3D
> >g= >t; &gt; (one a record type, the other an array), the types are differen= >t<B=3D
> >R>&gt; &gt; &gt; at a deep semantic le= >vel too. The inner array has static<B=3D
> >R>&gt; &= >gt; &gt; size, the outer one (call it a "variable array", perhaps)<= >=3D
> >BR>&gt; &gt; &gt; has dynamically changeable= > size, even more easily changed=3D
> ><BR>&gt; &gt; = >&gt; after it is created than a heap-allocated open array. Th=3D
>= >; >is<BR>&gt; &gt; &gt; is a significant semantic diff= >erence, so it also makes=3D
> > program<BR>&gt; &gt;= > &gt; design sense to view them as different types.<BR=3D
> &g= >t;>&gt; &gt; &gt;<BR>&gt; &gt; &gt; &g= >t;<BR>&gt; &gt; &gt; &gt; To wit:<BR>&g=3D<= >BR>> >t; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &gt; TYPE FooArray =3D3D ARRAY[0..1] OF F=3D
> >oo;<BR&g= >t;&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &= >amp;gt; TYPE FooArray =3D3D RECORD<=3D
> >BR>&gt; &g= >t; &gt; &gt; a : FooArray;<BR>&gt; &gt; &gt; &= >;gt; size :=3D3D 1;<BR=3D
> >>&gt; &gt; &gt; &am= >p;gt; END;<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >amp;gt; &gt; &gt; F( =3D
> >FooArray { FooArray { .. } );&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &am= >p;gt; &gt;=3D
> > But I have to come up with different names.&= >lt;BR>&gt; &gt; &gt; &gt;<BR>&gt;=3D
> &= >gt; &gt; &gt; &gt; And I don't think I can leave out the name f= >or the construc=3D
> >tor, <BR>&gt; &gt; like:<BR= >>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt;= > &gt; F( F=3D
> >ooArray { { .. } );<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt;<BR>&gt; &gt; &= >amp;gt; Y=3D
> >es, this is a limitation in Modula-3. Ada allows v= >alue constructors<BR>&gt;=3D
> > &gt; &gt; to om= >it inner type names in cases like this, and it is <BR>&gt; =3D>> >&gt; convenient. But<BR>&gt; &gt; &gt; it a= >lso crosses a really major line =3D
> >on complexity of the langua= >ge <BR>&gt; &gt; semantics,<BR>&gt; &gt; &g= >t; si=3D
> >nce type analysis information now flows not only upwar= >d, but <BR>&gt; &gt; =3D
> >also downward<BR>&= >amp;gt; &gt; &gt; in expression typing. I am mostly content t=3D>> >o live with this as <BR>&gt; &gt; one bit of<BR&= >gt;&gt; &gt; &gt; the price of=3D
> > avoiding a horri= >bly over complex language.<BR>&gt; &gt; &gt;<BR>&am= >p;gt; &gt; =3D
> >&gt; Ordinary procedures can do pretty m= >uch all of the things done by <BR>&=3D
> >gt; &gt; e= >xotic<BR>&gt; &gt; &gt; and complex language stuff like C= >++ const=3D
> >ructors. If you don't <BR>&gt; &gt; w= >ant to write<BR>&gt; &gt; &gt; the pon=3D
> >der= >ous nested value constructor, write a constructor <BR>&gt; &g= >t; procedur=3D
> >e and<BR>&gt; &gt; &gt; call i= >t. As Antony suggested, you can make it accep=3D
> >t an open <= >BR>&gt; &gt; array formal,<BR>&gt; &gt; &gt; w= >hich then codes ju=3D
> >st like a simple array value constructor.= > You <BR>&gt; &gt; could even<BR>&=3D
> >g= >t; &gt; &gt; make it elaborate and general, e.g.:<BR>&gt;= > &gt; &gt;<BR>&gt=3D
> >; &gt; &gt; PROC= >EDURE MakeF ( Val : ARRAY OF FOO ) : F<BR>&gt; &gt; &gt;&= >lt;BR=3D
> >>&gt; &gt; &gt; =3D3D VAR LSize : CARDI= >NAL<BR>&gt; &gt; &gt; ; VAR LResult : =3D
> >A&l= >t;BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; ; BE= >GIN<BR>&gt; &gt; &gt; LSize :=3D3D =3D
> >NUMBER= > ( Val )<BR>&gt; &gt; &gt; &lt;* ASSERT LSize &lt= >;=3D3D NUMBER ( FooArr=3D
> >ay ) *&gt;<BR>&gt; &= >;gt; &gt; ; LResult . size :=3D3D LSize<BR>&gt; &gt; &= >;gt; =3D
> >; SUBARRAY ( LResult . a , 0 , LSize )<BR>&g= >t; &gt; &gt; :=3D3D SUBARRAY ( Va=3D
> >l , FIRST ( Val ) = >, LSize )<BR>&gt; &gt; &gt; ; RETURN LResult<BR>&am= >p;gt; &gt;=3D
> > &gt; END MakeF<BR>&gt; &gt= >; &gt;<BR>&gt; &gt; &gt; Alternatively, since yo=3DR>> >ur maximum element count is so small, you <BR>&gt; &am= >p;gt; could<BR>&gt; &gt; =3D
> >&gt; write a con= >structor procedure that took two formals of type FOO, <BR>&=3D>> >gt; &gt; with<BR>&gt; &gt; &gt; at least th= >e second one optional. (This wou=3D
> >ld require a <BR>&= >;gt; &gt; distinguished<BR>&gt; &gt; &gt; value of ty= >pe FO=3D
> >O that would be used to mean "omitted".)<BR>&= >;gt; &gt; &gt;<BR>&gt; &gt; &gt=3D
> >; = >And, of course, if you want to use abstraction, you can put the <BR>&= >amp;gt; =3D
> >&gt; types,<BR>&gt; &gt; &gt;= > constructor procedures, and various other pro=3D
> >cedures for &= >lt;BR>&gt; &gt; manipulating<BR>&gt; &gt; &gt;= > the variable sized=3D
> > array in a module, behind an interface.= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt=3D<= >BR>> >; An additional limitation of Modula-3 in this regard, is that = >you <BR>&gt;=3D
> > &gt; can't<BR>&gt; &am= >p;gt; &gt; make the type F opaque, unless you heap alloc=3D
> >= >;ate it, which we <BR>&gt; &gt; were trying<BR>&gt;= > &gt; &gt; to avoid. Ada =3D
> >would allow you to do this= >, but it's another <BR>&gt; &gt; example of<BR>&g= >=3D
> >t; &gt; &gt; a convenience with high cost. It force= >s the equivalent of the =3D
> ><BR>&gt; &gt; revelat= >ion<BR>&gt; &gt; &gt; to be located in the equivalent =3D= >
> >of the interface, but makes it <BR>&gt; &gt; ill= >egal<BR>&gt; &gt; &gt; to w=3D
> >rite client co= >de that depends on what the revelation is.<BR>&gt; &gt; &= >gt;<=3D
> >BR>&gt; &gt; &gt; This in turn create= >s a source code control nightmare in a=3D
> > large <BR>&= >;gt; &gt; project,<BR>&gt; &gt; &gt; because now some= >one who wan=3D
> >ts to make what is really a purely <BR>&am= >p;gt; &gt; internal,<BR>&gt; &gt; &gt=3D
> >= >; implementation change, nevertheless has to check out the <BR>&g= >t; &gt; in=3D
> >terface, and<BR>&gt; &gt; &= >gt; if you aren't in denial mode, that means imp=3D
> >lementers o= >f all the <BR>&gt; &gt; client<BR>&gt; &gt; &am= >p;gt; code have to go=3D
> > to extra trouble to somehow find out = >that what <BR>&gt; &gt; appears<BR>&g=3D
> &g= >t;t; &gt; &gt; to be an interface change actually doesn't affect th= >em after a=3D
> >ll.<BR>&gt; &gt; &gt;<BR>= >&gt; &gt; &gt; &gt;<BR>&gt; &gt; &gt; &am= >p;gt; Though =3D
> >that might seem nice.<BR>&gt; &g= >t; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Am I un= >=3D
> >derstanding everything?<BR>&gt; &gt; &gt;= > &gt;<BR>&gt; &gt; &gt; &gt; Have =3D
> >= >;folks hit this before and there's a set of names that <BR>&gt; &= >amp;gt; don't s=3D
> >eem too lame<BR>&gt; &gt; &= >;gt; &gt; that folks use?<BR>&gt; &gt; &gt; &gt;&= >lt;=3D
> >BR>&gt; &gt; &gt; &gt; Also -- langua= >ge documentation?<BR>&gt; &gt; &gt; &g=3D
> >= >;t; Nelson's green book is excellent.<BR>&gt; &gt; &gt; &= >amp;gt; The stuff in th=3D
> >e doc directory is very dry and scie= >ntific.<BR>&gt; &gt; &gt; &gt; The tuto=3D
> &g= >t;rial seems more like a reference. Or maybe I didn't <BR>&gt; &a= >mp;gt; read it e=3D
> >nough.<BR>&gt; &gt; &gt; = >&gt; Is there better, in case I need a refresher?<=3D
> >BR= >>&gt; &gt; &gt; &gt; I think I got it, via Nelson's book= > from memory (won=3D
> >der if I <BR>&gt; &gt; can f= >ind mine..) and the reference,<BR>&gt; &gt; &gt=3D
>= >; >; &gt; but I don't think anyone could learn from the current onli= >ne <BR>&gt=3D
> >; &gt; docs in the source tree.<= >BR>&gt; &gt; &gt; &gt;<BR>&gt; &gt; &g= >t; &g=3D
> >t; Maybe it's me, some combination of laziness and= > short attention <BR>&gt;=3D
> > &gt; span<BR>= >&gt; &gt; &gt; &gt; as I age..<BR>&gt; &gt; &= >amp;gt; &gt;<BR>&gt;=3D
> > &gt; &gt; &g= >t; Btw, C doesn't offer a great solution here, though it offer=3D
> &= >gt;s <BR>&gt; &gt; leaving out some type names.<BR>&= >;gt; &gt; &gt; &gt; In C++ =3D
> >I could have both .s= >ize and operator[].<BR>&gt; &gt; &gt; &gt; Modula-3 s= >ee=3D
> >ms to be missing operator overloading.<BR>&gt; = >&gt; &gt; &gt; It's got some=3D
> > builtin stuff, eve= >n array assignment and equality <BR>&gt; &gt; and I thin=3DR>> >k<BR>&gt; &gt; &gt; &gt; even record assig= >nment and equality, but it is sti=3D
> >ll a bit <BR>&gt= >; &gt; limiting.<BR>&gt; &gt; &gt;<BR>&gt; = >&gt; &gt;<BR>&gt=3D
> >; &gt; &gt; I hav= >e raved on this before, but, having had lots of painful <B=3D
> &g= >t;R>&gt; &gt; experience with<BR>&gt; &gt; &gt= >; user-defined overloading in A=3D
> >da and C++, I can say with &= >lt;BR>&gt; &gt; authority, that it is<BR>&gt; &gt;= >=3D
> > &gt; a programming language disaster. It interacts wit= >h just about <BR>&gt=3D
> >; &gt; everything<BR&g= >t;&gt; &gt; &gt; else in the language, in very complicat=3D
= >> >ed ways, and all it buys <BR>&gt; &gt; you is saving= ><BR>&gt; &gt; &gt; time=3D
> >/energy thinking u= >p distinct names for procedures/functions. <BR>&gt; &gt; =3D<= >BR>> >Even this,<BR>&gt; &gt; &gt; aside from the e= >ffects on the language, is a n=3D
> >et loss, by the <BR>&am= >p;gt; &gt; time you consider<BR>&gt; &gt; &gt; readab= >ili=3D
> >ty along with writability.<BR>&gt; &gt; &a= >mp;gt;<BR>&gt; &gt; &gt; User-defined=3D
> > ove= >rloaded operators provide a slight readability <BR>&gt; &gt; = >benefit, _=3D
> >if_<BR>&gt; &gt; &gt; used with= > great restraint and discipline, something y=3D
> >ou can rely <= >;BR>&gt; &gt; on not happening.<BR>&gt; &gt; &= >gt; Meanwhile, th=3D
> >e language complexity can easily double or= > worse. <BR>&gt; &gt; And, with t=3D
> >he<BR>= >&gt; &gt; &gt; exception of compiler writers and language lawye= >rs who=3D
> > spend <BR>&gt; &gt; hundreds of hours&= >lt;BR>&gt; &gt; &gt; on just this, prog=3D
> >ramme= >rs don't understand the rules, not even <BR>&gt; &gt; close.&= >lt;BR>&gt; &=3D
> >gt; &gt;<BR>&gt; &= >gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt; Also, if= > I understan=3D
> >d things correctly, this has long bothered <= >BR>&gt; &gt; me about Modula-3,=3D
> ><BR>&gt= >; &gt; &gt; &gt; though I'm more tolerant now -- Modula-3 doesn= >'t se=3D
> >em to allow <BR>&gt; &gt; for lighter wi= >eght<BR>&gt; &gt; &gt; &gt; objects=3D
> >. = >Like, small stack allocated structs with member <BR>&gt; &gt;= > functions. =3D
> >You seem to have<BR>&gt; &gt; &am= >p;gt; &gt; to chose between heap allocated gar=3D
> >bage coll= >ected virtual <BR>&gt; &gt; member functions full<BR>&a= >mp;gt; &gt; &gt=3D
> >; &gt; featured objects, or feat= >ureless dumb structs. It's nice how C+ <BR>=3D
> >&gt; &= >amp;gt; + allow hybrids --<BR>&gt; &gt; &gt; &gt; obj= >ects don't have to b=3D
> >e heap allocated and member functions &= >lt;BR>&gt; &gt; don't have be virtual.<=3D
> >BR>= >&gt; &gt; &gt; &gt; Or am I missing something?<BR>&am= >p;gt; &gt; &gt;<BR>&gt;=3D
> > &gt; &gt;= ><BR>&gt; &gt; &gt; C++'s supposedly lighter weight forms = >of class=3D
> >es/structs with <BR>&gt; &gt; their s= >pecial<BR>&gt; &gt; &gt; member functi=3D
> >ons= > buy nothing that plain records, plain <BR>&gt; &gt; procedur= >es, and<BR>=3D
> >&gt; &gt; &gt; interfaces/modu= >les don't already provide, again, at signific=3D
> >ant <BR>= >&gt; &gt; and gratuitous<BR>&gt; &gt; &gt; langua= >ge complexity. Exc=3D
> >ept when methods/member functions <BR&= >gt;&gt; &gt; actually dispatch<BR>&gt; &=3D
> &= >gt;gt; &gt; dynamically, there is nothing that the above won't do, and = >when <B=3D
> >R>&gt; &gt; you create a<BR>&= >;gt; &gt; &gt; class instance as a local variab=3D
> >le (= >i.e., on the stack), it is <BR>&gt; &gt; necessarily<BR>= >;&gt; &gt; &gt; =3D
> >not polymorphic, that is, it ca= >n't change its "allocated" or <BR>&gt; &gt; =3D
> >d= >ynamic type<BR>&gt; &gt; &gt; among various subtypes at r= >untime. This in t=3D
> >urn means it can't <BR>&gt; &= >;gt; dispatch.<BR>&gt; &gt; &gt;<BR>&gt; &g= >t; &=3D
> >gt; So, just use plain procedures, an interface and= > a module, and you <BR>&=3D
> >gt; &gt; will get<= >BR>&gt; &gt; &gt; everything a lighter-weight C++ class w=3D= >
> >ould give you.<BR>&gt; &gt; &gt;<BR>&a= >mp;gt; &gt; &gt;<BR>&gt; &gt; &gt; &gt;<B= >=3D
> >R>&gt; &gt; &gt; &gt; Anyway, I've gotte= >n to accept C a bit more vs. C++ so=3D
> > I can <BR>&gt= >; &gt; deal with<BR>&gt; &gt; &gt; &gt; t: Type;&= >lt;BR>&gt; &gt;=3D
> > &gt; &gt; Type_DoSomethi= >ng(t);<BR>&gt; &gt; &gt; &gt;<BR>&gt; &= >gt; &gt; &g=3D
> >t; in place of:<BR>&gt; &g= >t; &gt; &gt; t.DoSomething();<BR>&gt; &gt; &gt;&l= >t;B=3D
> >R>&gt; &gt; &gt;<BR>&gt; &g= >t; &gt; Exactly. The special "receiver object" i=3D
> >n a tru= >e method call has <BR>&gt; &gt; significant<BR>&gt;= > &gt; &gt; semant=3D
> >ic differences from an ordinary pa= >rameter and introduces <BR>&gt; &gt; new =3D
> >comp= >lexities<BR>&gt; &gt; &gt; and non-orthogonalities. It ha= >s some very va=3D
> >luable uses too.<BR>&gt; &gt; &= >amp;gt;<BR>&gt; &gt; &gt; But to then create deg=3D
&g= >t; >enerate forms of it that still carry a lot <BR>&gt; &g= >t; of these<BR>&gt; &=3D
> >gt; &gt; complexitie= >s, but are equivalent in programing power to plain old<=3D
> >B= >R>&gt; &gt; &gt; parameters is just bad program design and b= >ad language de=3D
> sign. <BR>&gt; &gt; Objects and<= >BR>&gt; &gt; &gt; methods are indeed cool f=3D
> >o= >r situations that utilize their <BR>&gt; &gt; semantic comple= >xity.<BR>&gt;=3D
> > &gt; &gt; But it's deeply u= >ncool to try to look superficially cool by usin=3D
> >g an<BR&g= >t;&gt; &gt; &gt; inappropriately sophisticated construct when t= >he pro=3D
> >blem doesn't <BR>&gt; &gt; justify it.&= >lt;BR>&gt; &gt; &gt; Some OO proponents=3D
> > have= > gone way over the deep end here.<BR>&gt; &gt; &gt;<BR= >>&gt; &gt; &gt; =3D
> >&gt;<BR>&gt; &= >amp;gt; &gt; &gt; - Jay<BR>&gt; &gt; &gt; &gt= >;<BR>&gt; &gt; &gt; =3D
> >&gt;<BR>&am= >p;gt; &gt; &gt; &gt; <BR>&gt; &gt; --------------= >-------------------=3D
> >------------------------------------- &l= >t;BR>&gt; &gt; --<BR>&gt; &gt; &gt; &g=3D<= >BR>> >t; Boo! Scare away worms, viruses and so much more! Try Windows= > <BR>&gt; &g=3D
> >t; Live OneCare! Try now!<BR&g= >t;&gt; &gt; &gt; &lt;http://onecare.live.com/sta=3D
>= > >ndard/en-us/purchase/trial.aspx? <BR>&gt; &gt; s_cid=3D3= >Dwl_hotmailnews&gt;<B=3D
> >R>&gt; &gt; &gt;= ><BR>&gt; &gt; &gt;<BR>&gt; &gt; &gt; --= ><BR>&gt; &gt; &gt; -=3D
> >---------------------= >---------------------------------------<BR>&gt; &gt; &=3D= >
> >gt; Rodney M. Bates, retired assistant professor<BR>&= >;gt; &gt; &gt; Dept. of=3D
> > Computer Science, Wichita S= >tate University<BR>&gt; &gt; &gt; Wichita, KS 6=3D
>= >; >7260-0083<BR>&gt; &gt; &gt; 316-978-3922<BR>&= >amp;gt; &gt; &gt; rodney.bates at wic=3D
> >hita.edu<BR>= >;&gt; &gt; &gt;<BR>&gt; &gt; &gt; --<BR>= >;&gt; &gt; &gt; ---------=3D
> >----------------------= >------------------------------<BR>&gt; &gt; &gt; Rodn=3D<= >BR>> >ey M. Bates, retired assistant professor<BR>&gt; &= >;gt; &gt; Dept. of Compute=3D
> >r Science, Wichita State Univ= >ersity<BR>&gt; &gt; &gt; Wichita, KS 67260-008=3D
>= > >3<BR>&gt; &gt; &gt; 316-978-3922<BR>&gt; &= >amp;gt; &gt; rodney.bates at wichita.edu=3D
> ><BR>&gt;= > &gt;<BR>&gt; &gt;<BR>&gt; &gt; Boo! Scare = >away worms, viruses and =3D
> >so much more! Try Windows Live <= >BR>&gt; &gt; OneCare! Try now!<BR>&gt; <BR>=3DR>> ><BR><br /><hr />Climb to the top of the charts= >!=3DA0 Play Star Shuffle:=3DA0 th=3D
> >e word scramble challenge = >with star power. <a href=3D3D'http://club.live.com/=3D
> >star_= >shuffle.aspx?icid=3D3Dstarshuffle_wlmailtextlink_oct' target=3D3D'_new'>= >Pl=3D
> >ay Now!</a></body>
> ></html>= >=3D
> >
> >--_0109391c-2ffe-4cfe-9165-c2a24628c3c7_--
= >


Help yourself to FREE treats served up daily at the Messeng= >er Caf=E9. ml?ocid=3DTXT_TAGLM_OctWLtagline' target=3D'_new'>Stop by today! >= > >--_85b6c041-9539-4614-b541-8813489e58bb_-- From jay.krell at cornell.edu Sat Nov 17 09:35:10 2007 From: jay.krell at cornell.edu (Jay) Date: Sat, 17 Nov 2007 08:35:10 +0000 Subject: [M3devel] small array in modula-3? In-Reply-To: References: <473CE6B6.3030402@wichita.edu> <473E0ECB.504@wichita.edu> Message-ID: I forgot to point out something I half agree with -- overloading...We have a plain text index over a very large code base. Look for "Close", and hypothetically, I'm making up names here, you find File::Close, Window::Close, Session::Close -- not too bad for the implementations, if you can look for "File::Close", but if you want to find the callers, f.Close, w.Close, s.Close, etc... A "problem" with C++ is that the compiler implements it very well, and nothing else comes close. Good luck evaluating expressions in a debugger, search, "refactoring editors", "wizards" that can change code, etc. It's neat that Modula-3 is simple enough that the remoting feature can be a separate parser over the one language, instead of having a seperate interface language.. But still it is super tempting to have function names qualified by at least the static types of their first parameter or all parameters, if not the dynamic types. Qualification by the dynamic type of the first parameter is if course super common, super popular, even supported in Modula-3.. and maybe in C via function pointers..though at least in C it is obvious when such "switching" is being used (except, even then, it is often hidden by an upper layer -- like, I call ReadFile/WriteFile and then way down under the covers there are drivers to switch between FAT, NTFS, SMB, etc.) As to looseness and "duck typing", well, I see both sides here really.. And I am well aware of how buggy code is.. - Jay > Date: Fri, 16 Nov 2007 22:24:15 +0100> From: lemming at henning-thielemann.de> To: rodney.bates at wichita.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] small array in modula-3?> > > On Fri, 16 Nov 2007, Rodney M. Bates wrote:> > > If you don't want to have to write the module name as a qualifier, you can> > rename a procedure too, with a constant declaration (Procedures in Modula-3> > are actually the same thing a constants of procedure type.)> >> > CONST DoSomething = M.DoSomething> > ...> > DoSomething ( v )> > It would have been nice if PROCEDURE declarations would reflect this, like> in functional languages. Say> > CONST> Sin => PROCEDURE (x: LONGREAL;): LONGREAL> BEGIN> ...> RETURN y;> END;> > This would also be the key for anonymous functions or loops as higher> order functions. Just an idea, it's certainly simpler just to use a> functional language. :-) _________________________________________________________________ Climb to the top of the charts!? Play Star Shuffle:? the word scramble challenge with star power. http://club.live.com/star_shuffle.aspx?icid=starshuffle_wlmailtextlink_oct -------------- next part -------------- An HTML attachment was scrubbed... URL: From mika at async.caltech.edu Mon Nov 19 13:36:00 2007 From: mika at async.caltech.edu (Mika Nystrom) Date: Mon, 19 Nov 2007 04:36:00 -0800 Subject: [M3devel] write access to CM3 repository? Message-ID: <200711191236.lAJCa0YE051000@camembert.async.caltech.edu> Hello, Not sure who to write to these days... but it seems I lost my write access to the source repository? I just made the little "sharedboard" demo work on my machine and thought it'd be nice if it were committed. Mika From hosking at cs.purdue.edu Wed Nov 21 21:22:55 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Wed, 21 Nov 2007 15:22:55 -0500 Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <817267.35735.qm@web27105.mail.ukl.yahoo.com> References: <817267.35735.qm@web27105.mail.ukl.yahoo.com> Message-ID: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Have you tried this lately? It seems to work fine for me on Fedora Core. On Oct 30, 2007, at 12:48 PM, Daniel Alejandro Benavides D. wrote: > Hi: > LINUXLIBC6 32 bits, ubuntu dapper > > >Hmm. showheap works fine for me on my I386_DARWIN box. What > >platform are you on? > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro Benavides D. wrote: > > > Hi: > > About this last changes, the runtime can not properly > > feed shownew, with a @M3shownew=shownew. > > The program 'a' is just not started as it seems here, > > altough the window (shownew) does appear, start > > doesn't respond, and it stays there until aborted. > > > > Thanks > > > > --- "Daniel Alejandro Benavides D." > > escribi?: > > > >> Hi: > >> Yes it's working very well. I'm sorry for the delay. > >> Thanks. > >> --- Tony Hosking escribi?: > >> > >>> Please try the latest CVS head. > >>> > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > >>> Benavides D. wrote: > >>> > >>>> Hi: > >>>> Im trying to execute the following program with > >>> the Pthread cvs > >>>> head implementation and I got this when > >> executing > >>> the program: > >>>> > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>> LINUXLIBC6/Main > >>>> Entre dos enteros6 7 > >>>> Estadisticas del Heap > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > >>>> > >>>> > >>>> *** > >>>> *** runtime error: > >>>> *** <*ASSERT*> failed. > >>>> *** file > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line 992 > >>>> *** > >>>> > >>>> Aborted > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > >>>> > >>>> The assert violated in > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is this: > >>>> PROCEDURE ProcessOther (act: Activation; p: > >>> PROCEDURE (start, > >>>> stop: ADDRESS)) = > >>>> (* LL=activeMu *) > >>>> VAR > >>>> sp: ADDRESS; > >>>> state: RTMachine.ThreadState; > >>>> BEGIN > >>>> <*ASSERT act.state = ActState.Stopped*> > >>>> > >>>> > >>>> The source code of the little program is this: > >>>> > >>>> MODULE Main; > >>>> > >>>> IMPORT SIO; > >>>> IMPORT RTHeapStats; > >>>> IMPORT RTutils; > >>>> IMPORT RTHeapDebug; > >>>> VAR > >>>> varA, varB, varC: INTEGER; > >>>> > >>>> > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > >>>> VAR > >>>> varC: INTEGER; > >>>> BEGIN > >>>> varC:=a*b; > >>>> RETURN varC; > >>>> END multiplicar; > >>>> > >>>> > >>>> BEGIN > >>>> > >>>> SIO.PutText("Entre dos enteros"); > >>>> varA:=SIO.GetInt(); > >>>> varB:=SIO.GetInt(); > >>>> varC:=multiplicar(varA,varB); > >>>> SIO.PutText("Estadisticas del Heap"); > >>>> RTHeapDebug.CheckHeap(); > >>>> RTHeapStats.ReportReachable(); > >>>> (* RTutils.Heap > >>>> > >>> > >> > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > >>>> SIO.PutInt(varC); > >>>> > >>>> END Main. > >>>> > >>>> According to the draft book of Michael Dagenais > >>> Building > >>>> Distributed OO Applications: Modula-3 Objects > >> at > >>> Work, > >>>> RTHeapStats.ReportReachable() > >>>> " ... is called to determine the number > >>>> of active, reachable, objects (i.e. those which > >>> would not be > >>>> garbage collected). Of the 1980 objects on the > >>> heap, only slightly > >>>> more than half are still alive." > >>>> > >>>> According to the interface documentation: > >>>> "reports the number of reachable objects and > >>> bytes from each > >>>> compilation unit, thread stack, and the > >> individual > >>> roots that reach > >>>> the most bytes. The report is written to stderr. > >>> The Modula-3 > >>>> process is frozen during the scanning and > >>> reporting." > >>>> > >>>> Obviously with the previous version of pthread > >> the > >>> things were > >>>> working fine, also with user level > >> implementation > >>>> > >>>> Thanks, > >>>> > >>>> Daniel Benavides > > > ?Descubre una nueva forma de obtener respuestas a tus preguntas! > Entra en Yahoo! Respuestas. From dabenavidesd at yahoo.es Thu Nov 22 20:56:04 2007 From: dabenavidesd at yahoo.es (Daniel Alejandro Benavides D.) Date: Thu, 22 Nov 2007 20:56:04 +0100 (CET) Subject: [M3devel] Calling RTHeapStats.ReportReachable(); with Pthread cvs head In-Reply-To: <47E62FB1-8B31-4129-B17A-E17CDFE3A70A@cs.purdue.edu> Message-ID: <645186.51518.qm@web27114.mail.ukl.yahoo.com> Hi: Yes, it is working; shownew and also the test program. Thanks. --- Tony Hosking wrote: > Have you tried this lately? It seems to work fine > for me on Fedora > Core. > > On Oct 30, 2007, at 12:48 PM, Daniel Alejandro > Benavides D. wrote: > > > Hi: > > LINUXLIBC6 32 bits, ubuntu dapper > > > > >Hmm. showheap works fine for me on my I386_DARWIN > box. What > > >platform are you on? > > > > On Oct 30, 2007, at 2:24 AM, Daniel Alejandro > Benavides D. wrote: > > > > > Hi: > > > About this last changes, the runtime can not > properly > > > feed shownew, with a @M3shownew=shownew. > > > The program 'a' is just not started as it seems > here, > > > altough the window (shownew) does appear, start > > > doesn't respond, and it stays there until > aborted. > > > > > > Thanks > > > > > > --- "Daniel Alejandro Benavides D." > > > escribi?: > > > > > >> Hi: > > >> Yes it's working very well. I'm sorry for the > delay. > > >> Thanks. > > >> --- Tony Hosking escribi?: > > >> > > >>> Please try the latest CVS head. > > >>> > > >>> On Oct 21, 2007, at 6:03 PM, Daniel Alejandro > > >>> Benavides D. wrote: > > >>> > > >>>> Hi: > > >>>> Im trying to execute the following program > with > > >>> the Pthread cvs > > >>>> head implementation and I got this when > > >> executing > > >>> the program: > > >>>> > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>> LINUXLIBC6/Main > > >>>> Entre dos enteros6 7 > > >>>> Estadisticas del Heap > > >>>> HEAP: 0xb73d2000 .. 0xb7412000 => 0.2 Mbytes > > >>>> > > >>>> > > >>>> *** > > >>>> *** runtime error: > > >>>> *** <*ASSERT*> failed. > > >>>> *** file > > >>> "../src/thread/PTHREAD/ThreadPThread.m3", line > 992 > > >>>> *** > > >>>> > > >>>> Aborted > > >>>> danielb at danielb-desktop:~/as207/code/m3gdb$ > > >>>> > > >>>> The assert violated in > > >>> m3core/thread/PTHREAD/ThreadPthread.m3 is > this: > > >>>> PROCEDURE ProcessOther (act: Activation; p: > > >>> PROCEDURE (start, > > >>>> stop: ADDRESS)) = > > >>>> (* LL=activeMu *) > > >>>> VAR > > >>>> sp: ADDRESS; > > >>>> state: RTMachine.ThreadState; > > >>>> BEGIN > > >>>> <*ASSERT act.state = ActState.Stopped*> > > >>>> > > >>>> > > >>>> The source code of the little program is > this: > > >>>> > > >>>> MODULE Main; > > >>>> > > >>>> IMPORT SIO; > > >>>> IMPORT RTHeapStats; > > >>>> IMPORT RTutils; > > >>>> IMPORT RTHeapDebug; > > >>>> VAR > > >>>> varA, varB, varC: INTEGER; > > >>>> > > >>>> > > >>>> PROCEDURE multiplicar(a,b: INTEGER): INTEGER= > > >>>> VAR > > >>>> varC: INTEGER; > > >>>> BEGIN > > >>>> varC:=a*b; > > >>>> RETURN varC; > > >>>> END multiplicar; > > >>>> > > >>>> > > >>>> BEGIN > > >>>> > > >>>> SIO.PutText("Entre dos enteros"); > > >>>> varA:=SIO.GetInt(); > > >>>> varB:=SIO.GetInt(); > > >>>> varC:=multiplicar(varA,varB); > > >>>> SIO.PutText("Estadisticas del Heap"); > > >>>> RTHeapDebug.CheckHeap(); > > >>>> RTHeapStats.ReportReachable(); > > >>>> (* RTutils.Heap > > >>>> > > >>> > > >> > > > > (FALSE,RTutils.HeapPresentation.ByTypecode,TRUE,LAST(CARDINAL));*) > > >>>> SIO.PutInt(varC); > > >>>> > > >>>> END Main. > > >>>> > > >>>> According to the draft book of Michael > Dagenais > > >>> Building > > >>>> Distributed OO Applications: Modula-3 Objects > > >> at > > >>> Work, > > >>>> RTHeapStats.ReportReachable() > > >>>> " ... is called to determine the number > > >>>> of active, reachable, objects (i.e. those > which > > >>> would not be > > >>>> garbage collected). Of the 1980 objects on > the > > >>> heap, only slightly > > >>>> more than half are still alive." > > >>>> > > >>>> According to the interface documentation: > > >>>> "reports the number of reachable objects and > > >>> bytes from each > > >>>> compilation unit, thread stack, and the > > >> individual > > >>> roots that reach > > >>>> the most bytes. The report is written to > stderr. > > >>> The Modula-3 > > >>>> process is frozen during the scanning and > > >>> reporting." > > >>>> > > >>>> Obviously with the previous version of > pthread > > >> the > > >>> things were > > >>>> working fine, also with user level > > >> implementation > > >>>> > > >>>> Thanks, > > >>>> > > >>>> Daniel Benavides > > > > > > ?Descubre una nueva forma de obtener respuestas a > tus preguntas! > > Entra en Yahoo! Respuestas. > > ______________________________________________ ?Chef por primera vez? S? un mejor Cocinillas. http://es.answers.yahoo.com/info/welcome From lemming at henning-thielemann.de Thu Nov 29 08:08:03 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 08:08:03 +0100 (MET) Subject: [M3devel] Disabling runtime checks Message-ID: I remember that it was already discussed. I found this one: http://groups.google.de/group/comp.lang.modula3/browse_thread/thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check but it seems to be out of date. So once again: How can I disable checks on overflow, array bound violation, NIL pointer etc. in cm3 for the sake of speed? I hoped that '-A' (disable code generation for assertions) would do it, since these checks are like built-in ASSERTs, but I was wrong. From lemming at henning-thielemann.de Thu Nov 29 10:14:21 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 10:14:21 +0100 (MET) Subject: [M3devel] Disabling runtime checks In-Reply-To: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: On Thu, 29 Nov 2007, Mika Nystrom wrote: > For PM3/m3build you can check > > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet! cm3 supports m3_option quake command, but it accepts only the command line options. > Counter-question: does anyone have CM3 working well on Windows? I > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on > Windows 2k/Cygwin. By "well" I mean that everything (including > Network Objects) has to work... I don't know about all the M3 libraries but I could get my stuff to work, including three foreign libraries. http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip From jay.krell at cornell.edu Thu Nov 29 10:23:31 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 09:23:31 +0000 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: <200711290822.lAT8MgB4063461@camembert.async.caltech.edu> Message-ID: I also don't know about all the M3 libraries either, but it can build itself, repeatedly. I know I can start some of the netobj stuff but I don't have a "real" test case. I have the following built from source, should be "easy" for anyone to do so: C:\cm3\bin>dir /b *.exe *.dll /wCalculator.execm3-d5.5.0.execm3.execmpdir.exeCube.exeDeckScape.exedirfp.exefisheye.exefix_nl.exeformsedit.exeJuno.exem3browser.exem3bundle.exem3tohtml.exem3totex.exem3zume.exementor.exemklib.exenetobjd.exeobliq-anim.exeobliq-min.exeobliq-std.exeobliq-ui.exeobliqsrv-std.exeobliqsrv-ui.exeRehearseCode.exereplayheap.exeshobjcodegen.exeshowheap.exeshownew.exeshowthread.exestablegen.exestubgen.exevisobliq.exevocgi.exevoquery.exevorun.exeWebScape.exeanim3D.dllbinIO.dllBitVector.dllcmvbt.dlldb.dlldebug.dlldeepcopy.dllDiGraph.dllembutils.dllevents.dllGeometry.dllhttp.dlljuno-compiler.dlljuno-machine.dlljvideo.dlllibbuf.dlllibsio.dlllistfuncs.dllm3.dllm3codeview.dllm3core.dllm3formsvbt.dllm3formsvbtpixmaps.dllm3markup.dllm3mg.dllm3mgkit.dllm3netobj.dllm3parseparams.dllm3scan.dllm3slisp.dllm3smalldb.dllm3tcl.dllm3tcp.dllm3tk-misc.dllm3tk.dllm3ui.dllm3vbtkit.dllm3zeus.dllmetasyn.dllobliq.dllobliqlibanim.dllobliqlibemb.dllobliqlibm3.dllobliqlibui.dllobliqparse.dllobliqprint.dllobliqrt.dllodbc.dllopengl.dllpatternmatching.dllrdwr.dllserialio.dllset.dllsgml.dllsharedobj.dllSortedTableExtras.dllstable.dllsynex.dllsynwr.dlltable-list.dllTempFiles.dllUDP.dllvideovbt.dllweb.dllwebvbt.dll Bolded what /think/ is relevant. I'm /still/ looking into the int64 stuff... - Jay > Date: Thu, 29 Nov 2007 10:14:21 +0100> From: lemming at henning-thielemann.de> To: mika at async.caltech.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] Disabling runtime checks> > > On Thu, 29 Nov 2007, Mika Nystrom wrote:> > > For PM3/m3build you can check> >> > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html> >> > Does CM3 have this stuff? I don't know... I don't really use CM3.. yet!> > cm3 supports m3_option quake command, but it accepts only the command line> options.> > > Counter-question: does anyone have CM3 working well on Windows? I> > am using PM3/Klagenfurt (on 44 "floppies") with CM3 libraries on> > Windows 2k/Cygwin. By "well" I mean that everything (including> > Network Objects) has to work...> > I don't know about all the M3 libraries but I could get my stuff to work,> including three foreign libraries.> > http://users.informatik.uni-halle.de/~thielema/Research/modula3wavelet.zip _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 12:15:34 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 11:15:34 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: please confirm my understanding I don't feel great being a lone reader/changer of code esp. that I didn't write and that lacks sufficient documentation for my small brain/confidence. (I'm not stupid, but this isn't trivial stuff either.) I am bound to make mistakes. In the context of Modula-3 code gen interfaces, and the word interfaces, which apparently are identical/analogous/whatever: There is: Shift (aka, my bad naming, "generic" shift)LeftShiftRightShift LeftShift and RightShift allow only positive shift counts, 0 .. 31 or 0 .. 63 (given particular word sizes and depending on types..) The "front end" checks constants against these.The "front end" inserts checks for variables against these.The back end can assume 0 .. 31 or 0 .. 63. It looks like the x86 back end does redundant masks against 31, at least when shifting by a constant, only in its own data, not in the codegen. Just a small waste of time in the compiler, no negative affect on codegen. "generic" Shift accepts any number for a shift count.Negative numbers mean a right shift.Positive numbers mean a left shift.If the shift count is >31|63 or <-31|63, the result is not an error, but zero. In all cases, right shifts are unsigned, zero filling. There is no shift operation that propagates the sign bit.In the Modula-3 language even. Perhaps, yes, integer division. But the frontend does not optimizethere and turn multiplication or division into shifts, I think, haven't read much of the frontend. The backend could. Rotate is presumably similar, but I have not looked at it.(LeftRotate, RightRotate, Rotate...) m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, very redundanty code, could be combined. The layering is /roughly/ m3x86 on top stackx86 in the middle codex86 at the bottom However m3x86 does call through to codex86 directly.They are largely one layer. There is no strict division."stack" is a simple way to implement some optimizations and stategiesaround constant propagation and register allocation. It is a stack of "operands", which may be constants, globals, or locals.If something is needed in a register, a register will be freed up.If something is later needed and the register hasn't been spilled, it will be reused. If not, not. Presently the operands are assumed to be of word size, 32 bits, register size.That is largely a convenience, and very convenient.I will expand it to allow two word operands.It could be expanded to arbitrarily, at least to "fill" "all" the registers, for some not particularly interesting but theoretically useful scenarios -- passing "medium" sized structs around by value or such. There are ABI concerns though, this could only be amongst local functions that aren't visible/used externally (aka "custom calling conventions"). The "generic" shift (vs. left_shift, right_shift) is implemented in stackx86while left_shift, right_shift are in m3x86. All three functions are very similar,could be combined, and there is no good reason for some to be in one layervs. the other and it's a just a pointless inconsistency. Granted, "generic" shift is a good bit different, it has to check the sign and the magnitude,whereas left and right can just blindly do the operation with no comparisons or branches. Some of this I gather from attempting to compile code with shifts -- esp. the frontend checking of stuff, which then lead me to look at word.i3which declares subranges for the parameters. Is Bill Kalsow around?Or the other original authors?Everyone just figured stuff out from the code, comments, and "literature" (I ordered another copy of Nelson's good book. :) ) - Jay _________________________________________________________________ Connect and share in new ways with Windows Live. http://www.windowslive.com/connect.html?ocid=TXT_TAGLM_Wave2_newways_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Thu Nov 29 13:41:12 2007 From: jay.krell at cornell.edu (Jay) Date: Thu, 29 Nov 2007 12:41:12 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: At one point Linux/x86 didn't use gcc, right? It used the same as the Win32/x86 backend? Anyway, on Win32/x86, small functions like: PROCEDURE F5(b : INTEGER) : INTEGER =BEGIN RETURN Word.Shift(0, b);END F5; result in: _T__F5: 004010C2: 55 push ebp 004010C3: 8B EC mov ebp,esp 004010C5: 81 EC 04 00 00 00 sub esp,4 004010CB: 53 push ebx 004010CC: 56 push esi 004010CD: 57 push edi 004010CE: 33 C0 xor eax,eax 004010D0: 5F pop edi 004010D1: 5E pop esi 004010D2: 5B pop ebx 004010D3: C9 leave 004010D4: C3 ret Now, I can grant that having a consistent frame is nice for stack walkability in a debugger in the absence of symbols, so I won't argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure leave is the state of the art, need to compare to current compiler output). But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. Doesn't it? Looking at the code, and how it avoids having multiple passes, it should be easy to at least track which registers are used, and go back and nop out the pushes, and avoid the pops entirely. Or possibly to move the function ahead up to three bytes, leaving three bytes of padding -- being sure to test recursive code..except anything with a function call, maybe leave alone. I ASSUME nop is faster than push, esp. when combined with saving the pops entirely, ESP. when there are presumably two and three byte nops, so the instruction count can be dropped, even if the byte count cannot easily. Thoughts? Nobody cares 'cause everyone else is using gcc and it handles these things well? - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Thu Nov 29 16:47:40 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:47:40 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <7670DE57-26E8-4A2B-9169-1B77E80C610A@cs.purdue.edu> m3_option("-NoChecks") should do it. For assertions use m3_option("-NoAsserts"). On Nov 29, 2007, at 2:08 AM, Henning Thielemann wrote: > > I remember that it was already discussed. I found this one: > http://groups.google.de/group/comp.lang.modula3/browse_thread/ > thread/5b7cfe805da66f0b/7182f91c5e6e893d?hl=de&lnk=gst&q=range+check > but it seems to be out of date. So once again: How can I disable > checks > on overflow, array bound violation, NIL pointer etc. in cm3 for the > sake > of speed? I hoped that '-A' (disable code generation for assertions) > would do it, since these checks are like built-in ASSERTs, but I was > wrong. From hosking at cs.purdue.edu Thu Nov 29 16:59:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 10:59:26 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 6:15 AM, Jay wrote: > please confirm my understanding > > I don't feel great being a lone reader/changer of code esp. that I > didn't write and that lacks > sufficient documentation for my small brain/confidence. (I'm not > stupid, but this isn't trivial stuff either.) If you are talking about the native x86 (non-gcc) backend then I concur that it is pretty unreadable. Hence my lack of enthusiasm in working on it myself. > I am bound to make mistakes. We all do! > In the context of Modula-3 code gen interfaces, and the word > interfaces, which apparently are identical/analogous/whatever: > > There is: > > Shift (aka, my bad naming, "generic" shift) Yes, shift by n>0 is shift left. n<0 is shift right. > LeftShift > RightShift > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > or 0 .. 63 (given > particular word sizes and depending on types..) > The "front end" checks constants against these. > The "front end" inserts checks for variables against these. > The back end can assume 0 .. 31 or 0 .. 63. Yes, depending on word-size. > It looks like the x86 back end does redundant masks against 31, at > least when shifting by a constant, > only in its own data, not in the codegen. Just a small waste of > time in the compiler, no negative affect on codegen. > > "generic" Shift accepts any number for a shift count. > Negative numbers mean a right shift. > Positive numbers mean a left shift. > If the shift count is >31|63 or <-31|63, the result is not an > error, but zero. Yes. > In all cases, right shifts are unsigned, zero filling. Yes. > There is no shift operation that propagates the sign bit. > In the Modula-3 language even. Perhaps, yes, integer division. But > the frontend does not optimize > there and turn multiplication or division into shifts, I think, > haven't read much of the frontend. The backend could. Correct. I think the thinking was that a decent back-end would turn integer division by a power of 2 into an arithmetic right shift (the gcc backend certainly does). > Rotate is presumably similar, but I have not looked at it. > (LeftRotate, RightRotate, Rotate...) Weird thing with these is the way the high/low bits are rotated around, so sign can change! > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > very redundanty code, could be combined. > > The layering is /roughly/ > m3x86 on top > stackx86 in the middle > codex86 at the bottom > > However m3x86 does call through to codex86 directly. > They are largely one layer. There is no strict division. > "stack" is a simple way to implement some optimizations and stategies > around constant propagation and register allocation. > > It is a stack of "operands", which may be constants, globals, or > locals. > If something is needed in a register, a register will be freed up. > If something is later needed and the register hasn't been spilled, > it will be > reused. If not, not. > > Presently the operands are assumed to be of word size, 32 bits, > register size. > That is largely a convenience, and very convenient. > I will expand it to allow two word operands. > It could be expanded to arbitrarily, at least to "fill" "all" the > registers, for some > not particularly interesting but theoretically useful scenarios -- > passing "medium" > sized structs around by value or such. There are ABI concerns > though, this could > only be amongst local functions that aren't visible/used > externally (aka "custom calling conventions"). You can make some assumptions about how the front-end uses the middle- end interfaces. For example, it only ever stacks integer things as 32 or 64 bits, even if the integers have a memory representation that is 8 bits, etc. > The "generic" shift (vs. left_shift, right_shift) is implemented in > stackx86 > while left_shift, right_shift are in m3x86. All three functions are > very similar, > could be combined, and there is no good reason for some to be in > one layer > vs. the other and it's a just a pointless inconsistency. > > Granted, "generic" shift is a good bit different, it has to check > the sign and the magnitude, > whereas left and right can just blindly do the operation with no > comparisons or branches. > > Some of this I gather from attempting to compile code with shifts > -- esp. the frontend checking of stuff, which then lead me to look > at word.i3 > which declares subranges for the parameters. > > Is Bill Kalsow around? Good question. Farshad Nayeri may know where he ended up. > Or the other original authors? I know Michel Dagenais had a student who adapted the native x86 backend for use on Linux with PM3. I don't remember the student's name. > Everyone just figured stuff out from the code, comments, and > "literature" (I ordered another copy of Nelson's good book. :) ) > > > - Jay > > > Connect and share in new ways with Windows Live. Connect now! From hosking at cs.purdue.edu Thu Nov 29 17:02:42 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 11:02:42 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> On Nov 29, 2007, at 7:41 AM, Jay wrote: > At one point Linux/x86 didn't use gcc, right? It used the same as > the Win32/x86 backend? > > Anyway, on Win32/x86, small functions like: > > PROCEDURE F5(b : INTEGER) : INTEGER = > BEGIN > RETURN Word.Shift(0, b); > END F5; > > result in: > > _T__F5: > 004010C2: 55 push ebp > 004010C3: 8B EC mov ebp,esp > 004010C5: 81 EC 04 00 00 00 sub esp,4 > 004010CB: 53 push ebx > 004010CC: 56 push esi > 004010CD: 57 push edi > 004010CE: 33 C0 xor eax,eax > 004010D0: 5F pop edi > 004010D1: 5E pop esi > 004010D2: 5B pop ebx > 004010D3: C9 leave > 004010D4: C3 ret > > Now, I can grant that having a consistent frame is nice for stack > walkability in a debugger in the absence of symbols, so I won't > argue about push ebp, mov ebp, esp, sub esp,4, leave. (not sure > leave is the state of the art, need to compare to current compiler > output). > > But, this constant push ebx/esi/edi, pop edi/esi/ebx seems dumb. > Doesn't it? > > Looking at the code, and how it avoids having multiple passes, it > should be easy to at least track which registers are used, and go > back and nop out the pushes, and avoid the pops entirely. > > Or possibly to move the function ahead up to three bytes, leaving > three bytes of padding -- being sure to test recursive code..except > anything with a function call, maybe leave alone. I ASSUME nop is > faster than push, esp. when combined with saving the pops entirely, > ESP. when there are presumably two and three byte nops, so the > instruction count can be dropped, even if the byte count cannot > easily. > > Thoughts? Sounds reasonable. Having glanced at the native x86 backend I believe it really needs a good shake-out to bring it up to speed. > Nobody cares 'cause everyone else is using gcc and it handles these > things well? I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. > > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! :-) From rcolebur at scires.com Thu Nov 29 19:30:46 2007 From: rcolebur at scires.com (Randy Coleburn) Date: Thu, 29 Nov 2007 13:30:46 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> Message-ID: <474EBF06.1E75.00D7.1@scires.com> I am willing to help test stuff on the Windows platform, but I won't be much help with low-level stuff like what Jay is doing now. I have a working cm3 v4.1 on Windows. I tried a few weeks ago to get the "current" cm3 working on Windows, but ran into trouble. I say "current" in quotes, because I was downloading the tarballs. I presume there is more recent stuff avail via CVS. Can someone let me know how to check out the latest "stable" sources from CVS? I'll give it another try if someone can point me to the right code. If stuff breaks, I can provide feedback. Also, if I can get the new cm3 working on Windows, I should be able to complete the work on getting the CM3IDE (aka Reactor) ready for release. Regards, Randy Randy C. Coleburn, CISSP Senior Systems Engineer, Communications, Networks, & Electronics Division (CNE) Corporate & Atlanta Information Systems Security Manager (ISSM) Scientific Research Corporation 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) 989-9497 Quality Policy: "SRC CNE Division is committed to delivering continually improving research & engineering excellence that meets or exceeds customer requirements." >>> Tony Hosking 11/29/2007 11:02 AM >>> > At one point Linux/x86 didn't use gcc, right? It used the same as I haven't tried the CygWin (gcc-backend) based build of CM3 for Windows, but clearly we need a good story for Windows-based CM3. Jay you have done a great job keeping this branch of the system alive. I certainly hope you can keep it up. Not being a Windows user myself, I do lack the incentive (and expertise) to keep things going for Windows. That's why we need people like you to help out. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 4492 bytes Desc: S/MIME Cryptographic Signature URL: From hosking at cs.purdue.edu Thu Nov 29 21:11:59 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 15:11:59 -0500 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <474EBF06.1E75.00D7.1@scires.com> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> Message-ID: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote: > I am willing to help test stuff on the Windows platform, but I > won't be much help with low-level stuff like what Jay is doing now. > > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > get the "current" cm3 working on Windows, but ran into trouble. I > say "current" in quotes, because I was downloading the tarballs. I > presume there is more recent stuff avail via CVS. > > Can someone let me know how to check out the latest "stable" > sources from CVS? I'll give it another try if someone can point me > to the right code. If stuff breaks, I can provide feedback. Jay is probably your best resource on this. > Also, if I can get the new cm3 working on Windows, I should be > able to complete the work on getting the CM3IDE (aka Reactor) ready > for release. That would be very cool! > > Regards, > Randy > > Randy C. Coleburn, CISSP > Senior Systems Engineer, Communications, Networks, & Electronics > Division (CNE) > Corporate & Atlanta Information Systems Security Manager (ISSM) > Scientific Research Corporation > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339 > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > 989-9497 > > Quality Policy: "SRC CNE Division is committed to delivering > continually improving research & engineering excellence that meets > or exceeds customer requirements." > > >>> Tony Hosking 11/29/2007 11:02 AM >>> > > At one point Linux/x86 didn't use gcc, right? It used the same as > I haven't tried the CygWin (gcc-backend) based build of CM3 for > Windows, but clearly we need a good story for Windows-based CM3. Jay > you have done a great job keeping this branch of the system alive. I > certainly hope you can keep it up. Not being a Windows user myself, > I do lack the incentive (and expertise) to keep things going for > Windows. That's why we need people like you to help out. > From lemming at henning-thielemann.de Thu Nov 29 21:43:49 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Thu, 29 Nov 2007 21:43:49 +0100 (CET) Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: On Thu, 29 Nov 2007, Tony Hosking wrote: > m3_option("-NoChecks") should do it. Is this documented somewhere? > For assertions use m3_option("-NoAsserts"). $ cm3 -O -A -keep unsupported m3_option value: "-NoChecks" Sorry, it's not the newest version: $ cm3 -version Critical Mass Modula-3 version 5.2.6 last updated: 2003-06-27 configuration: /usr/local/cm3/bin/cm3.cfg From hosking at cs.purdue.edu Thu Nov 29 22:06:26 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 16:06:26 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: Hmmm... On Nov 29, 2007, at 3:43 PM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? > >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" > > > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg From wagner at elegosoft.com Thu Nov 29 23:08:58 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Thu, 29 Nov 2007 23:08:58 +0100 Subject: [M3devel] Disabling runtime checks In-Reply-To: References: Message-ID: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Quoting Henning Thielemann : > > On Thu, 29 Nov 2007, Tony Hosking wrote: > >> m3_option("-NoChecks") should do it. > > Is this documented somewhere? Actually yes, it is: http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html But I'm afraid that the documentation hasn't been updated for CM3 5.x in this respect, as Critical Mass never release it and Michael and I simply had not the resources to check every detail. So it will be out of date :-( >> For assertions use m3_option("-NoAsserts"). > > $ cm3 -O -A -keep > unsupported m3_option value: "-NoChecks" That's what I meant ;-/ > Sorry, it's not the newest version: > > $ cm3 -version > Critical Mass Modula-3 version 5.2.6 > last updated: 2003-06-27 > configuration: /usr/local/cm3/bin/cm3.cfg Later does not necessary mean better documented. A quick grep through the code does produce this though: .../cm3/m3-sys/m3front/src/misc/Host.m3 ELSIF (Text.Equal (t, "-NoChecks")) THEN doAsserts := FALSE; doNarrowChk := FALSE; doRangeChk := FALSE; doReturnChk := FALSE; doCaseChk := FALSE; doTCaseChk := FALSE; doNilChk := FALSE; doRaisesChk := FALSE; doDebugs := FALSE; So actually it seems like it should work; perhaps only the m3_option embedding is broken. ... It seems to be set from M3_OPTIONS in cm3.cfg: s.m3_options := GetConfigArray (s, "M3_OPTIONS"); So I'd try to set it there. Perhaps cm3 -D'M3_OPTIONS=[ "NoChecks" ]" will work, too. Olaf -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From hosking at cs.purdue.edu Fri Nov 30 00:19:05 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Thu, 29 Nov 2007 18:19:05 -0500 Subject: [M3devel] Disabling runtime checks In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <9DDF7EB7-803E-4781-8139-06BFCD2D4F78@cs.purdue.edu> On Nov 29, 2007, at 5:08 PM, Olaf Wagner wrote: > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" Ah, yes, that seems to be the trick. I think you can do: cm3 -DM3_OPTIONS="-NoChecks" as well. > > will work, too. > > Olaf > -- > Olaf Wagner -- elego Software Solutions GmbH > Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, > Germany > phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 > 45 86 95 > http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: > Berlin > Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: > DE163214194 > From jay.krell at cornell.edu Fri Nov 30 02:22:09 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:22:09 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: I haven't tried this in a few weeks, but the following should work. This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever. It is not particularly current, but it should work, by design and by my latest testing. (Until such time as a newer distribution is available, I assume a need to bootstrap from this, but perhaps not anything older). Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:28:12 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:28:12 +0000 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: Thanks! It helps to know I'm understanding things correctly. The backend isn't bad really, it's written by someone who very much knew what they were doing, which is necessary. > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that Understood. Actually, btw, the front/middleend could do more easy optimizations, like some of the ones I already commited, and really, all the constant propagation that m3x86.m3 does, via its stack stuff and remembering if something is "immediate". I should look into that some time....... - Jay > From: hosking at cs.purdue.edu> Date: Thu, 29 Nov 2007 10:59:26 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] "please confirm my understanding"> > > On Nov 29, 2007, at 6:15 AM, Jay wrote:> > > please confirm my understanding> >> > I don't feel great being a lone reader/changer of code esp. that I > > didn't write and that lacks> > sufficient documentation for my small brain/confidence. (I'm not > > stupid, but this isn't trivial stuff either.)> > If you are talking about the native x86 (non-gcc) backend then I > concur that it is pretty unreadable. Hence my lack of enthusiasm in > working on it myself.> > > I am bound to make mistakes.> > We all do!> > > In the context of Modula-3 code gen interfaces, and the word > > interfaces, which apparently are identical/analogous/whatever:> >> > There is:> >> > Shift (aka, my bad naming, "generic" shift)> > Yes, shift by n>0 is shift left. n<0 is shift right.> > > LeftShift> > RightShift> >> > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > or 0 .. 63 (given> > particular word sizes and depending on types..)> > The "front end" checks constants against these.> > The "front end" inserts checks for variables against these.> > The back end can assume 0 .. 31 or 0 .. 63.> > Yes, depending on word-size.> > > It looks like the x86 back end does redundant masks against 31, at > > least when shifting by a constant,> > only in its own data, not in the codegen. Just a small waste of > > time in the compiler, no negative affect on codegen.> >> > "generic" Shift accepts any number for a shift count.> > Negative numbers mean a right shift.> > Positive numbers mean a left shift.> > If the shift count is >31|63 or <-31|63, the result is not an > > error, but zero.> > Yes.> > > In all cases, right shifts are unsigned, zero filling.> > Yes.> > > There is no shift operation that propagates the sign bit.> > In the Modula-3 language even. Perhaps, yes, integer division. But > > the frontend does not optimize> > there and turn multiplication or division into shifts, I think, > > haven't read much of the frontend. The backend could.> > Correct. I think the thinking was that a decent back-end would turn > integer division by a power of 2 into an arithmetic right shift (the > gcc backend certainly does).> > > Rotate is presumably similar, but I have not looked at it.> > (LeftRotate, RightRotate, Rotate...)> > Weird thing with these is the way the high/low bits are rotated > around, so sign can change!> > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift,> > very redundanty code, could be combined.> >> > The layering is /roughly/> > m3x86 on top> > stackx86 in the middle> > codex86 at the bottom> >> > However m3x86 does call through to codex86 directly.> > They are largely one layer. There is no strict division.> > "stack" is a simple way to implement some optimizations and stategies> > around constant propagation and register allocation.> >> > It is a stack of "operands", which may be constants, globals, or > > locals.> > If something is needed in a register, a register will be freed up.> > If something is later needed and the register hasn't been spilled, > > it will be> > reused. If not, not.> >> > Presently the operands are assumed to be of word size, 32 bits, > > register size.> > That is largely a convenience, and very convenient.> > I will expand it to allow two word operands.> > It could be expanded to arbitrarily, at least to "fill" "all" the > > registers, for some> > not particularly interesting but theoretically useful scenarios -- > > passing "medium"> > sized structs around by value or such. There are ABI concerns > > though, this could> > only be amongst local functions that aren't visible/used > > externally (aka "custom calling conventions").> > You can make some assumptions about how the front-end uses the middle- > end interfaces. For example, it only ever stacks integer things as > 32 or 64 bits, even if the integers have a memory representation that > is 8 bits, etc.> > > The "generic" shift (vs. left_shift, right_shift) is implemented in > > stackx86> > while left_shift, right_shift are in m3x86. All three functions are > > very similar,> > could be combined, and there is no good reason for some to be in > > one layer> > vs. the other and it's a just a pointless inconsistency.> >> > Granted, "generic" shift is a good bit different, it has to check > > the sign and the magnitude,> > whereas left and right can just blindly do the operation with no > > comparisons or branches.> >> > Some of this I gather from attempting to compile code with shifts > > -- esp. the frontend checking of stuff, which then lead me to look > > at word.i3> > which declares subranges for the parameters.> >> > Is Bill Kalsow around?> > Good question. Farshad Nayeri may know where he ended up.> > > Or the other original authors?> > I know Michel Dagenais had a student who adapted the native x86 > backend for use on Linux with PM3. I don't remember the student's name.> > > Everyone just figured stuff out from the code, comments, and > > "literature" (I ordered another copy of Nelson's good book. :) )> >> >> > - Jay> >> >> > Connect and share in new ways with Windows Live. Connect now!> _________________________________________________________________ You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. http://im.live.com/messenger/im/home/?source=TAGLM -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:31:49 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:31:49 +0000 Subject: [M3devel] win32/x86 prolog/epilog In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> <09655FDA-C60F-4AC5-A485-8D05F1FDB983@cs.purdue.edu> <474EBF06.1E75.00D7.1@scires.com> <75D32A76-572E-4855-98D7-7250B86F1546@cs.purdue.edu> Message-ID: oops C:\net\modula3>tar tf cm3-min-WIN32-NT386-5.2.6.tar.bz2 cm3-min-WIN32-NT386-5.2.6/ cm3-min-WIN32-NT386-5.2.6/cminstall.exe cm3-min-WIN32-NT386-5.2.6/COPYRIGHT-CMASS cm3-min-WIN32-NT386-5.2.6/cygwin.dll cm3-min-WIN32-NT386-5.2.6/gzip.exe cm3-min-WIN32-NT386-5.2.6/system.tgz cm3-min-WIN32-NT386-5.2.6/tar.exe It is system.tgz that can be extracted into c:\cm3. You can dispense with the rest. Older versions of tar, such as the one in this distribution, require the z flag. Newer ones do not. - Jay From: jay.krell at cornell.eduTo: hosking at cs.purdue.edu; rcolebur at scires.comDate: Fri, 30 Nov 2007 01:22:09 +0000CC: m3devel at elegosoft.comSubject: Re: [M3devel] win32/x86 prolog/epilog I haven't tried this in a few weeks, but the following should work.This is all from memory off the cuff and bound to have some errors. Get the latest tarball binary distribution, cm3-min-WIN32-NT386-5.2.6.tar.gz or whatever.It is not particularly current, but it should work, by design and by my latest testing. (Until suchtime as a newer distribution is available, I assume a need to bootstrap from this, but perhapsnot anything older).Checkout the latest cvs code. I'm not familiar with cvs branching, so that should guide you to the right branch. :) Since Unix "steals" \dev. I use \dev2. CM3 is at c:\dev2\cm3 for me and paths below will reflect that. And I "install" it to c:\cm3. e.g. c:\cm3\bin\cm3.exe. You don't need to use the "install" any longer (with a compromise, that I declare worthwhile, until objections are raised and debated. :) ). You can do like: mkdir c:\cm3 cd /d c:\cm3 tar xf cm3-min-WIN32-NT386-5.2.6.tar.gz copy the nt386 config file from cvs to c:\cm3\bin\cm3.cfg e.g. copy C:\dev2\cm3\m3-sys\cminstall\src\config\NT386 c:\cm3\bin\cm3.cfg setup your C++ compiler environment, such as by running vcvars32.bat or vsvars32.bat or such, it is on your start menu I have provided my own set of rewritten/wrappers (they are in my hosted subversion so actually I could grant access..): C:\dev2\j\env\cm3\cm3.vc80.bat It is the running of vcvars32.bat/vsvars32.bat that largely replaces cminstall. and then, here is where I get confused, but upgrade and make-dist are both good. upgrade had bitrotted recently I but I think is good now. cd /d c:\dev2\cm3\scripts\win upgrade or make-dist and if you run make-dist, look near the end of the output, it will produce a new .tar.gz or .tar.bz2, you can rmdir /q/s your \cm3 and extract this on top of it it. OR poke around in my home directory at elelgosoft and there is such a distribution. Can someone please make it available for public download? The smile thing is Hotmail's automatic signature, not my doing, sorry. - Jay > CC: jay.krell at cornell.edu; m3devel at elegosoft.com> From: hosking at cs.purdue.edu> Subject: Re: [M3devel] win32/x86 prolog/epilog> Date: Thu, 29 Nov 2007 15:11:59 -0500> To: rcolebur at scires.com> > > On Nov 29, 2007, at 1:30 PM, Randy Coleburn wrote:> > > I am willing to help test stuff on the Windows platform, but I > > won't be much help with low-level stuff like what Jay is doing now.> >> > I have a working cm3 v4.1 on Windows. I tried a few weeks ago to > > get the "current" cm3 working on Windows, but ran into trouble. I > > say "current" in quotes, because I was downloading the tarballs. I > > presume there is more recent stuff avail via CVS.> >> > Can someone let me know how to check out the latest "stable" > > sources from CVS? I'll give it another try if someone can point me > > to the right code. If stuff breaks, I can provide feedback.> > Jay is probably your best resource on this.> > > Also, if I can get the new cm3 working on Windows, I should be > > able to complete the work on getting the CM3IDE (aka Reactor) ready > > for release.> > That would be very cool!> > >> > Regards,> > Randy> >> > Randy C. Coleburn, CISSP> > Senior Systems Engineer, Communications, Networks, & Electronics > > Division (CNE)> > Corporate & Atlanta Information Systems Security Manager (ISSM)> > Scientific Research Corporation> > 2300 Windy Ridge Parkway, Suite 400 South, Atlanta, Georgia 30339> > voice: (770) 989-9464, email: RColeburn at SciRes.com, fax: (770) > > 989-9497> >> > Quality Policy: "SRC CNE Division is committed to delivering > > continually improving research & engineering excellence that meets > > or exceeds customer requirements."> >> > >>> Tony Hosking 11/29/2007 11:02 AM >>>> > > At one point Linux/x86 didn't use gcc, right? It used the same as> > I haven't tried the CygWin (gcc-backend) based build of CM3 for> > Windows, but clearly we need a good story for Windows-based CM3. Jay> > you have done a great job keeping this branch of the system alive. I> > certainly hope you can keep it up. Not being a Windows user myself,> > I do lack the incentive (and expertise) to keep things going for> > Windows. That's why we need people like you to help out.> >> You keep typing, we keep giving. Download Messenger and join the i?m Initiative now. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:48:36 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:48:36 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <036701c83256$d553bbf0$7ffb33d0$@com> References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 02:59:43 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 01:59:43 +0000 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. x86 only. - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 01:48:36 +0000Subject: [M3devel] some more notes on the win32 system some more notes on the win32 system> setup your C++ compiler/linkerYou can/should "play dumb", skip that, and just run upgrade.See what errors you get.I tried to put in the right amount of up front sanity checking.What you need in particular arecl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%.If using VS2005 (8) or newer, mt on the path.%LIB% is a semicolon delimited list of directories.That is a feature of the Microsoft linker.msvcrt.lib must be in one of them.Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work.I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd).I use 8.0 the most lately.I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txtOn computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Share life as it happens with the new Windows Live.Download today it's FREE! http://www.windowslive.com/share.html?ocid=TXT_TAGLM_Wave2_sharelife_112007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 08:28:16 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 07:28:16 +0000 Subject: [M3devel] non-gcc backend Message-ID: I thought the last Digital release used the non-gcc backend for Linux x86. My mistake I see. The next thing to look into is the Critical Mass release, which I can't get to at the moment. - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 11:03:46 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 10:03:46 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: <20071130095354.8D45B10D4540@birch.elegosoft.com> References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...) Note that currently you have to use Visual C++ 6.0 or newer. I tested 2.0, 6.0, 8.0. 2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...) I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so. I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From jay.krell at cornell.edu Fri Nov 30 12:50:21 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 11:50:21 +0000 Subject: [M3devel] FW: fix win32 bootstrapping In-Reply-To: References: <20071130095354.8D45B10D4540@birch.elegosoft.com> Message-ID: Older than 6.0 should work now.. I probe the linker in sysinfo.cmd.. 7.1 Express which lacks msvcrt.lib should work now too, I probe for msvcrt.lib. The probing methods may be considered..not great..and "inspired" by autoconf..try stuff, see if it works, or sniff the error message (not sure if autoconf sniffs error messages). The testing remains..light. Stuff like run upgrade or do-pkg-core, not with all VC toolsets, not always going back to cm3 5.2.6. I've got 2.0,4.0,4.1,4.2,5.0,6.0,7.0,7.1, 8.0, sometimes just express, but not patience/time. The oldest officially supported by Microsoft I believe is 7.0. Really this is just a way to procrastinate on the int64 stuff and real work.. :( - Jay From: jay.krell at cornell.eduTo: m3devel at elegosoft.comDate: Fri, 30 Nov 2007 10:03:46 +0000Subject: [M3devel] FW: fix win32 bootstrapping m3-commit == m3devel? (I complained about the advertising in my signature, we'll see...)Note that currently you have to use Visual C++ 6.0 or newer.I tested 2.0, 6.0, 8.0.2.0 failed for a reason I forgot about, and is easily fixed -- it is the delayloading I put in cm3.cfg. Otherwise there are way more .dll loads than necessary, as m3core.dll is a bit bloated with Win32 wrappers or something. (Compare with msvcr*.dll that only depends on kernel32.dll, and maybe manually loads user32.dll to bring up assertion failures...)I'd like to make it automatically fallback, like either upon those errors, or if the linker version was rapidly queried, or %lib%\delayimp.lib rapidly checked for. I did like so.I have two open cmd windows. Just for command line history purposes. cmd#1 cd /d c:\cm3 rmdir /q/s . (nifty -- reports an error at the end, after deleting everything) tar xf ../net/modula3/system.tgz (the 5.2.6 release) copy /y \dev2\cm3\m3-sys\cminstall\src\config\NT386 \cm3\bin\cm3.cfg cmd#2 cd /d C:\dev2\cm3\scripts\win \dev2\j\env\cm3\cm3.vc80.bat which gives me: C:\dev2\cm3\scripts\win>set include INCLUDE=C:\msdev\80\VC\include;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Include C:\dev2\cm3\scripts\win>set lib LIB=C:\cm3\lib;C:\msdev\80\VC\lib;C:\Program Files\Microsoft Platform SDK for Windows Server 2003 R2\Lib C:\dev2\cm3\scripts\win>set path Path=C:\cm3\bin;C:\msdev\80\VC\BIN;C:\msdev\80\Common7\IDE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\bin upgrade which makes a new compiler, installs it, then new compiler and runtime, installs, then builds the "core" packages as defined by do-cm3-core.cmd. Again, note that make-dist was already working.. - Jay > Date: Fri, 30 Nov 2007 10:53:49 +0000> To: m3commit at elegosoft.com> From: jkrell at elego.de> Subject: [M3commit] CVS Update: cm3> > CVSROOT: /usr/cvs> Changes by: jkrell at birch. 07/11/30 10:53:49> > Modified files:> cm3/scripts/win/: backup-pkgs.cmd sysinfo.cmd upgrade.cmd > > Log message:> fix bootstrapping> > make-dist does work, so look at what it does..> > In particular, the old compiler cannot build> the new runtime. First build just the compiler,> and then use that to build the runtime.> > As well, backup-pkgs would complain about> most packages missing, ask you to build them,> but you can't. So only require libm3 and m3core,> which you must get from a binary release..> you must get them anyway, to build the new> compiler against, and you can't build them..> > As well, remove some warnings that seem irrelevant now,> as they say so themselves -- "generally automatic".> > As well, running upgrade twice in a row does not work,> unless we backup/restore the compiler along with the packages,> so do that too.> Your smile counts. The more smiles you share, the more we donate. Join in! _________________________________________________________________ Your smile counts. The more smiles you share, the more we donate.? Join in. www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline -------------- next part -------------- An HTML attachment was scrubbed... URL: From lemming at henning-thielemann.de Fri Nov 30 14:25:09 2007 From: lemming at henning-thielemann.de (Henning Thielemann) Date: Fri, 30 Nov 2007 14:25:09 +0100 (CET) Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: On Thu, 29 Nov 2007, Olaf Wagner wrote: > http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html Aha. > It seems to be set from M3_OPTIONS in cm3.cfg: > > s.m3_options := GetConfigArray (s, "M3_OPTIONS"); > > So I'd try to set it there. Perhaps > > cm3 -D'M3_OPTIONS=[ "NoChecks" ]" > > will work, too. $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: ) Fatal Error: package build failed But, the following works: $ cm3 -O -D'M3_OPTIONS+=-NoChecks' where there must be no space between = and -. Many thanks for the help! I'm trying to read the code that cm3 produces, because I thought that the simple loop I wrote needs too much time. I'm sitting in front of an Intel machine and I do not really understand the Intel assembly code (I'm used to Motorola :-), but according to the line numbering (.loc directive) it seems that 'ROUND' and friends needs lot of time. The count of assembly commands is reduced by -NoChecks but still around 20 commands. It seems that ROUND, FLOOR and CEILING are implemented manually (checks for negative numbers), whereas TRUNC is the shortest, but still about 9 commands. I do not know whether Intel processors have primitives for several rounding modes. From hosking at cs.purdue.edu Fri Nov 30 15:03:39 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:03:39 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Shouldn't Jay's notes go somewhere on the CM3 Web-site? On Nov 29, 2007, at 8:48 PM, Jay wrote: > some more notes on the win32 system > > > setup your C++ compiler/linker > > You can/should "play dumb", skip that, and just run upgrade. > See what errors you get. > I tried to put in the right amount of up front sanity checking. > > What you need in particular are > > cl and link on the %PATH%. > See, cminstall would have you specify full paths, my > configuration uses %PATH%. > If using VS2005 (8) or newer, mt on the path. > > %LIB% is a semicolon delimited list of directories. > That is a feature of the Microsoft linker. > msvcrt.lib must be in one of them. > > Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, > 7.0, 7.1, 8.0 -- should work. > I have tested all of them some and many required small changes in > one particular spot, > that actually is only used by "maintainers" (C:\dev2\cm3\m3-win > \import-libs\src\make-lib-1.cmd). > I use 8.0 the most lately. > I haven't done much with 9.0. > > Another thing, fairly redundant: > > C:\dev2\cm3\m3-win>more vcredist.txt > On computers without Visual C++ 2005 or CLR 2.0 installed, download > and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- > from either > > RTM (release to manufacturing): > http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE- > A3F9-4C13-9C99-220B62A191EE > > or Service Pack 1: > http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9- > ae1a-4a14-984d-389c36f85647 > > You can find those searching the web for vcredist, no real need to > recort the URLs. That's about it. > > - Jay > > Your smile counts. The more smiles you share, the more we donate. > Join in! From hosking at cs.purdue.edu Fri Nov 30 15:02:53 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:02:53 -0500 Subject: [M3devel] "please confirm my understanding" In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: On Nov 29, 2007, at 8:28 PM, Jay wrote: > Thanks! It helps to know I'm understanding things correctly. > > The backend isn't bad really, it's written by someone who very much > knew what they were doing, which is necessary. > > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > Understood. > > Actually, btw, the front/middleend could do more easy > optimizations, like some of the ones I already commited, and > really, all the constant propagation that m3x86.m3 does, via its > stack stuff and remembering if something is "immediate". I should > look into that some time....... I'd be leery of complicating the front/middle-ends with optimizations given that backends can do them (ie, gcc/m3x86). > > > - Jay > > > > From: hosking at cs.purdue.edu > > Date: Thu, 29 Nov 2007 10:59:26 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] "please confirm my understanding" > > > > > > On Nov 29, 2007, at 6:15 AM, Jay wrote: > > > > > please confirm my understanding > > > > > > I don't feel great being a lone reader/changer of code esp. that I > > > didn't write and that lacks > > > sufficient documentation for my small brain/confidence. (I'm not > > > stupid, but this isn't trivial stuff either.) > > > > If you are talking about the native x86 (non-gcc) backend then I > > concur that it is pretty unreadable. Hence my lack of enthusiasm in > > working on it myself. > > > > > I am bound to make mistakes. > > > > We all do! > > > > > In the context of Modula-3 code gen interfaces, and the word > > > interfaces, which apparently are identical/analogous/whatever: > > > > > > There is: > > > > > > Shift (aka, my bad naming, "generic" shift) > > > > Yes, shift by n>0 is shift left. n<0 is shift right. > > > > > LeftShift > > > RightShift > > > > > > LeftShift and RightShift allow only positive shift counts, 0 .. 31 > > > or 0 .. 63 (given > > > particular word sizes and depending on types..) > > > The "front end" checks constants against these. > > > The "front end" inserts checks for variables against these. > > > The back end can assume 0 .. 31 or 0 .. 63. > > > > Yes, depending on word-size. > > > > > It looks like the x86 back end does redundant masks against 31, at > > > least when shifting by a constant, > > > only in its own data, not in the codegen. Just a small waste of > > > time in the compiler, no negative affect on codegen. > > > > > > "generic" Shift accepts any number for a shift count. > > > Negative numbers mean a right shift. > > > Positive numbers mean a left shift. > > > If the shift count is >31|63 or <-31|63, the result is not an > > > error, but zero. > > > > Yes. > > > > > In all cases, right shifts are unsigned, zero filling. > > > > Yes. > > > > > There is no shift operation that propagates the sign bit. > > > In the Modula-3 language even. Perhaps, yes, integer division. But > > > the frontend does not optimize > > > there and turn multiplication or division into shifts, I think, > > > haven't read much of the frontend. The backend could. > > > > Correct. I think the thinking was that a decent back-end would turn > > integer division by a power of 2 into an arithmetic right shift (the > > gcc backend certainly does). > > > > > Rotate is presumably similar, but I have not looked at it. > > > (LeftRotate, RightRotate, Rotate...) > > > > Weird thing with these is the way the high/low bits are rotated > > around, so sign can change! > > > > > m3-sys\m3back\src\m3x86.m3 implements left_shift, and right_shift, > > > very redundanty code, could be combined. > > > > > > The layering is /roughly/ > > > m3x86 on top > > > stackx86 in the middle > > > codex86 at the bottom > > > > > > However m3x86 does call through to codex86 directly. > > > They are largely one layer. There is no strict division. > > > "stack" is a simple way to implement some optimizations and > stategies > > > around constant propagation and register allocation. > > > > > > It is a stack of "operands", which may be constants, globals, or > > > locals. > > > If something is needed in a register, a register will be freed up. > > > If something is later needed and the register hasn't been spilled, > > > it will be > > > reused. If not, not. > > > > > > Presently the operands are assumed to be of word size, 32 bits, > > > register size. > > > That is largely a convenience, and very convenient. > > > I will expand it to allow two word operands. > > > It could be expanded to arbitrarily, at least to "fill" "all" the > > > registers, for some > > > not particularly interesting but theoretically useful scenarios -- > > > passing "medium" > > > sized structs around by value or such. There are ABI concerns > > > though, this could > > > only be amongst local functions that aren't visible/used > > > externally (aka "custom calling conventions"). > > > > You can make some assumptions about how the front-end uses the > middle- > > end interfaces. For example, it only ever stacks integer things as > > 32 or 64 bits, even if the integers have a memory representation > that > > is 8 bits, etc. > > > > > The "generic" shift (vs. left_shift, right_shift) is > implemented in > > > stackx86 > > > while left_shift, right_shift are in m3x86. All three functions > are > > > very similar, > > > could be combined, and there is no good reason for some to be in > > > one layer > > > vs. the other and it's a just a pointless inconsistency. > > > > > > Granted, "generic" shift is a good bit different, it has to check > > > the sign and the magnitude, > > > whereas left and right can just blindly do the operation with no > > > comparisons or branches. > > > > > > Some of this I gather from attempting to compile code with shifts > > > -- esp. the frontend checking of stuff, which then lead me to look > > > at word.i3 > > > which declares subranges for the parameters. > > > > > > Is Bill Kalsow around? > > > > Good question. Farshad Nayeri may know where he ended up. > > > > > Or the other original authors? > > > > I know Michel Dagenais had a student who adapted the native x86 > > backend for use on Linux with PM3. I don't remember the student's > name. > > > > > Everyone just figured stuff out from the code, comments, and > > > "literature" (I ordered another copy of Nelson's good book. :) ) > > > > > > > > > - Jay > > > > > > > > > Connect and share in new ways with Windows Live. Connect now! > > > > > You keep typing, we keep giving. Download Messenger and join the > i?m Initiative now. Join in! From hosking at cs.purdue.edu Fri Nov 30 15:12:23 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:12:23 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: Message-ID: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> CMass (Bill Kalsow) were the ones to do the x86 backend I think. On Nov 30, 2007, at 2:28 AM, Jay wrote: > I thought the last Digital release used the non-gcc backend for > Linux x86. My mistake I see. > The next thing to look into is the Critical Mass release, which I > can't get to at the moment. > > - Jay > > Get the power of Windows + Web with the new Windows Live. Power up! From hosking at cs.purdue.edu Fri Nov 30 15:17:27 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 09:17:27 -0500 Subject: [M3devel] Disabling runtime checks -> implementation of ROUND and friends In-Reply-To: References: <20071129230858.6dcvsy376ogkk40w@mail.elegosoft.com> Message-ID: <625C608A-B7F8-4F7E-A657-EBE2288B77BB@cs.purdue.edu> On Nov 30, 2007, at 8:25 AM, Henning Thielemann wrote: > > On Thu, 29 Nov 2007, Olaf Wagner wrote: > >> http://modula3.elegosoft.com/pm3/pkg/m3build/src/html/m3options.html > > Aha. > >> It seems to be set from M3_OPTIONS in cm3.cfg: >> >> s.m3_options := GetConfigArray (s, "M3_OPTIONS"); >> >> So I'd try to set it there. Perhaps >> >> cm3 -D'M3_OPTIONS=[ "NoChecks" ]" >> >> will work, too. > > > $ cm3 -D'M3_OPTIONS=[ "NoChecks" ]' > LINUXLIBC6/m3make.args, line 3: syntax error: missing: = (found: > ) > Fatal Error: package build failed > > > But, the following works: > $ cm3 -O -D'M3_OPTIONS+=-NoChecks' > > where there must be no space between = and -. > > Many thanks for the help! > > I'm trying to read the code that cm3 produces, because I thought > that the > simple loop I wrote needs too much time. I'm sitting in front of an > Intel > machine and I do not really understand the Intel assembly code (I'm > used > to Motorola :-), but according to the line numbering (.loc > directive) it > seems that 'ROUND' and friends needs lot of time. The count of > assembly > commands is reduced by -NoChecks but still around 20 commands. It > seems > that ROUND, FLOOR and CEILING are implemented manually (checks for > negative numbers), whereas TRUNC is the shortest, but still about 9 > commands. I do not know whether Intel processors have primitives for > several rounding modes. I think the issue here is that GCC's round/trunc/ceiling don't match the M3 spec particularly well. I'd have to look more closely. From jay.krell at cornell.edu Fri Nov 30 15:44:42 2007 From: jay.krell at cornell.edu (Jay) Date: Fri, 30 Nov 2007 14:44:42 +0000 Subject: [M3devel] non-gcc backend In-Reply-To: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: Well that I can contradict. Digital (Bill Kalsow) did the x86 backend.Attached is from boot-LINUXELF.tar.bz2 (originally some other compression). 2) Unpack "boot-XYZ.tar.gz": gunzip < boot-XYZ.tar.gz | tar xpof - 3) Inside the boot-XYZ directory that gets created, unpack "m3cc.tar.gz". It's the gcc-based backend. cd boot-XYZ gunzip < ../m3cc.tar.gz | tar xpof - On Windows 95 and Windows NT, m3cc is not used. This step should be skipped. I think a C producing backend would be useful, to quickly get Windows IA64 and AMD64 support... - Jay > From: hosking at cs.purdue.edu> Date: Fri, 30 Nov 2007 09:12:23 -0500> To: jay.krell at cornell.edu> CC: m3devel at elegosoft.com> Subject: Re: [M3devel] non-gcc backend> > CMass (Bill Kalsow) were the ones to do the x86 backend I think.> > On Nov 30, 2007, at 2:28 AM, Jay wrote:> > > I thought the last Digital release used the non-gcc backend for > > Linux x86. My mistake I see.> > The next thing to look into is the Critical Mass release, which I > > can't get to at the moment.> >> > - Jay _________________________________________________________________ Put your friends on the big screen with Windows Vista? + Windows Live?. http://www.microsoft.com/windows/shop/specialoffers.mspx?ocid=TXT_TAGLM_CPC_MediaCtr_bigscreen_102007 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: NOTES URL: From hosking at cs.purdue.edu Fri Nov 30 17:49:25 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 11:49:25 -0500 Subject: [M3devel] non-gcc backend In-Reply-To: References: <3DEB49C9-C520-4A2C-BF88-F10209BF2F86@cs.purdue.edu> Message-ID: On Nov 30, 2007, at 9:44 AM, Jay wrote: > Well that I can contradict. Digital (Bill Kalsow) did the x86 backend. > Attached is from boot-LINUXELF.tar.bz2 (originally some other > compression). > > 2) Unpack "boot-XYZ.tar.gz": > gunzip < boot-XYZ.tar.gz | tar xpof - > 3) Inside the boot-XYZ directory that gets created, > unpack "m3cc.tar.gz". It's the gcc-based backend. > cd boot-XYZ > gunzip < ../m3cc.tar.gz | tar xpof - > On Windows 95 and Windows NT, m3cc is not used. This step should > be skipped. > > I think a C producing backend would be useful, to quickly get > Windows IA64 and AMD64 support... There was a C-producing backend in the bad old days. Is it still around anywhere? Also, I know there were experimental BURS-based backends too. An alternative to C might be C-- or llvm. > > > - Jay > > > > > From: hosking at cs.purdue.edu > > Date: Fri, 30 Nov 2007 09:12:23 -0500 > > To: jay.krell at cornell.edu > > CC: m3devel at elegosoft.com > > Subject: Re: [M3devel] non-gcc backend > > > > CMass (Bill Kalsow) were the ones to do the x86 backend I think. > > > > On Nov 30, 2007, at 2:28 AM, Jay wrote: > > > > > I thought the last Digital release used the non-gcc backend for > > > Linux x86. My mistake I see. > > > The next thing to look into is the Critical Mass release, which I > > > can't get to at the moment. > > > > > > - Jay > > > Get the power of Windows + Web with the new Windows Live. Power up! > From wagner at elegosoft.com Fri Nov 30 20:24:12 2007 From: wagner at elegosoft.com (Olaf Wagner) Date: Fri, 30 Nov 2007 20:24:12 +0100 Subject: [M3devel] some more notes on the win32 system In-Reply-To: <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> References: <036701c83256$d553bbf0$7ffb33d0$@com> <8395E37B-1822-4C04-A986-FB14CB7F0E16@cs.purdue.edu> Message-ID: <20071130202412.8mewmacdssoso04s@mail.elegosoft.com> Quoting Tony Hosking : > Shouldn't Jay's notes go somewhere on the CM3 Web-site? Sure they should. I would suggest a Windows-specific chapter or link in http://modula3.elegosoft.com/cm3/installation.html, as well as a news item on the first page. Jay, could you extend the HTML documentation on your own and check it into the reporitory, or do you need help? It's all in the cm3/www package. Once it's checked in, we can ship it to our WWW server. Thanks in advance, Olaf > > On Nov 29, 2007, at 8:48 PM, Jay wrote: > >> some more notes on the win32 system >> >>> setup your C++ compiler/linker >> >> You can/should "play dumb", skip that, and just run upgrade. >> See what errors you get. >> I tried to put in the right amount of up front sanity checking. >> >> What you need in particular are >> >> cl and link on the %PATH%. >> See, cminstall would have you specify full paths, my configuration >> uses %PATH%. >> If using VS2005 (8) or newer, mt on the path. >> >> %LIB% is a semicolon delimited list of directories. >> That is a feature of the Microsoft linker. >> msvcrt.lib must be in one of them. >> >> Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, >> 7.0, 7.1, 8.0 -- should work. >> I have tested all of them some and many required small changes in >> one particular spot, >> that actually is only used by "maintainers" >> (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). >> I use 8.0 the most lately. >> I haven't done much with 9.0. >> >> Another thing, fairly redundant: >> >> C:\dev2\cm3\m3-win>more vcredist.txt >> On computers without Visual C++ 2005 or CLR 2.0 installed, download >> and run the setup for the Visual C++ runtime -- vcredist_x86.exe >> -- from either >> >> RTM (release to manufacturing): >> >> http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE >> >> or Service Pack 1: >> >> http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 >> >> You can find those searching the web for vcredist, no real need to >> recort the URLs. That's about it. >> >> - Jay >> >> Your smile counts. The more smiles you share, the more we donate. Join in! -- Olaf Wagner -- elego Software Solutions GmbH Gustav-Meyer-Allee 25 / Geb?ude 12, 13355 Berlin, Germany phone: +49 30 23 45 86 96 mobile: +49 177 2345 869 fax: +49 30 23 45 86 95 http://www.elegosoft.com | Gesch?ftsf?hrer: Olaf Wagner | Sitz: Berlin Handelregister: Amtsgericht Charlottenburg HRB 77719 | USt-IdNr: DE163214194 From agrj at aes.com.br Fri Nov 30 20:28:42 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:28:42 -0200 Subject: [M3devel] Modula 3 and Mac os X Message-ID: Dear All, this is my first message, sorry for the "beginner" question. is there any Modula 3 distribution that is capable of running in a Mac OS X enviroment? if yes, where can I get it and how to install. thanks in advance, Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 20:42:33 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 14:42:33 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: References: Message-ID: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a daily basis. Unfortunately, the most recent release of CM3 does not support Intel Macs (and is somewhat lacking even for PowerPC Macs). I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from the current CVS head of CM3 following the instructions for CM3. On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > Dear All, > > this is my first message, sorry for the "beginner" question. > > is there any Modula 3 distribution that is capable of running in a > Mac OS X enviroment? if yes, where can I get it and how to install. > > thanks in advance, > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > From agrj at aes.com.br Fri Nov 30 20:48:58 2007 From: agrj at aes.com.br (Aryldo G Russo Jr) Date: Fri, 30 Nov 2007 17:48:58 -0200 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> Message-ID: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Thanks I will try. I have also a Macbook pro with OS X 10.5.1. would you think it work? thanks again Aryldo G Russo Jr Gerente de Pesquisa e Desenvolvimento Grupo AeS CRE 6006 - CSSBB 5770 Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a > daily basis. Unfortunately, the most recent release of CM3 does not > support Intel Macs (and is somewhat lacking even for PowerPC Macs). > I have a bootstrap compiler available at ftp://ftp.cs.purdue.edu:pub/ > hosking/m3/I386_DARWIN/cm3.gz. You can use this to bootstrap from > the current CVS head of CM3 following the instructions for CM3. > > On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: > >> Dear All, >> >> this is my first message, sorry for the "beginner" question. >> >> is there any Modula 3 distribution that is capable of running in a >> Mac OS X enviroment? if yes, where can I get it and how to install. >> >> thanks in advance, >> >> Aryldo G Russo Jr >> Gerente de Pesquisa e Desenvolvimento >> Grupo AeS >> CRE 6006 - CSSBB 5770 >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hosking at cs.purdue.edu Fri Nov 30 21:21:52 2007 From: hosking at cs.purdue.edu (Tony Hosking) Date: Fri, 30 Nov 2007 15:21:52 -0500 Subject: [M3devel] Modula 3 and Mac os X In-Reply-To: <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> References: <097AEAEF-7743-454F-A96D-9A2CD0CCAB1B@cs.purdue.edu> <508C3E08-CA3C-4E05-A329-7EE481957931@aes.com.br> Message-ID: <523F0686-A41F-49CB-A89A-E06145AA557F@cs.purdue.edu> I have heard that there may be problems generally with porting software to 10.5 resulting from changes in some of the low-level interfaces. I have not had a chance to try on 10.5 yet. On Nov 30, 2007, at 2:48 PM, Aryldo G Russo Jr wrote: > Thanks > > I will try. > > I have also a Macbook pro with OS X 10.5.1. would you think it work? > > thanks again > > Aryldo G Russo Jr > Gerente de Pesquisa e Desenvolvimento > Grupo AeS > CRE 6006 - CSSBB 5770 > > > Em 30/11/2007, ?s 17:42, Tony Hosking escreveu: > >> Yes, I use CM3 on my Intel Macbook Pro running OS X 10.4.11 on a >> daily basis. Unfortunately, the most recent release of CM3 does >> not support Intel Macs (and is somewhat lacking even for PowerPC >> Macs). I have a bootstrap compiler available at ftp:// >> ftp.cs.purdue.edu:pub/hosking/m3/I386_DARWIN/cm3.gz. You can use >> this to bootstrap from the current CVS head of CM3 following the >> instructions for CM3. >> >> On Nov 30, 2007, at 2:28 PM, Aryldo G Russo Jr wrote: >> >>> Dear All, >>> >>> this is my first message, sorry for the "beginner" question. >>> >>> is there any Modula 3 distribution that is capable of running in >>> a Mac OS X enviroment? if yes, where can I get it and how to >>> install. >>> >>> thanks in advance, >>> >>> Aryldo G Russo Jr >>> Gerente de Pesquisa e Desenvolvimento >>> Grupo AeS >>> CRE 6006 - CSSBB 5770 >>> >>> >> > From rcoleburn at scires.com Fri Nov 30 23:24:25 2007 From: rcoleburn at scires.com (Randy Coleburn) Date: Fri, 30 Nov 2007 17:24:25 -0500 Subject: [M3devel] some more notes on the win32 system In-Reply-To: References: <036701c83256$d553bbf0$7ffb33d0$@com> Message-ID: <4750474F.1E75.00D7.1@scires.com> Jay: Thanks for all your help. Actually, the last time I tried to install cm3, I used the 5.26 tarballs and tried to build, but ran into some compile errors. I'll try it again and report back the actual errors I get (if any). As for Microsoft Visual Studio, yes I'm familiar with setting it up. Are you saying that the cm3install program should no longer be used? I've used this in the past. The big issue I've run into is making sure to give old style 8.3 pathnames without spaces and to edit the cm3.cfg file to find all the libraries and stuff using paths without spaces. I've also set some environment vars, in particular the TEMP and TMP vars, to use paths without spaces. I will try to be very careful to document everything I do in great detail. Perhaps we can use this to give out a better recipe to folks on how to get cm3 working on Windows. Regards, Randy >>> Jay 11/29/2007 8:48 PM >>> some more notes on the win32 system > setup your C++ compiler/linker You can/should "play dumb", skip that, and just run upgrade. See what errors you get. I tried to put in the right amount of up front sanity checking. What you need in particular are cl and link on the %PATH%. See, cminstall would have you specify full paths, my configuration uses %PATH%. If using VS2005 (8) or newer, mt on the path. %LIB% is a semicolon delimited list of directories. That is a feature of the Microsoft linker. msvcrt.lib must be in one of them. Any 32 bit version of Visual C++ -- 2.0, 4.0,, 4.1, 4.2, 5.0, 6.0, 7.0, 7.1, 8.0 -- should work. I have tested all of them some and many required small changes in one particular spot, that actually is only used by "maintainers" (C:\dev2\cm3\m3-win\import-libs\src\make-lib-1.cmd). I use 8.0 the most lately. I haven't done much with 9.0. Another thing, fairly redundant: C:\dev2\cm3\m3-win>more vcredist.txt On computers without Visual C++ 2005 or CLR 2.0 installed, download and run the setup for the Visual C++ runtime -- vcredist_x86.exe -- from either RTM (release to manufacturing): http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE or Service Pack 1: http://www.microsoft.com/downloads/details.aspx?FamilyID=200b2fd9-ae1a-4a14-984d-389c36f85647 You can find those searching the web for vcredist, no real need to recort the URLs. That's about it. - Jay Your smile counts. The more smiles you share, the more we donate. Join in! ( about:www.windowslive.com/smile?ocid=TXT_TAGLM_Wave2_oprsmilewlhmtagline ) -------------- next part -------------- An HTML attachment was scrubbed... URL: