[erlang-questions] next(Erlang): "Fix up records so that records are first-class citizens and not just syntax saccharine for tuples?"
damien morton
dmorton@REDACTED
Sat Nov 22 01:07:35 CET 2008
On Sat, Nov 22, 2008 at 10:27 AM, Steve Davis
<steven.charles.davis@REDACTED> wrote:
>
>> > - Consider how close/far JSON maps to record tuples
>>
>> Richard's frames map very nicely to JSON and back.
>>
>
> Hmm. JSON uses Strings for property names -- is it really an impedance
> mismatch that you should dismiss so easily?
> i.e.
> JSON: { "Object": {"name": "Damien", "location": "here" }}
> Erlang: -record(object {name, location}) which has a tuple
> representation { "Damien", "here" }
> (case differences emphasized for effect)
Not dismissing it at all. Richard's frames proposal uses atoms for
"property names". Every atom can be converted to a string, and every
string can be converted to an atom. An atom is basically an interned
string.
Probably helpful to take a look at the frames proposal at
http://www.cs.otago.ac.nz/staffpriv/ok/frames.pdf
Essentially, what is being proposed is for frames to be dictionaries
with atoms for keys. This is very similar to javascript dictionaries.
There are a number of ways of implementing this. One way is to keep
the list of keys separate from the list of values, which has the
advantage that where you have many frames with the same keys but
different data, you dont have to store the keys many times over - they
keys can be shared between the frames.
More information about the erlang-questions
mailing list