[prev in list] [next in list] [prev in thread] [next in thread] 

List:       squeak-dev
Subject:    [squeak-dev] Re: The Trunk: Collections-cmm.1059.mcz
From:       Chris Muller <asqueaker () gmail ! com>
Date:       2024-02-27 0:24:24
Message-ID: CANzdToHfNKuYTVAyLwJpjO54sC6u2BLkNYcFm9VsrCKV+0jUqg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Levente,

> Should SharedQueue2 inherit from Object, or should SharedQueue inherit
> > from Stream?  Because, if it walks and quacks like a Stream, should it
> > not be a Stream, able to inherit additional Stream behaviors?
>
> That's a very good question, and I think the answer is obvious. It did
> not walk and quack like a Stream until you added #atEnd. So, yeah, it's
> not a stream.


Shouldn't the question center around the nature of the behaviors themselves
rather than the names.  The four behaviors required of any Stream are:

   #atEnd
   #contents
   #next
   #nextPut:

SharedQueue[2] already had two of them, and the other two make perfect
sense for a Queue.  #isEmpty could easily have been named #atEnd in the
first place and be equally meaningful.

Does a "queue" not already seem like it "is-a" stream from a semantic
sense?  It seems like a lot of good behaviors could be inherited from
it, why should those have to be copy-and-pasted?

Are there any good arguments _against_ inheriting from Stream?

> Re: #peek:'s use of #abs vs. #negated, may I ask why you prefer
> > #negated?  For me,
>
> If you know that a number is negative and you want to make it
> non-negative, then #negated is the right message. #abs is for the case
> when you don't have any knowledge about the number's sign.


My thoughts were that not everyone reading the code would quickly know that
a #negated means "* -1"; they might believe it means, "ensure it's
negative, even if it's already negative".  That's why I used #abs there.


> >     - #abs ensures it's positive, whereas
> >     - #negated creates a dependency on the line above.
>
> You didn't have those concerns while using #negated in #peekBack: to
> create a non-negative number from a negative number.


Only because there is no equivalent of #abs to force a number negative.
#negated is only for toggling.  If there were some #ensureNegative as #abs
is like "ensurePositive", then I would've used it.  I almost want to write
"abs" and "abs negated".

I don't feel strongly about it, though.  I can switch it to use #negated
after we decide what to do with SharedQueue[2], which I do feel could
benefit from inheriting from Stream.  I wish I could understand why you're
against that.

Regards,
  Chris

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_quote"><div>Hi \
Levente,</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px \
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; Should \
SharedQueue2 inherit from Object, or should SharedQueue inherit <br> &gt; from \
Stream?   Because, if it walks and quacks like a Stream, should it <br> &gt; not be a \
Stream, able to inherit additional Stream behaviors?<br> <br>
That&#39;s a very good question, and I think the answer is obvious. It did <br>
not walk and quack like a Stream until you added #atEnd. So, yeah, it&#39;s <br>
not a stream.  </blockquote><div><br></div><div>Shouldn&#39;t the question center \
around the nature of the behaviors themselves rather than the names.   The four \
behaviors required of any Stream are:</div><div><br></div><div>     #atEnd</div><div> \
#contents</div><div>     #next</div><div>     \
#nextPut:</div><div><br></div><div>SharedQueue[2] already had two of them, and the \
other two make perfect sense for a Queue.   #isEmpty could easily have been named \
#atEnd in the first place and be equally meaningful.</div><div><br></div><div>Does a \
&quot;queue&quot; not already seem  like it &quot;is-a&quot; stream from a semantic \
sense?   It seems like a lot of good behaviors could be inherited from it,  why \
should those have to be copy-and-pasted?</div><div><br></div><div>Are there any good \
arguments _against_ inheriting from Stream?</div><div><br></div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">&gt; Re: #peek:&#39;s use of #abs vs. #negated, \
may I ask why you prefer <br> &gt; #negated?   For me,<br>
<br>
If you know that a number is negative and you want to make it <br>
non-negative, then #negated is the right message. #abs is for the case <br>
when you don&#39;t have any knowledge about the number&#39;s \
sign.</blockquote><div><br></div><div>My thoughts were that not everyone reading the \
code would quickly know  that a #negated means &quot;* -1&quot;; they might believe \
it means, &quot;ensure it&#39;s negative, even if it&#39;s already negative&quot;.   \
That&#39;s why I used #abs there.<br></div><div>  </div><blockquote \
class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex"> &gt;        - #abs ensures it&#39;s positive, \
whereas<br> &gt;        - #negated creates a dependency on the line above.<br>
<br>
You didn&#39;t have those concerns while using #negated in #peekBack: to <br>
create a non-negative number from a negative \
number.</blockquote><div><br></div><div>Only because there is no equivalent of #abs \
to force a number negative.   #negated is only for toggling.    If there were some \
#ensureNegative as #abs is like &quot;ensurePositive&quot;, then I would&#39;ve used \
it.   I almost want to write &quot;abs&quot; and &quot;abs \
negated&quot;.</div><div><br></div><div>I don&#39;t feel strongly about it, though.   \
I can switch it to use #negated after we decide what to do with SharedQueue[2], which \
I do feel could benefit from inheriting from Stream.   I wish I could understand why \
you&#39;re against that.</div><div><br></div><div>Regards,</div><div>   \
Chris</div></div></div>





[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic