Immutable Paths, of minimum length 2 #906
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This changes PATH! to no longer be an ANY-SERIES! type. This means it
cannot be operated on with series operations like APPEND, and it can't
be traversed to give new positions into paths with things like NEXT
or SKIP. However, other operations like LENGTH OF, PICK, and FOR-EACH
continue to work.
Besides no series modifiers, ANY-PATH! can't be mutated with POKE-ing.
This means that a path can be checked at the time of its creation for
properties which cannot be violated by future mutations.
The new rules are:
Paths must contain at least 2 elements. The minimum path is
/
,which is the path form of [_ _]...two blanks.
Paths may not directly contain other paths. This prevents various
ambiguity problems like [a/b c] and [a b/c] both being possible
interpretations of a/b/c. Indirect inclusion of other paths is
legal, such as
a/(b/c)/d
It is believed that this change eliminates harmful degrees of freedom,
without really sacrificing any behaviors people found that interesting.
Additionally, being able to promise paths are immutable open doors to
being able to create optimized representations of things like
/
or/a
, which could be packed into a single cell with no array node.If one wishes to do surgery on path content, the way to do that is to
convert it to a BLOCK! or GROUP! and use series operations on that,
and then change it back to a PATH!.
(Note: Any series embedded in a path, e.g. the GROUP! in
a/(b c d)/e
,is not subject to the immutability rule...and is subject to whatever
mutability state it had when it was inserted.)