Re: Discuss changing the behaviour of append()

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

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

gimlet said...

A[i] can be a sequence or an atom.\\ 
                 append(A[i],x) : sequence : OK\\ 

So far, so good.

gimlet said...

                 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.

gimlet said...

This is legitimate because A[i] is the i in A[i..i]??

Uh, no.

gimlet said...

A[i..i] is a sequence

Yes. That's always a 1-element sequence.

gimlet said...

A[i..i-1] ditto

Yes. That's the empty sequence.

gimlet said...

A{i..i-2] is rubbish

Agreed. That's a syntax error.

gimlet said...

At some point here I am losing you.

I followed you up to the bit after the bit about the rubbish.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu