atom_concat/3 is forward-only: split/backward modes raise type_error instead of enumerating decompositions #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
atom_concat/3works only in the forward (assembly) direction, where the firsttwo arguments are bound. The standard backward / split modes — third argument
bound, one or both of the first two unbound — are not supported. Instead of
backtracking through decompositions (as ISO requires) they raise an error, and
the error class is itself wrong for an unbound argument.
Version
plgc 0.3.1.Reproduction
Given any program file
p.pl(e.g.p.):Forward (works):
Backward / split (all error):
Expected (ISO 8.16.2)
Two distinct deviations:
1. Missing split mode (primary). When
Atom_3is instantiated andAtom_1/Atom_2are unbound,atom_concat/3is nondeterministic and must enumerate everydecomposition. For example
atom_concat(A, B, abc)should yield, on backtracking:''abcabcabcabc''and the partially-bound forms should pick out the matching split:
atom_concat(X, bar, foobar)→X = foo;atom_concat(foo, Y, foobar)→Y = bar. This is the same relational / multi-mode behaviourappend/3alreadyhas for lists.
2. Wrong error class (secondary). Even setting the split mode aside, raising
type_error(atom, _Var)for an unbound argument is non-conformant: ISO reservestype_errorfor a bound term of the wrong type. In the genuine error modes(e.g.
Atom_1unbound andAtom_3unbound) the standard prescribesinstantiation_error, nottype_error.Contrast — the other text builtins are bidirectional on 0.3.1
Only
atom_concat/3is forward-only.Notes / impact
Found while scoping the loglings "atoms & text" chapter.
atom_concatis fullyusable for assembly (building qualified names, labels, etc.), but cannot be
taught as a relational splitter the way
append/3is. Filing so the split mode— and the
instantiation_errorcorrection — can be considered.1b019bdc9a