Haha, great discussion, great find. Amazing that all these things are just already there. Pharo/Smalltalk programming is really 'studying the problem and the existing system, moving it to the desired state with as little work as possible' - including the use of frameworks and libraries.
On 29 Mar 2019, at 18:08, Peter Kenny <peter@pbkresearch.co.uk> wrote:
Tim
Going back to your original question, the answer is there all the time but buried in the enormous method dictionaries of the Collection subclasses. If you look at SequenceableCollection>>atWrap: you will see that it does exactly what you want.
To get the item before the first, i.e. the zeroth: #(1 2 3 4) atWrap: 0 => 4
To get the item after the last: #(1 2 3 4) atWrap: 5 => 1
As seen here, the method is inherited by Array, so it should do all you want.
HTH
Peter
Marcus Denker-4 wrote
On 29 Mar 2019, at 14:24, Ben Coman <
btc@
> wrote:
On Fri, 29 Mar 2019 at 18:57, Tim Mackinnon <
tim@
> wrote:
Hi Peter - yes of course you are right that its malleable, I guess Iâm often suprised about the things we leave out and then discover weird things weâve put in.
I had a quick look at LinkedList (I should have thought of that) - I might be able to do something with that (and this is now more out of curiosity) - but gosh its an easy way to crash your image. Having linked the first to the last, and then tried a quick: list after: $n - Iâm now guessing Iâm stuck in an infinite loop that even Cmd . wonât break out of!!!! ouch.
If you look at Hier(archy) of LinkList you'll see Semaphore underneath it. I'm not sure, but there may be some VM magic around Semaphore and Process management that makes it fragile to changes. I believe there have been some proposals to separate out the Process related LinkedList stuff, but I can't remember the exact arguments.
Yes, we did that⦠there is now ProcessList.
We ran into that problem far too often âhey, LinkedList can be cleaned up easily like this!â â> boom, everything broken.
Now we have ProcessList where it matters if code is changed to introduce a message send more and LinkedList where it does not.
Marcus
-- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html