# Splice matching function arguments

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?

• Using 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 where Splice[] comes in. – J. M.'s torpor May 13 '20 at 1:00
• @J.M. Thank your for your explanation! – L.Yu May 15 '20 at 3:45

## 1 Answer

The docs say that

Splice[{e1,e2,…}] is equivalent to Sequence[e1,e2,…] when the outer wrapping head is List.

In your example the outer wrapping head is f. In the Basic Examples section it gives one instance,

head[a, b, c, Splice[{1, 2, 3}], d, e]

which returns with the Splice unevaluated. So your f sees one argument, Splice[{a,b}], and returns 1 according to its definition.

• Thanks for pointing that out! – L.Yu May 15 '20 at 3:45