4 ms·
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
by liontwist 2y ago
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.
- deleted 2y ago[deleted]
- hinkley 2y agoI find the destructuring logic in elixir much more interesting, and the watered down version in ES6 much more practical. In elixir you can pop off as many as you like.
- liontwist 2y agoCan you share any resources about it?
- hinkley 2y agoI’m a bit of an elixir noob, but Enum functions like slice let you cut up lists in various ways, and you can pattern match values in maps in function definitions: http://www.skuunk.com/2020/01/elixir-destructuring-function.html http://www.skuunk.com/2020/01/elixir-destructuring-function.... Which can let you unroll function preambles, or apply different rules if for instance an admin user runs a function versus a regular user.
- EuAndreh 2y agoNot 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.