[squeak-dev] Really strange problem
Casimiro de Almeida Barreto
casimiro.barreto at gmail.com
Tue Jan 18 13:48:41 UTC 2011
Em 18-01-2011 11:21, Levente Uzonyi escreveu:
> (...)
> Which VM and image do you use? (I couldn't reproduce this problem.)
Happens both VMs ("traditional" and cog)
>
> But I found a bug in your code. This line:
> (combOfRest at: j) add: x before: 1 ].
> should probably be:
> (combOfRest at: j) addFirst: x ].
Yes, but add: x before: 1 works...
>
> And there's another bug(?) which causes your method to sometimes
> return a hierarchical structure instead of simply a collection of
> collections. But you shouldn't bother with it, because this method can
> be implemented much easier:
Never even enters in this error case.
I'm concerned with the fact that
SomeClass>>method: x
| y |
...
y := self class new.
...
k := y method: z.
may fail because things are interpreted flatly (in the same context as
calling object)
>
> SequenceableCollection >> combinations: n
>
> ^Array streamContents: [ :stream |
> self combinations: n atATimeDo: [ :each |
> stream nextPut: each copy ] ]
>
Yeah, that works. Shorter & more elegant. Thnx.
>
> Levente
More information about the Squeak-dev
mailing list
|