[Cuis-dev] What is the meaning of "::" in code examples ?
Gerald Klix
cuis.01 at klix.ch
Fri Mar 10 01:19:12 PST 2023
If you unsure, how your double-colon-constructs are parsed,
you can use the pretty printer; it is blissfully unaware of
double-colon-syntax.
On 3/10/23 7:52 AM, Alexandre Rousseau via Cuis-dev wrote:
> 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...
Nope, that's the gist of it.
It makes Cuis less lisp-like than other Smalltalks.
>>
>> - Jon
>
HTH,
Gerald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230310/cdfe9777/attachment.htm>
More information about the Cuis-dev
mailing list