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?
<| a -> b... |>
with autocompletion instead of a singleassoc
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$<| a -> b... |>
either, but I want the template to be dead clear on what the function expects.) $\endgroup$