<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font face="Georgia">Given that there might be a performance issue
      in some (rare) cases, but especially because of the potential for
      the wrong handler seeing the exception, another approach might be
      more acceptable. Some possibilities:<br>
    </font><br>
    <font face="Georgia"><font face="Georgia"><font face="Georgia">=======================</font><br>
        next<br>
        <br>
        &nbsp;&nbsp;&nbsp; &lt;primitive: 65&gt;<br>
        &nbsp;&nbsp;&nbsp; position &gt;= readLimit<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifTrue: [^eos]&nbsp;&nbsp;&nbsp; "a new instance variable the user can
        leave nil or set to preferred marker"<br>
        &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifFalse: [^collection at: (position := position + 1)]<br>
        =======================<br>
      </font>nextIfNone: aBlock<br>
      <br>
      &nbsp;&nbsp;&nbsp; &lt;primitive: 65&gt;<br>
      &nbsp;&nbsp;&nbsp; position &gt;= readLimit<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifTrue: [^aBlock value]<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifFalse: [^collection at: (position := position + 1)]<br>
    </font><br>
    <font face="Georgia">=======================</font><br>
    nextOrEOS: endOfStreamMarker<br>
    <br>
    &nbsp;&nbsp;&nbsp; &lt;primitive: 65&gt;<br>
    &nbsp;&nbsp;&nbsp; position &gt;= readLimit<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifTrue: [^endOfStreamMarker]<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifFalse: [^collection at: (position := position + 1)]<br>
    <font face="Georgia">=======================</font><br>
    nextOrSelf<br>
    <br>
    &nbsp;&nbsp;&nbsp; &lt;primitive: 65&gt;<br>
    &nbsp;&nbsp;&nbsp; position &gt;= readLimit<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifTrue: [^self]&nbsp;&nbsp;&nbsp; "if the stream is known not to contain
    itself, then self could be the marker"<br>
    &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ifFalse: [^collection at: (position := position + 1)]<br>
    <font face="Georgia">=======================</font><br>
    <br>
    Cheers,<br>
    Bob<br>
    <font face="Georgia"><br>
    </font>
    <div class="moz-cite-prefix">On 7/22/13 8:59 PM, Levente Uzonyi
      wrote:<br>
    </div>
    <blockquote
      cite="mid:alpine.DEB.2.00.1307230159350.1719@login01.caesar.elte.hu"
      type="cite">On Mon, 22 Jul 2013, Frank Shearar wrote:
      <br>
      <br>
      <blockquote type="cite">I'm half-tempted to say "in that case the
        user should use Xtreams".
        <br>
        Because the weird behaviours around #next and #atEnd were pretty
        much<br>
        the main drivers behind it.
        <br>
        <br>
        Do you use EndOfStream like this (to allow nil objects in a
        Stream of objects)?
        <br>
      </blockquote>
      <br>
      Your question is misleading. nil can be in any stream, but #next
      will also return nil, when the stream is #atEnd. If you know that
      your stream doesn't have nils in it, then using #next is safe (and
      fast), otherwise you should not rely on #next's return value to
      decide if it was a valid read or not. That's what #atEnd is for.
      <br>
      <br>
      Signaling an Exception when a ReadStream is #atEnd should not
      really cause performance issues. It can only be a problem, when
      you are repeatedly reading from short streams. Xtreams also uses
      this technique.
      <br>
      <br>
      <br>
      Levente
      <br>
      <br>
      <blockquote type="cite">
        <br>
        frank
        <br>
        <br>
        On 22 July 2013 17:09, Chris Muller <a class="moz-txt-link-rfc2396E" href="mailto:asqueaker@gmail.com">&lt;asqueaker@gmail.com&gt;</a>
        wrote:
        <br>
        <blockquote type="cite">What if a system needs to allow nil
          objects in a Stream of objects and
          <br>
          have it be treated as just another object in the stream rather
          than
          <br>
          the EOS marker?
          <br>
          <br>
          So, maybe ReadStream&gt;&gt;#next _should_ be signaling
          EndOfStream, so the
          <br>
          sender of #next can know the difference in that scenario.&nbsp;
          Since the
          <br>
          defaultAction is ^nil, presumably we could simply change #next
          to do
          <br>
          that with no breakage...
          <br>
          <br>
          On Mon, Jul 22, 2013 at 9:02 AM, Frank Shearar
          <a class="moz-txt-link-rfc2396E" href="mailto:frank.shearar@gmail.com">&lt;frank.shearar@gmail.com&gt;</a> wrote:
          <br>
          <blockquote type="cite">EndOfStream has no references in the
            base image. It claims to be used
            <br>
            by ReadStream &gt;&gt; #next, but that's not true.
            <br>
            <br>
            Time to die/deprecate?
            <br>
            <br>
            frank
            <br>
            <br>
          </blockquote>
        </blockquote>
        <br>
        <br>
      </blockquote>
      <br>
      <br>
    </blockquote>
    <br>
  </body>
</html>