Re: Discuss changing the behaviour of append()

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
    integer n = I[1] 
    
    return S[1 .. n - 1] & {deep_append(S[n], I[2 .. $], X)} & S[n + 1 .. $] 
end function 

The above function works as specified, however I'd hoped for better performance.

Would this not help?

    integer n = I[1] 
    S[N] = deep_append(S[n], I[2 .. $], X)    
    return S 
end function 



mindwalker said...

Five years of running this program every hour 24x7x365 and only 3 aborts...

At this point, the previously working as designed program would be broken.

As others might have said, I think you meant

the previously broken as designed program would no longer be properly broken. 
I can (just about) see your point, but I'm not going to lose any sleep over it. As long as things get properly documented, of course.

DerekParnell said...
jimcbrown said...

So if we used petelomax's suggestion of appenda()/prependa(), then there would be no problem here?

Ugh! No, please.

We would have append()/prepend() when the first argument must only be a sequence and appenda()/prependa() when the first argument can be any object. That arrangement, I predict, would be more confusing and more likely to introduce errors in code, plus people would tend to just use the newer functions anyway.

Agreed, that was certainly not one of my better suggestions.

jimcbrown said...

Perhaps we should take a different tack. What is the compelling original reason for append() to have refused to accept atoms as the first parameter in the first place?

Absolutely. When Derek said something similar, it completely changed my mind, and 4 days later I still cannot think of a valid answer to that one.

Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu