I have a function f which takes as one of its arguments an Association object, and I would like to produce a nice usage message for it, including a proper autocomplete template.

As an example, consider the function

f[association_] := {Keys[association], Values[association]}

which turns e.g.

f[<|a -> b, c -> d|>]

into {{a, c}, {b, d}}, and so on. The natural autocomplete template to use is then

f::usage = "f[\[LeftAssociation]a\[Rule]b,c\[Rule]d,…\[RightAssociation]] 
                returns {{a,c,…},{b,d,…}}.";

and it formats nicely when I ask for ?f. However, if I try to use the template for autocomplete using Ctrl+Shift+K, I get the following:

Note, in particular, that it's somehow turned the Association symbols <| and |> into patterns to be filled in, which is obviously not the desired behaviour. This is a bit strange, particularly since <| is described by its documentation as a

Matchfix operator with built-in evaluation rules.

much like { or , so it cannot mean a template for some other variable. Moreover, this is independent of whether the separated form <| (i.e. < then |) or the single-symbol \[LeftAssociation] is used in the usage message string.

Is there some way to make the produced template include correctly-formatted <|s and |>s?

  • $\begingroup$ But then is it really going to be better for your users to get an explicit <| a -> b... |> with autocompletion instead of a single assoc pattern? Sometimes it might be but in many cases they might want to pass a variable instead of an explicitly written out association. That said, I'd also like this feature and +1 ... $\endgroup$
    – Szabolcs
    May 4, 2016 at 18:10
  • 1
    $\begingroup$ (To be honest I won't ever be passing an explicit <| a -> b... |> either, but I want the template to be dead clear on what the function expects.) $\endgroup$ May 4, 2016 at 19:15
  • $\begingroup$ Reported as a bug to WRI. Will update if I hear back from them. $\endgroup$ May 4, 2016 at 21:53

1 Answer 1


No, I don't think it's possible. The reason is that built-in symbols are plagued by the same problem.

enter image description here

I would actually consider this a bug. It's confusing and hinders usability. Plus, other operators, such as ->, are not turned into patterns.

  • $\begingroup$ Thanks, this is a good find. I'll report it to WRI when I have time. $\endgroup$ May 4, 2016 at 19:15
  • $\begingroup$ Note also that here is turned into a pattern, though in general this is not the case, particularly with options. $\endgroup$ May 4, 2016 at 19:16
  • $\begingroup$ @EmilioPisanty Also, would you kindly send this link along with your report to WRI, too: mathematica.stackexchange.com/questions/58669/… ? It's a problem that's been around for years that needs to be fixed. $\endgroup$
    – QuantumDot
    May 4, 2016 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.