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

Chris Pressey cpressey@REDACTED
Tue Jun 3 02:15:31 CEST 2003

On Fri, 30 May 2003 18:43:49 +0200
"Vlad Dumitrescu" <vlad_dumitrescu@REDACTED> wrote:

> 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.

That's sort of how I'd approach structs:
- you effectively can't get rid of records, so leave them be
- make all functions in module dict, BIFs (for performance only)
- add a shorthand syntax for dicts
- add pattern matching for dicts
- add guards (etc) to dicts

Then you basically have structs, plus any code that currently uses dicts
also gets a performance boost, without any extra changes.

But then you might well ask, "Why can't I pattern match on property
lists etc"?  Then you may ask "Why aren't patterns a first-class type?" 
Then you may ask "Isn't this an awful lot of work to slightly improve a
language which is already very nice?" :)


More information about the erlang-questions mailing list