3 ms·
A flaw with the JSON model is that there is no inherent sorting to the order of pairs. This has problems for canonicalisation, but also for shadowing. A Lisp
by eadmund 4y ago
A flaw with the JSON model is that there is no inherent sorting to the order of pairs. This has problems for canonicalisation, but also for shadowing.
A Lisp can use an alist to represent a set of key-value pairs, and is easy enough to shadow values there:
(defvar original '((a . 1) (b . 2)))
→ ((A . 1) (B . 2))
(assoc 'b foo)
→ (B . 2)
(defvar bar `((b . 3) ,@foo))
→ ((B . 3) (A . 1) (B . 2))
(assoc 'b bar)
→ (B . 3)
This makes it easy to implement things like inheritance or trees of lexical environments.
I sometimes wish that Lisp had better ergonomics for hash tables, but normally I am pretty happy that folks don't reach for them first. Frankly, I think positionality is normally good. Can you image how terrible it would be to program a language in which addition is represented as:
add(operand: 1, operand: 2)
- renox 4y agoPositionality is good only when arguments are interchangeable/commutative like addition or when the types are different which ensure that any mistakes in the order will be detected by the compiler. In all the other case positionality is bad: see memset for example.