0

Is there any way I can have I not refer to the imaginary unit?

I like the letter I, it's a terrible choice of letter for the imaginary unit, and I almost never input I directly anyway.

I would have thought there would be a way of shadowing any function I don't want to address within a particular scope, and have that scope be the one used by my notebook. But I can't figure out how to do that.

The docs for Locked do not explain this.

Karsten7
  • 27,448
  • 5
  • 73
  • 134
Lucas
  • 828
  • 4
  • 14
  • I has the Locked attribute and thus cannot be modified. – JungHwan Min Aug 24 '16 at 02:14
  • @JHM There must be some workaround though... surely... – Lucas Aug 24 '16 at 02:20
  • 1
    There isn't. It's "bulletproof". I recommend that you read the documentation on Locked. – JungHwan Min Aug 24 '16 at 02:21
  • 4
    When I was a beginner of Mathematica, I disliked I being a system symbol since my variables and function names in applications were best called I. A "trick" around this is to use Greek capital iota (alias: esc-I-esc), which looks exactly like the Latin I. With more experience, I trained myself to have all my variables begin with lower case letter (since the capital ones are always reserved for system variables anyway). – QuantumDot Aug 24 '16 at 02:25
  • When you write code in Mathematica, it is a good practice to use lowerCamelCase to avoid conflicts with the built-in functions. – JungHwan Min Aug 24 '16 at 02:26
  • @JHM Put it this way, if I can override it inside a Module[] tag, why can't I make it so the interpreter is similarly scoped? – Lucas Aug 24 '16 at 02:26
  • Module renames the variable. Try Module[{I}, I]. – QuantumDot Aug 24 '16 at 02:27
  • Module renames the symbol. i.e. Module[{I}, SymbolName[I]]. Observe that the Block version of that code does not work because Block does not rename variables. – JungHwan Min Aug 24 '16 at 02:27
  • 2
    I is a terrible choice of letter for a variable name (but reasonable for a system-level constant)... I'm so glad that they locked it down. – rm -rf Aug 24 '16 at 02:28
  • @QuantumDot but sometimes you want to use the same letters as the thing you're working on, "best practice" be damned. That's why it has the whole greek letter thing in the first place, right? If I was using some other programming language, I'd use words, but large part of the appeal is being able to use the symbols you want (except I and N) – Lucas Aug 24 '16 at 02:31
  • 1
    If you really want I, try \[CapitalIota] (input as Esc I Esc). Likewise, \[CapitalNu] for N – rm -rf Aug 24 '16 at 02:34
  • @R.M. I'd rather have to write I = ImaginaryUnit[] - or even better Import[Imaginary] or something - imagine someone at Wolfram Research realised that global variables are always a terrible idea. – Lucas Aug 24 '16 at 02:35
  • 1
    Not to mention, C, D, E, and O are built-in as well. – JungHwan Min Aug 24 '16 at 02:36
  • @JHM arggggggggg... yes. I want to rename them all! – Lucas Aug 24 '16 at 02:36
  • 2
    Perhaps you might consider writing yourself a pair of transpilers: https://en.wikipedia.org/wiki/Source-to-source_compiler With the tap of a key the text in your word processor would be translated from your desired form into Mathematica's required form, sent to Mathematica, the code runs and the resulting notebook is translated back to precisely your desired form. That will let you use every name exactly the way you want. – Bill Aug 24 '16 at 03:44
  • \[ScriptCapitalI] uses a style variant of I – Sander Aug 24 '16 at 06:05
  • @Bill I can't say that I hadn't already seriously contemplated that option. I was hoping there was an easier solution, by just to scoping the notebook differently. – Lucas Aug 24 '16 at 14:47
  • With modern languages it is much easier to write small translators than it used to be. If you did a very good job of that so that other people could understand it, easily modify it and enhance it then you might get yourself an excellent reputation from that project. – Bill Aug 27 '16 at 17:54
  • @Bill I'm not sure I want a reputation for doing that kind of thing ;) – Lucas Aug 28 '16 at 15:18
  • A reputation for producing a very high quality tool that allows you and others to easily solve a problem that would otherwise be difficult to solve would not be a bad reputation to have. Yes, some might not want to use that tool to change the case of predefined variables, but a tool that would easily and predictably allow other kinds of transformations might gain some respect. Imagine, for example, being able to easily overcome the "challenges" associated with use of subscripted variables that so many users seem compelled to use. – Bill Aug 31 '16 at 05:43
  • @Bill yes, the subscripts, they suck too. It would be nice to do things like $x = {x_0, x_1, x_2, x_3}$. A lot is just about readability. But, I don't want to spend my time working on that kind of thing, and I definitely don't want to give people the impression that I enjoy it. – Lucas Aug 31 '16 at 16:06
  • Lucas, I changed to designation on this question from closed to already has an answer. Please see the link inserted at the top of your post. I hope that you find my answer there of some use. – Mr.Wizard Sep 06 '16 at 20:08
  • @Mr.Wizard Thanks, I really didn't understand the reason given before (I did understand why some people didn't like it). This $PreRead and $PostRead system is interesting. – Lucas Sep 06 '16 at 22:17

0 Answers0