Concatenative topics
Concatenative meta
Other languages
Meta
Factor has many words that do almost the same thing but have different stack effects, such as remove-nth ( n seq -- seq' )
and delete-nth ( n -- seq )
. This results in having to remember two different names for every concept. One proposed solution is to use Scheme's naming convention for mutation, which is a ! at the end of the word. Then we'd have delete-nth
for creating new sequences and delete-nth!
for mutating existing ones. What would the stack effects be on these new versions?
One issue is that ! is already used for comments. One proposed idea is to change the comment character to #. The # symbol is a word in the make
vocabulary, but this could be changed. Ideas?
An alternative approach is to move towards using Persistent data structures for hashtables and vectors and making just a single word do both mutation and non-mutation, with the stack effect being word ( ... old-obj ... -- new-obj )
. Maybe you would still need two names. Anyone?
The benefit of doing this is for code such as:
ERROR: symbol-not-found ch ; : lookup-symbol ( ch -- symbol ) H{ { CHAR: * STAR } { CHAR: + PLUS } } at* [ symbol-not-found ] unless ;
Throwing an error with the symbol you attempted to look up is awkward with the current at
behavior:
ERROR: symbol-not-found ch ; : lookup-symbol ( ch -- symbol ) dup H{ { CHAR: * STAR } { CHAR: + PLUS } } at* [ nip ] [ drop symbol-not-found ] if ;
This change would make the (substitute)
word unnecessary.
This revision created on Thu, 18 Sep 2008 19:33:03 by erg