Mathematica 12.1 introduces Splice
that replaces the old way of using Sequence@@
to "melt" a list of entries. However, the argument matching seems to be not working as intended.
Suppose we have data = {a, b}
and the following polymorphic function definitions:
data = {a, b};
f[x_] = 1;
f[x_, y_] = 2;
Using Sequence@@
would result in the following:
f[Sequence @@ data]
(* 2 *)
But if we use Splice
f[Splice[data]]
(* 1 *)
Is this intentional or a Bug? If this is intentional, could anyone explain why such behavior is favored over the Sequence @@
method?
Sequence[]
is of course the more general approach. But it is because of this generality that one might want things to only work in e.g. lists, and that's whereSplice[]
comes in. $\endgroup$ – J. M.'s ennui♦ May 13 '20 at 1:00