Shallow-bind symbols? #24

Open
opened 2026-05-11 12:12:40 +00:00 by simon · 0 comments
Owner

I'm not convinced I want to abandon deep binding altogether, but there's no doubt that shallow binding is (much!) faster1. So I want to have shallow bind symbols. Whether they should replace the existing symbols, or supplement them, is at present an open question. But it does mean that symbols need meta-data, to whit at least whether they are shallow-bind or not (this is the meta-data added by (declare special...)) in Common Lisp. Which means they cannot fit into the memory footprint of a pso22; which means, in turn, that there would be merit in storing them as character arrays in pson objects, which would require much less chasing of pointers.

See:

  1. DEEP AND SHALLOW BINDING: THE ASSIGNMENT
    OPERATION
    ;

  1. Is this actually true? To have shallow binding work, you have to ensure that there are not two distinct symbols in the environment which are lexically identical but have different bindings. Which means every time a symbol is read, you need to see whether or not that lexical sequence of characters is interned in the environment, which is precisely what you'd have to do for a deep bound symbol anyway. ↩︎

  2. It would of course be possible to store a symbol as a pso2 whose first pointer was a pointer to metadata, and whose second pointer was a pointer to the string which represented the print name of the symbol, but that feels pretty messy. ↩︎

I'm not convinced I want to abandon deep binding altogether, but there's no doubt that shallow binding is (much!) faster[^1]. So I want to have shallow bind symbols. Whether they should replace the existing symbols, or supplement them, is at present an open question. But it does mean that symbols need meta-data, to whit at least *whether* they are shallow-bind or not (this is the meta-data added by `(declare special...))` in Common Lisp. Which means they cannot fit into the memory footprint of a `pso2`[^2]; which means, in turn, that there would be merit in storing them as character arrays in `pso`<sub>`n`</sub> objects, which would require much less chasing of pointers. See: 1. [DEEP AND SHALLOW BINDING: THE ASSIGNMENT OPERATION](https://www.cs.umd.edu/~hjs/pubs/SameJCL79.pdf); [^1]: Is this actually true? To have shallow binding work, you have to ensure that there are not two distinct symbols in the environment which are lexically identical but have different bindings. Which means every time a symbol is read, you need to see whether or not that lexical sequence of characters is interned in the environment, which is precisely what you'd have to do for a deep bound symbol anyway. [^2]: It would of course be possible to store a symbol as a `pso2` whose first pointer was a pointer to metadata, and whose second pointer was a pointer to the string which represented the print name of the symbol, but that feels pretty messy.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: simon/post-scarcity#24
No description provided.