Re: Idle musings on doing E over again

"Karp, Alan H" <[email protected]> Mon, 15 Oct 2012 15:00:56 +0000
Newsgroups gmane.comp.lang.e.general
Message-ID <8AD823089998C849A832D86972E69CD53DBAE416@G9W0731.americas.hpqcorp.net>
Kevin Reid wrote:
> 
> What comes to mind now is that there could be a pattern for extensible
> records: add a single field for extra data,
>     unknowns :Map[String, Data],
> such that the User (version 1) guard coerces (using placeholder
> syntax!)
>     struct [
> 	name = "Alice",
> 	email = <mailto:[email protected]>,
> 	phone = <tel:+5555555>,
>     ]
> into the typed struct
>     User [
> 	name = "Alice",
> 	email = <mailto:[email protected]>,
> 	unknowns = ["phone" => <tel:+5555555>],
>     ]
> . That is, all unknown fields are stuffed into a plain Map (hm, or
> perhaps an untyped record). This keeps the record semantics simple for
> applications that don't want extensibility, and makes it easy to
> process extra fields if wanted. What do you think?
>
That's exactly what Stiegler and I did for SCoopFS.  The UI running in the browser uses the waterken back end for persistence.  We used this approach to avoid Marc having to change the Java code every time I decided I needed to stash a new piece of information.  The downside is that the map field is essentially untyped, so you lose the advantages (Well, I think they are advantages.) of compile-time type checking.

________________________
Alan Karp
Principal Scientist
Virus Safe Computing Initiative
Hewlett-Packard Laboratories
1501 Page Mill Road
Palo Alto, CA 94304
(650) 857-3967, fax (650) 857-7029
http://www.hpl.hp.com/personal/Alan_Karp