Re: Eu improvements (part 4)

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

Matt Lewis wrote:

> euclass foo( sequence f )
>     integer bar, baz
>     function foo( integer bar, integer baz ) : foo
>         foo this
>         this = repeat( 0, 2 )
>         this.bar = bar
>         this.baz = baz
>         return this
>     end function
>     
>     procedure print()
>         ? this.bar
>         ? this.baz
>     end procedure
> end euclass

By this, don't we then already have structured sequences (SS) in Euphoria?!?!

-- simple example
euclass Address( sequence s )
   atom street_number
   sequence street_name
   sequence city
   sequence state
   atom zip_number
   atom zip_plus4
end euclass

This seems to allow both structured sequences (at its simplest) and advanced
objects (at its most complex).

address myAddress -- create your new structured sequence
  myAddress.street_number = 1234
  myAddress.street_name = "Independence Pkwy"

It's just called a euclass instead of a sequence/record/etc.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu