Re: Discuss changing the behaviour of append()
- Posted by jimcbrown (admin) Jun 12, 2014
- 4083 views
One of the better techniques in designing applications, is to always provide validity checking on data that comes from outside the program, as opposed to data that is generated by the program.
This can (and should) be applied to functions.
When reasonable to do so. The problem is when one adds in restrictions that serve no purpose.
(There's a second problem, where it's reasonable for a function in the general case to have a certain behavior, but in a specific context it causes a logical error in the data. But we don't seem to be discussing this here.)
A[i] can be a sequence or an atom.\\ append(A[i],x) : sequence : OK\\
So far, so good.
atom : How do you want to see it? (atom or sequence)?
Autopromotion - we already do this from integers to atoms in the delete case. Now we can promote the atom to a sequence (n -> {n}) and then append x to it.
In general though, autopromotion should be done in specific, case-by-case circumstances.
This is legitimate because A[i] is the i in A[i..i]??
Uh, no.
A[i..i] is a sequence
Yes. That's always a 1-element sequence.
A[i..i-1] ditto
Yes. That's the empty sequence.
A{i..i-2] is rubbish
Agreed. That's a syntax error.
At some point here I am losing you.
I followed you up to the bit after the bit about the rubbish.