2
$\begingroup$

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"];
$\endgroup$
8
  • 1
    $\begingroup$ Using 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$
    – Bob Hanlon
    Commented Sep 21, 2022 at 13:57
  • 2
    $\begingroup$ I recommend reading my answer here. Long story short: it's better to use Ding = ResourceFunction["Ding", "Function"]. $\endgroup$ Commented Sep 21, 2022 at 14:12
  • 1
    $\begingroup$ Also: Ding = Quiet @ function simply does not work because the Quiet evaluates away immediately. You'd need Ding[args___] := Quiet @ function[args] or Ding = Quiet @* function to make that work. $\endgroup$ Commented Sep 21, 2022 at 14:18
  • 2
    $\begingroup$ This might be of use: PersistResourceFunction $\endgroup$
    – Greg Hurst
    Commented Sep 21, 2022 at 15:17
  • 1
    $\begingroup$ @JulesManson yes, function was just my shorthand for whatever thing you want to abbreviate in this situation. I'd recommend Ding = Quiet @*ResourceFunction["Ding", "Function"], though. $\endgroup$ Commented Sep 22, 2022 at 8:21

0

Your Answer

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