Hi Denis, Hi Sven,
We made this change in VisualWorks and it works well. One can avoid using atEnd and lion for the sentinel instead, which is much cleaner and faster and less problematic than atEnd.
|
2018-04-04 16:12 GMT+02:00 Eliot Miranda <[hidden email]>:
Hi Eliot, Using self is a nice hack for saving an inst. var. :) If we want to afford an inst.var. then we can also reify an endOfStreamAction inst.var. like I did in ExtendedStream ^endOfStreamAction value We are then free to use Notification/Error, default value (reified EndOfStream object, nil, ...), block with block return... The problem I had is when I started using stream wrappers like in Xtreams. Each wrapper has it's own action, and it's not obvious how we should compose these.
|
In reply to this post by Eliot Miranda-2
2018-04-04 16:12 GMT+02:00 Eliot Miranda <[hidden email]>:
Hi Eliot, Using self is a nice hack for saving an inst. var. :) If we want to afford an inst.var. then we can also reify an endOfStreamAction inst.var. like I did in ExtendedStream ^endOfStreamAction value We are then free to use Notification/Error, default value (reified EndOfStream object, nil, ...), block with block return... The problem I had is when I started using stream wrappers like in Xtreams. Each wrapper has it's own action, and it's not obvious how we should compose these.
Nicolas Sorry to double post, I should have respond-to-all as default action...
|
In reply to this post by Eliot Miranda-2
Hi Eliot.
2018-04-04 16:12 GMT+02:00 Eliot Miranda <[hidden email]>:
Does it mean that at the end of stream:
?
|
Hi Denis,
e.g. ReadStream>>next "Primitive. Answer the next object in the Stream represented by the receiver. Fail if the collection of this stream is not an Array or a String. Fail if the stream is positioned at its end, or if the position is out of bounds in the collection. Optional. See Object documentation whatIsAPrimitive." <primitive: 65> ^position >= readLimit ifTrue: [self pastEnd] ifFalse: [collection at: (position := position + 1)] ReadStream>>pastEnd "The stream is at its end; respond appropriately. If the endOfStream element has been set, answer it, otherwise raise an exception." ^endOfStream == self ifTrue: [self class endOfStreamSignal signal] ifFalse: [endOfStream] then for the current behavior of answering nil on end of stream endOfStream is set to nil. By default endOfStream would be initialized to self, meaning that an exception is raised on end of stream by default. And I'm wrong. This scheme is not used in VisualWorks. They ripped it out after I left. It's not in vw7.7.
|
In reply to this post by Nicolas Cellier
Hi Nicolas,
On Wed, Apr 4, 2018 at 7:24 AM, Nicolas Cellier <[hidden email]> wrote:
I suppose one could send value to the endOfStream element. Then if one wanted to answer a block, rather than the evaluation of a block, one would wrap it in a block or an association. e.g. pastEnd ^endOfStream == self ifTrue: [self class endOfStreamSignal signal] ifFalse: [endOfStream value] and then myStream setEndOfStreamElement: nil -> ['I want it to answer a block on end of stream goddammit!!!'] as opposed to myStream setEndOfStreamElement: ['I want it to answer this string on end of stream goddammit!!!']P.S. Note that this hack is used in CompiledMethod>>messages in the form of InstructionStream>>selectorToSendOrSelf because notionally any object can function as a message selector, not just symbols. Of course nil could be used here because nil is the value used for an empty key in a method dictionary. But that's implementation. A better representation for method dictionaries is as a flat sequence of pairs, ordered by selector identity hash; but that's a separate discussion :-)
_,,,^..^,,,_ best, Eliot |
Free forum by Nabble | Edit this page |