There are currently 14 opcode variants of C<new>, not counting
C<newclass>. But all are limited when it comes to initializers.
I've now experimented (again) with C<instantiate> [1], which got
deactivate during calling conv changes.
Here is a typical sequence with new:
o = new .Integer
o = 42
and the same with instantiate:
set_args '(0,0)', .Integer, 42
o = instantiate
Both variants are almost equally fast[2], but the latter has much more
potential of passing args e.g.
o = __instantiate(.Complex, 2, 3) # [3]
o = __instantiate(.Complex, "2 + 3i")
or
cl = getclass 'MyClass'
o = __instantiate(cl, p0, p1, 'extra' => p2)
These arguments could easily passed on to the C<__init> hook, if the
class happens to be one defined in PIR, because the C<set_args> is the
same as used for function args.
What do folks think?
leo
[1] r12005
[2] creating 10 M Integers in a loop:
new: 1.53s
instantiate 1.62s
[3] the syntactic sugare doesn't exist yet, but could look like these
function calls