The following will show how easy I alias Ding
which is my very first ResourceFunction
and it works very well. Ding
is a more polite alternative to Beep
designed for alerting on positive or successful events. But first the standard form for using it.
ResourceFunction["Ding"][] (* at full relative system volume *)
ResourceFunction["Ding"][1/3] (* at 1/3 relative system volume *)
And now the alias so that I may use it like I would any native Mathematica symbol. I place all my frequently used aliases in my init.m
. But is aliasing like the following a good idea or standard poor practice? If so why?
Ding = ResourceFunction["Ding"] (* a very simple alias *)
Ding[] (* at full relative system volume *)
Ding[1/3] (* at 1/3 relative system volume *)
If you get a Paclet
error while trying Ding
its not the ResourceFunction
or the alias. It's a bug somewhere in Mathematica. A quick and easy solution is to prepend it with Quiet. If you recognize the error bug please inform us on what's causing it. For the record, Ding
has no Paclet
commands, syntax, or symbols in it at all and it does not attempt to install anything. The error looks like this.
Sound`ToSampledSound: The SoundFont paclet cannot be installed.
Here is the simple solution.
Quiet@ResourceFunction["Ding"] []
Quiet@Ding[] (* at full relative system volume *)
Quiet@Ding[1/3] (* at 1/3 relative system volume *)
I tried to prepend the alias but unfortunately, it did not work. I mean, it still generated an audible ding but the bug error still appeared.
Ding = Quiet@ResourceFunction["Ding"];
Ding
as the alias is not optimal because user-defined variables should not start with a capital letter (to avoid any potential name conflict with existing or future built-in names). $\endgroup$Ding = ResourceFunction["Ding", "Function"]
. $\endgroup$Ding = Quiet @ function
simply does not work because theQuiet
evaluates away immediately. You'd needDing[args___] := Quiet @ function[args]
orDing = Quiet @* function
to make that work. $\endgroup$function
was just my shorthand for whatever thing you want to abbreviate in this situation. I'd recommendDing = Quiet @*ResourceFunction["Ding", "Function"]
, though. $\endgroup$