Re: wishlist : structures

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 7 Nov 2000, at 12:00, Al Getz wrote:

> Koda,
>
>   I like the idea of structures too, but i have used the following
> to emulate some simple structures which only have to be accessed
> by other Euphoria code.  For example:
>
>   my.width=145
>   my.height=233
>
> become:
>
>   sequence my
>   constant WIDTH=1, HEIGHT=2
>   my={0,0}
>   my[WIDTH]=145
>   my[HEIGHT]=233
>
> the only drawback is if you need WIDTH and HEIGHT for another struc,
> you might have to super class all the constants:
>
>   sequence my
>   constant my_WIDTH=1, my_HEIGHT=2
>   my={0,0}
>   my[my_WIDTH]=145
>   my[my_HEIGHT]=233
>
>   sequence her
>   constant her_WIDTH=2, her_HEIGHT=1
>   her={0,0}
>   her[her_WIDTH]=145
>   her[her_HEIGHT]=233
>
> I've used this method in several large programs and can still
> understand what is being done after reading through the code
> several months later.

This reminds me of a large pascal program i wrote once, which could
easily be converetd to Eu, if i chose to do that. In it, i'd this in Eu:

constant
something 1
somethingelse 2
somethingmore 3
anotherthing 4

sequence stuff_1 {"","","",""}
sequence stuff_2 {"","","",""}
sequence stuff_3 {"","","",""}

ok,,,

stuff_2[somethingelse] = "etc"
stuff_2[anotherthing] = "whatever two"

stuff_3[something] = "whatever"
stuff_3[anotherthing] = "whatever three"

and just don't use those indexes i don't need. No need to redefine different
index values for each sequence. If i ever do need to use them, the space in
the sequence is already there, all i haveto do is use it. Really, in today's
puters and OSs, what is a wasted byte here or there?

Kat

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu