Steffen,
if you fear performance bottlenecks, did you consider using a Stream as a single block parameter?
Your requirement sounds a bit as if you do some diving into a structure (recursion?) where "someone" (maybe even conditionally) adds another argument before the block is evaluated. I've had good results in both performance and readability with Streams in such scenarios...
Just an idea, maybe completely useless...
Joachim
Am 07.04.23 um 19:18 schrieb Noury Bouraqadi:
Steffen,
My first response, is do NOT optimize too early. The performance bottlenecks are not always where we think they are.In Pharo you can add methods to BlockClosure class. You can go up to 255 arguments IIRC.But, of course there is no primitive to handle them, so you endup writing the same code.Better usevalueWithArguments:
block valueWithArguments: (multipleArgs copyWith: singleArg)
NouryOn Apr 6 2023, at 3:28 pm, Steffen M��rcker <merkste@web.de> wrote:Hi!
I want to evaluate a block an argument 'arg1' and additional n argumentsgiven 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 thatevaluate the block with n arguments directly without falling back to#valueWithArguments: ? If yes, what's the maximum?
Cheers!Steffen-- ----------------------------------------------------------------------- Objektfabrik Joachim Tuchel mailto:jtuchel@objektfabrik.de Fliederweg 1 http://www.objektfabrik.de D-71640 Ludwigsburg http://joachimtuchel.wordpress.com Telefon: +49 7141 56 10 86 0 Fax: +49 7141 56 10 86 1