Re: Discuss changing the behaviour of append()

new topic     » goto parent     » topic index » view thread      » older message » newer message
_tom said...

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.

_tom said...

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.

_tom said...

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.

_tom said...

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?!

_tom said...

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).

_tom said...

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.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu