[e-lang] record syntax for E, please help
Pierre Radermecker
pradermecker at yahoo.ca
Mon Jan 7 19:56:41 EST 2008
Does E provide syntactic facilities for "records" ? I like to do
something similar to the Erlang record syntax :
-record(language,{name = 'E', popularity= high, rating}).
Declaring a constructor for each default/optional data does not sound
like a practical option ;-) Is it the default way to create data container ?
I would like to have an immutable data store that can be built quickly
according to the data at hand together with an explicit "template" that
indicate which kind of data the objects can hold. So "dictionary" or
"map" seems like a poor option.
Of course if I can do "pattern matching" (or whatever) to quickly
create, read or update the container that would be wonderful.
If you have any idea how to achieve this (I mean easily) in other
languages I would love to hear it. I know Oz have a record datatype but
as far as I know it does not provide instantiation (explicit template)
with default/optional values, does it ?
In ML, you can define records but all fields needs to be provided to
instantiate a new record (no default/optional values). In OCaml you can
use named arguments and wrap the constructor within a function.
Haskell 98 does not seem to provide any clean and standardized solution
but extensions are provided.
I guess you can easily achieve something close to Erlang in CL (Scheme
syntax on the matter looks more clunky) or Python.
Do you think this is useful at all ? Why not ?
Thanks for your help. E is wonderful !
More information about the e-lang
mailing list