[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">> Should \
SharedQueue2 inherit from Object, or should SharedQueue inherit <br> > from \
Stream? Because, if it walks and quacks like a Stream, should it <br> > not be a \
Stream, able to inherit additional Stream behaviors?<br> <br>
That'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's <br>
not a stream. </blockquote><div><br></div><div>Shouldn'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 \
"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?</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">> Re: #peek:'s use of #abs vs. #negated, \
may I ask why you prefer <br> > #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't have any knowledge about the number's \
sign.</blockquote><div><br></div><div>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.<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"> > - #abs ensures it's positive, \
whereas<br> > - #negated creates a dependency on the line above.<br>
<br>
You didn'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 "ensurePositive", then I would've used \
it. I almost want to write "abs" and "abs \
negated".</div><div><br></div><div>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.</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