Idea for a possibly better Collection occurrencesOf method.

Hans-Martin Mosner hmm at heeg.de
Wed Sep 13 19:47:48 UTC 2006


danil osipchuk schrieb:
> But I wonder, if VAST problems with seaside are related to something
> like that ;)
Not primarily. VAST uses a single stack per process instead of Context
objects as the Smalltalk-80 derived systems (Squeak and VisualWorks) do,
and the stack can not be safely manipulated by non-VM code. I've tried
it quite hard, and I did not find a way to implement continuations
correctly.

The iterator primitive could be implemented with Context objects, but
there are some tricky issues:
1. There needs to be a slot in a context where the iteration variable
can be stored. One possibility would be to keep the block, collection,
limit and current index on the stack of the calling context, instead of
popping them off the stack.
2. The return value from the block needs to be discarded somehow.
Normally, every return from a method or block pushes the result onto the
caller's stack. The problem is that the primitive can only handle the
activation of the block, not its return.
3. The primitive needs to ensure that the return will happen to the
right place so that the loop can continue, preferably just to the
position of the send bytecode. But since bytecodes may be 1 or more
bytes long, it is difficult for the primitive to find out what's the
correct place.

Overall, I think that the performance and readability improvements
gained by such a primitive might not be worth the effort.

Cheers,
Hans-Martin



More information about the Squeak-dev mailing list