Structs - thoughts on implementation

Shawn Pearce <>
Fri Jan 17 05:15:25 CET 2003


I've been following this quite a bit, and have these two comments:

- Dynamic structs are just asking for trouble.  I run into this
  problem in Perl so often:  I spell 'upper' in one spot and 'uper'
  in the other, thanks to having human fingers.  Program doesn't work
  for 3 days while I debug my hash keys.

- Dynamic structs are cool, but a dyanmic struct is really just a
  tagged list:  [{key, val},{key, val}] stored in sorted order
  or such.  Although a tagged list isn't very fast to search.

Plus, with some of the syntax being kicked around, structs vs. records
will get very complex, very fast.  Erlang is starting to become almost
as grotty as Perl!

static structs meanwhile....   ohhhhh the possibilities....  no more
records!  :)  Faster implementation possible.  Maybe.

I especially liked the proposal (I forget who proposed it, sorry)
to have guards on fields and on the struct itself to validate the
struct on all modifications, preventing improper modification of
the struct.  Sweet.

Now all I need is a good business case to do my next project in
Erlang.  I think a load testing environment in Erlang could be very
easy to build... and fun.


Lawrie Brown <> wrote:
> where
>  - structname is the name of the structure (atom)
>  - flag is 'static_struct' (tags fixed) or 'dynamic_struct" (extensible)
>  - tag1 & val1 are the first field tag and value up to the nth

-- 
Shawn.




More information about the erlang-questions mailing list