We have two rather separate mechanisms, both designed to solve aspects of what is essentially the same problem: lookup expressions lose too much information.
Pinning tries to solve the problem by saying that if the origin of the lookup is pinned, then the results of the lookup carry a label containing information about the key and the parent.
Modifiers like pair::* try to solve the problem by returning a map containing the key and the value as separate fields.
But pinning only solves part of the problem, in particular it doesn't prevent X?* flattening the result, and the pairs modifier only solves part of the problem, in particular it doesn't retain parentage.
I would like to try combining them and trying to create a mechanism that is better than either. I don't yet know exactly how this might work, but I'm thinking along the lines:
- Replace the concept of labelled items with labelled values (that is, a label can be attached to any value, not just an item)
- Scrap pin() as an explicit function
- A lookup expression like $X ? child::Y returns a sequence of labelled values (no flattening)
- The properties of a labelled value include:
** target - the actual value
** key - the associated key (or array index)
** parent - the containing map or array
- These properties might be made available through syntax such as
$LV ? target::* , $LV ? key::*, $LV ? parent::* (or otherwise)
- ancestor and ancestor-or-self can be made available as derived properties
- Many operations when given a labelled value should automatically operate on its target, and ignore the label (rather like atomisation). Exactly which operations do this is an interesting question to which I don't yet know the answer. It's tricky because child::* returns a sequence of labelled values, and we want to be able to manipulate this in unflattened form. Perhaps child::* should instead return an array of labelled values? But then you end up with another lookup operation to extract the members of this array.
We have two rather separate mechanisms, both designed to solve aspects of what is essentially the same problem: lookup expressions lose too much information.
Pinning tries to solve the problem by saying that if the origin of the lookup is pinned, then the results of the lookup carry a label containing information about the key and the parent.
Modifiers like pair::* try to solve the problem by returning a map containing the key and the value as separate fields.
But pinning only solves part of the problem, in particular it doesn't prevent X?* flattening the result, and the
pairsmodifier only solves part of the problem, in particular it doesn't retain parentage.I would like to try combining them and trying to create a mechanism that is better than either. I don't yet know exactly how this might work, but I'm thinking along the lines:
** target - the actual value
** key - the associated key (or array index)
** parent - the containing map or array
$LV ? target::*,$LV ? key::*,$LV ? parent::*(or otherwise)