Re: Discuss changing the behaviour of append()
- Posted by DerekParnell (admin) Jun 24, 2014
- 3766 views
Consider append and prepend to be special cases of the insert function.
Interesting point of view ... and probably a useful one too in some circumstances. I've mainly regarded append/prepend as special cases of concatenate.
The proposed changes to O[ are going to put emphasis on object behavior and blur some previous atom-sequence distinctions. While a != {a} remains true, the new behavior tolerates the idea that a becomes {a} when it is convenient in a prepend, insert, or append.
Well ... except that "a becomes {a}" never actually happens. An atom does not become a sequence during those operations. Its more that these operations will work on objects rather than just atoms or sequences.
TARGET is an atom, like 1, is promoted to { 1 ,$} using prepend, insert, append
I'm not sure the term TARGET is correct, maybe RESULT? Also, I'm not sure if anything is promoted either.
Also, the $ symbol, in this context, is used as a LIST construction device and has nothing whatsoever to do with sequences.
The length function is now oddly named. It could have been named item_count (items, count, size, topsize, ... ?)
- on its own {} has a zero item count, but inside a sequence it is itself one item
- length( { } ) or length( "" ) is zero, this does not mean a null sequence, but a sequence with no item count
- length( a ) is one, this does not mean a number has "length", but that one atom is one item
- length( {a} ) = length( a ) means there is one item count in each example
Yes, but I guess we are stuck with it now. Evolution, eh?!
If the results seem "strange" is it because an empty sequence can be both paradoxically "length zero and one item"? Note that quantum physics copes with ideas like this.
There is no paradox here. An empty cup is still one thing and contains nothing. A sequence is just a container. It can be empty (length = 0) while still having an existence (is an object).
Another consideration is that syntax is not mathematics. Sometimes syntax is based on mathematics (consider lisp, haskel), sometimes syntax just looks like mathematics (consider the assignment operator = which is better represented by :=), and sometimes syntax just happens when a language is designed.
I like this explanation.

