Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I found a nice bug in Mathematica 9.0.1.0. Could anyone check to reproduce it?

Create a file temp.txt with one line:

Attributes[s$] = {Temporary}

Load it into Mathematica with <<.

Now calculate:

Sum[x^(-n)*y^n, {n, 0, Infinity}]

Mathematica stops responding and the only option is to quit the kernel. You can't interrupt or abort.

Now change s to a or b in the file and repeat the above. It works!

Next put the line

Attributes[s$] = {Temporary}

directly into the notebook and calculate the sum. It works!

What is so special about temporary variable s$ loaded from the file?

I used a temporary variable s$ in one of my functions and then saved the function to the file. Mathematica added the above line to the file. Everything stopped working.

share|improve this question
2  
Mathematica uses renaming to localize variables. In certain situations s will be renamed to s$ to avoid name collisions (though not in Module). You should never use such names in your code or you're risking to break things. –  Szabolcs Feb 7 at 0:31
1  
@Vlad This is not a Q/A site, not a place to rant. Please make sure that you ask a clear and answerable question. If your question was, "is this a bug and how do I work around it?", then you got the answer: if you used s$ then it's not a bug, it's user error. If you didn't then maybe. Yet you fail to tell us if you did or didn;t. –  Szabolcs Feb 7 at 0:59
1  
@Mr.Wizard I think that, if your use stopped working or happened to eventually break something, it wouldn't be a MMA bug, but a risk you were willing to take –  Rojo Feb 7 at 1:41
1  
@Vlad, as to the difference, I think at least in the notebook the line where you set the attributes shouldn't do anything. Because since it is Temporary the symbol should get removed instantly. Perhaps that's not the case if it was defined in the file? I haven't tried –  Rojo Feb 7 at 1:46
2  
I filed a bug report for this. Best advice remains: Don't use variables that end with $. Too much chance of confusing the scoping mechanism. –  Daniel Lichtblau Feb 7 at 16:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.