You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To solve this an unpacking operator (...) could be introduced, which would unpack values when calling a function. Variadic arguments are tuples, but ... would be more useful if it could unpack any iterable value.
f=|args...|for i, arg inargs.enumerate()
print'{i}: {arg}'g=|args...|f args...# unpack the args before calling fg'one', 'two', 'three'# 0: one# 1: two# 2: threex='abc'# Strings are iterableg x..., 'extra'# The unpacked value doesn't have to be in last position# 0: a# 1: b# 2: c# 3: extra
A technical limitation is that currently the Call and CallInstance ops includes the argument count, but a flag could be introduced that tells the runtime to treat the arg count as a register, allowing the compiler to emit unpacking ops which increment a dynamic argument count.
There's currently no way to unpack variadic arguments, which makes it impossible to forward them to another variadic function:
To solve this an unpacking operator (
...
) could be introduced, which would unpack values when calling a function. Variadic arguments are tuples, but...
would be more useful if it could unpack any iterable value.A technical limitation is that currently the
Call
andCallInstance
ops includes the argument count, but a flag could be introduced that tells the runtime to treat the arg count as a register, allowing the compiler to emit unpacking ops which increment a dynamic argument count.See #417 for background discussion.
The text was updated successfully, but these errors were encountered: