Structures (WAS Re: Memory)

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

Dear Euphorians,

Irv Mullins explained:

> >And while I'm at it, can anyone tell me specifically what the term
> >'structure' means ? Example; is it related to code or data? Please
> >convert your answear to my 2-digit IQ format smile
>
> Both. A structure is a way to "package" variables so they can be
> handled more conveniently.
> Example in unEuphoria code:
>   structure customer
>      sequence name, addr, city, state, zip, phone
>      integer age
>   end structure
>
> You could make assignments as follows:
>    customer.name = "John Smith"
>    customer.phone = "555-1212"
>    customer.age = 23
> and write to disk as puts(fn, customer)
> or assign the whole thing in one swell foop: thiscustomer = customer
> which does the same as:
>   thiscustomer.name = customer.name
>   thiscustomer.addr = customer.addr
>   thiscustomer.city = customer.city...and so on.

As Irv pointed out, structures are a way of conveniently handling
variables. I was surprised when I started learning Euphoria (I still
am ) that I couldn't find a structure (or struct, or TYPE, depending
on your background) statement in Euphoria. I would be in favour
of implementing this into a later Euphoria version, if possible. IMO, it
doesn't 'dirty up' the code by making it too complex, but rather
(like stated above) gives the programmer one more way of handling
variables, and a clean, clear way of doing it at that. Any opinions on this?


Chris Cox
cox.family at sk.sympatico.ca

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

Search



Quick Links

User menu

Not signed in.

Misc Menu