I have written a package in Mathematica 11, and I would like to provide some backwards compatibility to earlier versions. An example is the function
Currently I define
Echo in the following way.
Quiet[System`Echo[x_] := (Print[x]; x);]
As far as I understand, this defines
Echo for example in version 10 where it was not part of the core language, and in version 11 it does nothing.
This is fine when I'm working inside of
Global`, but when I go into my package's
Private` I then have problems. My package seems to try to access
Private`Echo when I write just
Echo, but I would like it to access
To me this seems like it should be the default behaviour; as far as I understand other core language functions such as
Sytem` and so I think Mathematica should look inside of
System` before looking inside of
Private`, only it appears not to.
Can anybody explain to me why this doesn't work? And any suggestions for a solution would be great, thank you.
Here is some example code, which all sits in my package file.
Quiet[System`Echo[x_] := (Print[x]; x);] BeginPackage["Example`"]; myfunc::usage = ""; Begin["`Private`"]; myfunc[x_] := Echo[x^2] End; EndPackage;
I would like to be able to access
Echo both inside the package, and in a session where the package is loaded. In this current example, the call to
Echo in the package accesses
Private`Echo, which is not what I want.
EDIT2: The above code works fine, thanks to Szalbocs for pointing out a missing backtick.