[Cuis-dev] What is the meaning of "::" in code examples ?

Alexandre Rousseau yalexr at gmail.com
Thu Mar 9 22:52:25 PST 2023


 Thanks for the link.

* Cascades
> There are two kinds of message cascades.


> Semicolons can be used to send a cascade of messages to the original
> receiver. In "Transcript show: 'hello'; cr" we first send the keyword
> message #show: 'hello' to the receiver Transcript, and then we send
> the unary message #cr to the same receiver.


> It is sometimes useful to send messages to the result of a message
> send. In "BoxedMorph new :: color: Color blue; openInWorld.", we send
> succeeding messages to the new BoxedMorph instance, not the BoxedMorph
> class.


So,

> lay1 beRow :: borderWidth: 1 :: borderColor: (Color black) .


can also be expressed as

> lay1 beRow; borderWidth: 1; borderColor: (Color black).

since all messages are intended for the original receiver (lay1).

And since "beRow" also returns the original object (lay1),

> lay1 beRow :: borderWidth: 1 :: borderColor: (Color black) .

works as well.

A.

> According to this page:
>
> https://cuis-smalltalk.github.io/TheCuisBook/Summary-of-Syntax.html
>
> Double-colon sends the message to the result of the previous expression. I
> would guess that would make it functionally equivalent to putting the
> previous expression in parens.
>
> So:
>
> lay1 beRow :: borderWidth: 1 :: borderColor: (Color black) .
>
> would be the same as:
>
> ((lay1 beRow) borderWidth: 1) borderColor: (Color black) .
>
> Unless I'm missing something...
>
> - Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230310/7755ec99/attachment.htm>


More information about the Cuis-dev mailing list