Re: Structures (WAS Re: Memory)
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jan 10, 1999
- 553 views
On Sun, 10 Jan 1999 13:53:19 -0800, Greg Phillips <i.shoot at REDNECKS.COM> wrote: >With Euphoria's sequences, what need is there for structures, really? > >for example: > customer.name = "John Smith" > customer.phone = "555-1212" > customer.age = 23 > >could be represented in a sequence: >customer{"John Smith","555-1212",23} It can, however, there are several drawbacks to this workaround: 1. You no longer have type checking. Try assigning customer[age] = "Older than Dirt" You can do it - not a Good Thing (tm). 2. You will have namespace collisions all over the place. Try to find a business program that does _not_ have fields like customer.name, supplier.name, and maybe half a dozen other "name" or "phone" fields. >then, if you want to access all of the sequence values, just use >customer, or if you want the age, customer[3].... you can make sequences >even more like structures, style-wise, by using constants to make NAME = >1, PHONE = 2, etc. It would be easier if Euphoria had the ability to "enum" lists, but still would not solve the first two problems. As it stands, you must number and renumber these lists each time you add/delete a "field". One mistake and kaboom! Irv