Re: Discuss changing the behaviour of append()
- Posted by _tom (admin) Jun 13, 2014
- 3926 views
Still trying to make sense of this topic. Here is a summary of a few ideas I see in this thread.
- Is change going to happen?
- How do I describe these chagnes?
_tom
From Euphoria 1.0 Documentation from 1993:
Concatenation of Sequences:
The & operator will concatenate two sequences into a longer sequence. e.g. {1, 2, 3} & {4, 5, 6} is {1, 2, 3, 4, 5, 6}. Atoms can also be concatenated: 6.5 & 9 is {6.5, 9}. {1, 2, 3} & 4 is {1, 2, 3, 4}.
Operations on Sequences:
i = length(s) -- length of sequence s = repeat(x, a) -- repeat x a times s2 = append(s1, x) -- append x to end of s1 s2 = prepend(s1, x) -- prepend x at beginning of s1
Twenty years later...OpenEuphoria wants to look like:
Concatenation of Objects:
The & operator will concatenate two objects into a longer sequence. e.g. {1, 2, 3} & {4, 5, 6} is {1, 2, 3, 4, 5, 6}. Atoms can also be concatenated: 6.5 & 9 is {6.5, 9}. {1, 2, 3} & 4 is {1, 2, 3, 4}.
Operations on Objects:
i = length(x) -- length of object s = repeat(x, a) -- repeat x a times s2 = append(x1, x) -- append x to end of x1 s2 = prepend(x1, x) -- prepend x at beginning of x1
- Keep things the way they were
- Extend Euphoria
Keep Things
- change is bad
- some suble changes in program behaviour if append is changed?
- append was optimized for speed; do not sacrifice this speed
- & is a "sequence creation" operator; therefore it makes sense that you can concatenate two atoms
- append is a "sequence modifying" function; therefore it makes sense that you can not start with an atom
Extend Euphoria
- length has already been changed
- a complementary change given that length is now different
- fits the existing pattern that & already has
- promoting an atom a to a sequence {a} is a convenience that is expected because of the flexibility of Euphoria
- usability is more valuable than interpreter speed
- thinking in terms of objects is more powerful than thinking in terms of just sequences