1

I find that Mathematica's status-indication constants like $Failed, $Aborted, and $TimedOut are very useful, and would like to use them in my own code. Sometimes I'm tempted to create my own when developing packages, but that create context issues around where they're created, and prepending them with Global' all the time gets tedious.

So, it would be very helpful to have a list of all the $ constants that Mathematica uses, so that I can use them too. However, I have been unable to find such a list. Question 1: Does one exist?

Question 2: Any advice for creating similar constants that have a similarly global reach?

ibeatty
  • 2,533
  • 11
  • 22
  • Names["System\$*"]will list all inbuilt symbols which start with$`. – Patrick Stevens Sep 09 '15 at 21:00
  • Oh for heaven sakes. I should have thought of that! Thanks. – ibeatty Sep 09 '15 at 21:01
  • Alas, it appears that the three I mentioned above -- the only ones I've stumbled over -- appear to be the only status-type message symbols in that list, at least as far as I can tell from the names. All the rest seem to be variables like $Context. Oh well, back to defining my own. – ibeatty Sep 09 '15 at 21:04
  • The only reason $Failed is a status message is because there's widespread consensus that it should be used that way. You can define your own symbols and Protect them (or even set the Locked attribute) so that they can't be assigned a value. – Patrick Stevens Sep 09 '15 at 21:05
  • If I define them in a notebook, I guess I should explicitly create them in the Global context, so that they don't default to the package context, and can be accessed without an explicit context from anywhere. Concur? – ibeatty Sep 09 '15 at 21:07
  • Agreed. ${{{}}}$ – Patrick Stevens Sep 09 '15 at 21:07
  • What's wrong with putting them in the package context? – Szabolcs Sep 09 '15 at 21:15
  • $Failed is something I use frequently. I never directly pass $Aborted, it's generated during aborts. I don't think I've seen $TimedOut come up. – Szabolcs Sep 09 '15 at 21:17
  • My application involves multiple contexts. I worry that if I test something like If[response==$notReady,...] and the $notReady thrown by the generating code was in a different context than the evaluating code, the test might not evaluate to True. (I've had very traumatic experiences trying to make Mathematica respect my context intentions, so I'm gun-shy about this.) – ibeatty Sep 09 '15 at 21:18

0 Answers0