[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: User-defined record types
From: |
Stefan Monnier |
Subject: |
Re: User-defined record types |
Date: |
Sat, 19 Oct 2013 10:37:48 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
SM> You lost me: I though "null" and "empty list" were JSON thingies, so
SM> I just offered you ways to represent them on the Elisp side. Of course,
SM> when turning those elements into JSON, you'd be careful to map them to
SM> the appropriate JSON elements.
> Right. So instead of a special mapping operation, the underlying C
> storage (record) should hold the JSON/YAML/XML types and values
> directly.
Huh... no, I'm thinking about json.el, with no C code involved at all.
SM> I still don't understand in what way a custom data structure would help.
> By holding the original data in a way that today's Emacs internals can't.
For example?
> - the value under the "y" key has four distinct values that should be
> represented and serialized differently, yet provide the expected
> semantics for ELisp access ("null", "[]", and "false" would be exposed
> as `nil').
Let's call [[e]] the Elisp representation of JSON's e.
Then you're saying that [[null]] would be exposed as nil and
[[false]] as well? Then would it be the case that (eq [[false]] [[null]])?
I really don't see how you expect to turn those into `nil', preserve
sane semantics (and Elisp performance), and be able to recover null, [],
and false when converting them back to JSON. You can probably pick any
two of the three, but all three together sounds pretty much impossible.
> - stored efficiently
Saying so is not sufficient to make it so.
> format. The C implementation would also be more efficient than an ELisp
> implementation if it serializes to and from JSON in C, but that's a
> minor concern.
We're back at the FFI discussion, which is a different issue.
> Finally, a C implementation would be able to make null, false, and []
> look like `nil' in boolean or iteration contexts, yet preserve the
> original data.
C is not magic. Such a "feature" would require changes deep in the
elisp/bytecode interpreter, the NILP function/macro, ...
Stefan
- Re: RFC: User-defined pseudovectors, (continued)
- Re: RFC: User-defined pseudovectors, Lars Brinkhoff, 2013/10/11
- Re: RFC: User-defined pseudovectors, Stefan Monnier, 2013/10/11
- User-defined record types, Lars Brinkhoff, 2013/10/12
- Re: User-defined record types, Stefan Monnier, 2013/10/15
- Re: User-defined record types, Ted Zlatanov, 2013/10/18
- Re: User-defined record types, Stefan Monnier, 2013/10/18
- Re: User-defined record types, Ted Zlatanov, 2013/10/18
- Re: User-defined record types, Stefan Monnier, 2013/10/18
- RE: User-defined record types, Drew Adams, 2013/10/18
- Re: User-defined record types, Ted Zlatanov, 2013/10/19
- Re: User-defined record types,
Stefan Monnier <=
- Re: User-defined record types, Ted Zlatanov, 2013/10/19
- Re: User-defined record types, Stefan Monnier, 2013/10/19
- Re: RFC: User-defined pseudovectors, Stefan Monnier, 2013/10/10