←back to thread

389 points kurinikku | 1 comments | | HN request time: 0.209s | source
Show context
liontwist ◴[] No.42165013[source]
The cons/car/cdr implementation as lambda was magical the first time I saw it. But it just shows that the language runtime must implement key/value dictionaries and you are able to borrow that implementation to make other data structures.
replies(3): >>42165632 #>>42166573 #>>42203090 #
1. EuAndreh ◴[] No.42203090[source]
Not key value dictionaries, just pointers are needed.

A closure with no behaviour is just a pointer to the enclosed variable. A closure with 2 pointers is a pair, which you can get the car and cdr.

The runtime needs to make the pointee available outside its definition, so escape analysis, garbage collection, etc. But no dictionary is needed.