# Can I put Association brackets <| … |> in an autocompletion template?

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?

• 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 ... – Szabolcs May 4 '16 at 18:10
• (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.) – Emilio Pisanty May 4 '16 at 19:15
• Reported as a bug to WRI. Will update if I hear back from them. – Emilio Pisanty May 4 '16 at 21:53

I would actually consider this a bug. It's confusing and hinders usability. Plus, other operators, such as ->, are not turned into patterns.
• Note also that here → is turned into a pattern, though in general this is not the case, particularly with options. – Emilio Pisanty May 4 '16 at 19:16