[Discussion] Creating message sends via anObject >>> #selector ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Discussion] Creating message sends via anObject >>> #selector ?

marcel.taeumel
Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.


Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

marcel.taeumel
Correction: This would add #>>> to Object, not MessageSend.

Best,
Marcel

Am 12.06.2019 15:31:12 schrieb Marcel Taeumel <[hidden email]>:

Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.


Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

Stéphane Rollandin
In reply to this post by marcel.taeumel
> someObjects collect: self >>> #convert:.
-1 (since you asked :)

Stef

Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

Jakob Reschke-2
In reply to this post by marcel.taeumel
Java has had this as :: since the introduction of lambdas in Java 8. It is a shortcut replacement for trivial lambdas to omit the argument names.

In JavaScript or Python you can just pass around the bound methods as callables. Smalltalk does not have attribute/method access syntax (self.xyz) to make it work naturally in the same way (meaning it would look special/unfamiliar).

Moreover, this would look awful for messages with more than one argument. The other languages don't suffer from that because they suffer from prefix notation for message sending. ;-)

I think the original block is concise enough and does not make you wonder what it means and how it works (unless you don't know blocks and the Collection protocol).

Marcel Taeumel <[hidden email]> schrieb am Mi., 12. Juni 2019, 15:31:
Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.



Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

timrowledge
In reply to this post by Stéphane Rollandin


> On 2019-06-12, at 8:14 AM, Stéphane Rollandin <[hidden email]> wrote:
>
>> someObjects collect: self >>> #convert:.
> -1 (since you asked :)

I have to agree; I really don't like the
`someObjects collect: #message`
thing either. Just ain't natural.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
May the bugs of many programs nest on your hard drive.



Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

Tobias Pape

> On 12.06.2019, at 18:42, tim Rowledge <[hidden email]> wrote:
>
>
>
>> On 2019-06-12, at 8:14 AM, Stéphane Rollandin <[hidden email]> wrote:
>>
>>> someObjects collect: self >>> #convert:.
>> -1 (since you asked :)
>
> I have to agree; I really don't like the
> `someObjects collect: #message`
> thing either. Just ain't natural.

Also, it "lifts" things to a meta-level, where the block thing is more base-level…

That said, I do think we nee something for "write-along" scripting, repl-style.
In that case, the '…ect: #…' thing comes in handy; but it's a different use case.



-t

Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

Stéphane Rollandin
In reply to this post by timrowledge
> I have to agree; I really don't like the
> `someObjects collect: #message`
> thing either. Just ain't natural.

This one is fine with me though...

Stef

Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

Francisco Garau-2
In reply to this post by marcel.taeumel
Have you looked at the Higher Order Messaging from Marcel Weiher?

http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf


On 12 Jun 2019, at 14:31, Marcel Taeumel <[hidden email]> wrote:

Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.



Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

marcel.taeumel
Hi Francisco,

thanks for sharing. :-) Yes, I am familiar with this work. It is really interesting to see such ideas tackling the line between being language extensions and libraries. Such HOM constructs change the appearance of traditional Smalltalk code. Yet, I got used to passing blocks (and closures) around --- which wasn't possible in Smalltalk-76 ... if I recall correctly. One could still use instances of MessageSend to manage callbacks.

Best,
Marcel

Am 13.06.2019 15:41:59 schrieb Francisco Garau <[hidden email]>:

Have you looked at the Higher Order Messaging from Marcel Weiher?

http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf


On 12 Jun 2019, at 14:31, Marcel Taeumel <[hidden email]> wrote:

Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.



Reply | Threaded
Open this post in threaded view
|

Re: [Discussion] Creating message sends via anObject >>> #selector ?

frank.lesser
hi,
adding "syntactic  sugar to Smalltalk is a bad idea", IMO.
 
first of all it covers only specific bkocks ( which are not bound to a context ) - then in terms try to debug the newly added construct - more complex IMO -
Finally it affects performance - since extra Objects have to be created & a perform: is needed.
 
Frank


Von: Squeak-dev [mailto:[hidden email]] Im Auftrag von Marcel Taeumel
Gesendet: Donnerstag, 13. Juni 2019 15:57
An: Robert via Squeak-dev
Betreff: Re: [squeak-dev] [Discussion] Creating message sends via anObject >>> #selector ?

Hi Francisco,

thanks for sharing. :-) Yes, I am familiar with this work. It is really interesting to see such ideas tackling the line between being language extensions and libraries. Such HOM constructs change the appearance of traditional Smalltalk code. Yet, I got used to passing blocks (and closures) around --- which wasn't possible in Smalltalk-76 ... if I recall correctly. One could still use instances of MessageSend to manage callbacks.

Best,
Marcel

Am 13.06.2019 15:41:59 schrieb Francisco Garau <[hidden email]>:

Have you looked at the Higher Order Messaging from Marcel Weiher?

http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf


On 12 Jun 2019, at 14:31, Marcel Taeumel <[hidden email]> wrote:

Hi, there.

One of our students was curious about whether the following expression could be somehow improved:

someObjects collect: [:each | self convert: each].

I suppose that the main goal was to remove the brackets. Similar to the existing symbol shortcut:

someObjects collect: #message.

Looking at all implementors of #value:, #cull: and alike, I suppose that a more convenient creation of a MessageSend could tackle this case directly:

someObjects collect: self >>> #convert:.

This feels strange. :-) Very strange. But maybe it's just me. I don't see the traditional [:each | ...] version as neither difficult to read nor write.

What do you think about adding the #>>> message to MessageSend for more compact instantiation? Do you see other scenarios of interest? Would it be just superfluous? Producing less readable code?

Best,
Marcel

P.S.: #>>> would be close to #>>, which is implemented on Behavior to access method objects.