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

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Fri Aug 9 20:02:52 UTC 2019


The missing code snippet was


Interval>>@ verticalInterval ^ Rectangle left: self start right: self stop top: verticalInterval start bottom: verticalInterval stop

(I just inserted it into the history)

Other proposals for creating Rectangles:

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

Illustratively, Rectangle>>#intersects: could answer

(self horizontalRange intersects: aRectangle horizontalRange) and: [self verticalRange intersects: aRectangle verticalRange].

(I do not want to change this optimized implementation, this is only one possible use case for the change.)

Best,
Christoph

________________________________
Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im Auftrag von Thiede, Christoph
Gesendet: Freitag, 9. August 2019 21:55 Uhr
An: squeak-dev at lists.squeakfoundation.org
Betreff: [squeak-dev] [Squeak protocol] Proposal: Interval>>#@

Hi all,

in a recent project, we introduced a shorthand for creating rectangles:

Interval>>@ verticalInterval ^ Rectangle left: self start right: self stop top: verticalInterval start bottom: verticalInterval stop

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)
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
Smalltalk - Squeak - Dev | Mailing List Archive<http://forum.world.st/Squeak-Dev-f45488.html>
forum.world.st
Squeak - Dev forum and mailing list archive. The general-purpose Squeak developers list




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20190809/2fad6299/attachment.html>


More information about the Squeak-dev mailing list