Hi!

First, thanks for your engaging answers Richard, Stephane and the others!

The objective is to avoid unnecessary object creation in a tight loop that
interfaces between a value source and a block that processes the values.
- The source object returns multiple values as a tuple (for good reasons).
- The block processes theses values but needs another argument (at the
first place).
We do not know the number of values at compile time but know that they
match the arity of the block. Something like this (though more involved in
practice):

        (1 to: 1000) do: [:i | | args |
                args := source compute: i.
                block valueWithArguments: {i} , args ]

Since prepending the tuple with the first argument and then sending
#valueWithArguments: creates an intermediate Array, I wonder whether we can
avoid (some of) that overhead in the loop without changing this structure.
Note, "{i}, args" is only for illustration and creates an additional third
array as Steve already pointed out.

To sum up the discussion so far:
- If possible, change the structure, e.g., processing the tuple directly.
- Fast primitives exist for the special cases of 1, 2 and 3 arguments only.
- Code for > 3 arguments would have to use #valueWithArguments: after all.

Did I miss something?

Kind regards,
Steffen

Reply via email to