[squeak-dev] [Squeak protocol] Proposal: Interval>>#@

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Mon Aug 12 15:08:34 UTC 2019


Thank you for your feedback.


My motivation was a method where x and y coordinates came from different sources, and I didn't found it beautiful to separate and reassemble them. The snippet looks up a cell by the x coordinates of a column header and the y coordinates of a row header:


[cid:5dbe2728-9c02-448f-9186-40065cc967d5]


I now see that Interval>>#@ might be confusing, respecting the implementation in SequenceableCollection ...


> @ is not intuitive at all. Why would one expect to get 2 @ 3 corner: 4 @ 6

> instead of 2 @ 3 extent: 4 @ 6?

In my view, because in the expression 2 to: 4, 4 stands for the absolute end of the interval but not the relative size.

How would you think about the following protocol?

r := Rectangle horizontal: (2 to: 3) vertical: (4 to: 6).
r horizontalRange; verticalRange.

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Gesendet: Samstag, 10. August 2019 23:20:13
An: The general-purpose Squeak developers list
Betreff: Re: [squeak-dev] [Squeak protocol] Proposal: Interval>>#@

In my images i often use xCollection @ yCollection to create a (proxy) collection of points (for curves).

Le ven. 9 août 2019 à 22:39, Levente Uzonyi <leves at caesar.elte.hu<mailto:leves at caesar.elte.hu>> a écrit :
On Fri, 9 Aug 2019, Christoph Thiede wrote:

> Hi all,
>
> in a recent project, we introduced a shorthand for creating rectangles:
>
>
>
> As applying @ on two numbers converts them into a point, I think it would be
> somehow analogical to apply @ on two ranges to convert them into a
> rectangle. Above all, I experienced enough cases where I personally find it
> much more convenient to create a rectangle using
> (2 to: 4) @ (3 to: 6)

@ is not intuitive at all. Why would one expect to get 2 @ 3 corner: 4 @ 6
instead of 2 @ 3 extent: 4 @ 6?

Also, why not just use #rect:? The comment says "This is the most general
infix way to create a rectangle.".

Levente

> instead of
> 2 @ 3 corner: 4 @ 6.
>
> On the other hand, it is a bit weird that [(2 to: 4) @ (3 to: 5)] would
> produce a different output than [(2 to: 4) asArray @ (3 to: 5)]. But imho
> the rectangle construction would just be more intuitive. In general, are
> there any real senders of SequenceableCollection>>#@ which could not just
> call [aCollection with: anotherCollection collect: #@]?
>
> Looking forward to your opinions :)
>
> Best,
> Christoph
>
>
>
> --
> Sent from: http://forum.world.st/Squeak-Dev-f45488.html

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190812/4bb28bd4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 60252 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190812/4bb28bd4/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 59702 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190812/4bb28bd4/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 74844 bytes
Desc: pastedImage.png
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190812/4bb28bd4/attachment-0005.png>


More information about the Squeak-dev mailing list