1. Re: Implementing structures
- Posted by Irv Mullins <irv at ELLIJAY.COM> Apr 23, 1998
- 468 views
At 12:11 PM 4/23/98 -0700, David Cuny wrote: >Let me see if I understand what you are asking for: > >1. Ability to define sequences with structured elements. >2. Type checking for the elements. >3. Ability to re-use element names with different structures >4. Implemented as an include file. Exactly (except #4) >Assuming that something like *this* is the optimal syntax: > > myPoint.x = 11 > myLine.point1.x = 32 > x = myLine.point2.y > >I can offer the following versions: > >[Fairly Little Overhead] > > myPoint = set( myPoint, ptX, 11 ) > myLine = set( myLine, {lnPoint1, ptX}, 32 ) > x = get( myLine, {lnPoint2, ptY} ) > <snip some more examples> >Do any of these appeal to you (or other people)? > These seem more OO than what we have been discussing. Looking thru some old Pascal code, I find structures used extensively. Everywhere, actually. Quite useful, and makes for cleaner code. An example converted to Euphorish: structure listbox coords location -- we're assuming type coords coords size -- is already defined as sequence caption -- a structure with elements atom maxlen -- x and y, type checked to be ....etc. -- within valid range for screen coords. assignments would be done in the normal way: with listbox location = {1,1} size = {100,100} caption = "My List" maxlen = 25 end listbox You could use the same names (location...etc) for other gadgets: messagebox:location = {12,16} The difference would be you could refer to listbox as a unit (like any sequence) but assignments would be type checked, i.e. location could not be assigned 1, or "Here". and maxlen couldn't be "Lou" or {2,1} (Oh,yeah: no more LOCATION = 1, SIZE=2, constant declarations needed, either) I am not at all sure this could be implemented in any way other than a change to Euphoria itself. Hope I am wrong. >PS: When are you going to post your Win95 for DOS program? >I'd *love* to = take a look at it. Saturday -- ok, maybe Sunday. Depends upon all sorts of things, including the barometric pressure... Irv Spam Haiku:------------------- Silent, former pig One communal awareness Myriad pink bricks -------------------------------------