pharo-users@lists.pharo.org

Any question about pharo is welcome

View all threads

Re: [vwnc] Block evaluation with n+1 arguments

SM
Steffen Märcker
Tue, Apr 11, 2023 4:04 PM

Hi Stephane,

thanks for linking the upcoming lesson. I'll have a look. :-D

Best, Steffen

stephane.ducasse@free.fr schrieb am Montag, 10. April 2023 16:03:16 (+02:00):

BTW to me when a block needs too many arguments it feels like that an object has to be born :)
With an object I can just sent or not a given extra argument.

Now I do not know enough your specific context but what I learned is that complex blocks are difficult to follow, manipulate…
so I keep block as simple as possible and else I create little objects.

This is a little lectures from a super cool forthcoming mooc

https://rmod-files.lille.inria.fr/DesignCoffeeClub/ForLearningLab/7-Lang-04-BlocksVsObjects.pdf

On 6 Apr 2023, at 15:28, Steffen Märcker merkste@web.de wrote:

Hi!

I want to evaluate a block an argument 'arg1' and additional n arguments
given in an array 'args'. The following code does the trick:

block valueWithArguments: (Array with: arg1) , args.

Is there a way to do this without the overhead of creating a new Array?
(How) Can I add additional #value:value:[...] methods to BlockClosure that
evaluate the block with n arguments directly without falling back to
#valueWithArguments: ? If yes, what's the maximum?

Cheers!
Steffen

--
Gesendet mit Vivaldi Mail. Laden Sie Vivaldi kostenlos von vivaldi.com herunter.

Hi Stephane, thanks for linking the upcoming lesson. I'll have a look. :-D Best, Steffen stephane.ducasse@free.fr schrieb am Montag, 10. April 2023 16:03:16 (+02:00): BTW to me when a block needs too many arguments it feels like that an object has to be born :) With an object I can just sent or not a given extra argument. Now I do not know enough your specific context but what I learned is that complex blocks are difficult to follow, manipulate… so I keep block as simple as possible and else I create little objects. This is a little lectures from a super cool forthcoming mooc https://rmod-files.lille.inria.fr/DesignCoffeeClub/ForLearningLab/7-Lang-04-BlocksVsObjects.pdf On 6 Apr 2023, at 15:28, Steffen Märcker <merkste@web.de> wrote: Hi! I want to evaluate a block an argument 'arg1' and additional n arguments given in an array 'args'. The following code does the trick: block valueWithArguments: (Array with: arg1) , args. Is there a way to do this without the overhead of creating a new Array? (How) Can I add additional #value:value:[...] methods to BlockClosure that evaluate the block with n arguments directly without falling back to #valueWithArguments: ? If yes, what's the maximum? Cheers! Steffen -- Gesendet mit Vivaldi Mail. Laden Sie Vivaldi kostenlos von vivaldi.com herunter.