Syntax & Records (was: Re: COPL, the Tandem, PLITS and JAVA (WAS Re: Eppur si sugat))

Vlad Dumitrescu vlad_dumitrescu@REDACTED
Fri May 30 18:43:49 CEST 2003


Hi,

> My problems with records are more semantic:
> - they're optimized for performance - which is not always the #1 goal
> - they're compile-time only - making general functions which work on
> records very awkward to write
> - they're not a real type - they're "repurposed" tuples
> - they're not typesafe - A#b "casts" A as a b whether it is or not
> - when used across modules you get header file dependency headaches,
> esp. during code upgrade
> - when used internal to a module, they can't be pattern-matched from
> outside that module
>
> These all more or less follow from the first.  If you're willing to take
> the performance hit, dicts solve many of the problems.  But you can't
> pattern-match on dict contents, which is why structs look appealing.

Just one wild thought in the opposite direction from the one discussed
before: Why not let records be as they are (or almost) and instead introduce
pattern matching on dicts (and maybe other similar data structures)?

As an afterthought, I think Joe's structs did work that way, and the idea
might not be original.

I think records and matchable-dicts/structs would make a very nice
complementing pair.

regards,
Vlad



More information about the erlang-questions mailing list