Re: EUPHORIA struct support

new topic     » goto parent     » topic index » view thread      » older message » newer message
struct sequence person  
    integer magic 
    sequence name 
    sequence phone_numbers 
end struct 
 
person p1 
p1.magic = "Person" 
p1.name = "Matt Lewis" 
p1.phone_numbers = {} 
-- The following prints 
-- Person 
-- Matt Lewis 
-- 
for i = 1 to length(p1) do 
   ? p1[i] 
end for 

What you seem to be suggesting here is yet another enum scheme that incorporates type checking as well, that's assuming that assigning "Person" to the magic integer would result in an error.

One of the major selling points for Euphoria is the simplicity of the language; very few keywords/built-in functions. When I first ran across Euphoria years ago I learned the entire language in an afternoon, including reading the REFMAN.DOC and reviewing the include libraries. With version 4 I am seeing the complexity starting to grow. Not bad yet, but if it continues unabated it won't be very long before Euphoria is competing with Java and C+ for complexity.

I'm not sure you need both enum and struct in the language, but I have thought from day 1 it would be nice to have type checking when assigning something to a sequence (that includes user defined types).

Specific comments on the example code follows.

I think it should read "struct person" unless you think there will be "struct integer" and "struct atom", etc.

The name space concept already uses the . notation I would be more in favor of p1[magic] = "Person".

I would extend that concept to p1 = {"Person", "Matt Lewis", {}} where type checks would occur on each element of p1 assigned.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu