Mathematica temporary variables

I wrote a package for Mathematica called MathOO. In short, it allows you to use the orientation of objects in Mathematica just like you do in Python. Read more at Voofie / MathOO :

MathOO: adding Python style object orientation to Mathematica using MathOO (running 1.0 beta) [Objectica alternative]

The problem I am facing is that I would like to have a garbage collector so that the user does not have to explicitly delete the object after using it. For instance:

NewClass[Object1]
Object1.$init$[self_]:= Return[];

In the above two lines, I just defined Object1 as a new class, and the constructor is empty. If you are familiar with Python, you should see a resemblance to __init__().

To create an instance of Object1, follow these steps:

object1 = new[Object1][]

Conclusion:

Out: object$13

$13 . , , . , . :

In:  y = Module[{x}, x[1] = 2; x]
Out: x$117

In:  FullDefinition[y]
Out: y = x$117
     Attributes[x$117] = {Temporary}
     x$117[1] = 2

y x $117, x $117 . , y 1:

In:  y = 1;

x $117 :

In:  Definition[x$117]
Out: Attributes[x$117] = {Temporary}
     x$117[1] = 2

, , . Mathematica :

, :

, Mathematica? ? Mathematica 7.0. .

+5
2

Mathematica Temporary, . , , x $117 .

  • , Module , "" , "var $modnum" Temporary Attribute. x a DownValue, , x .

  • y ​​ x$..., Out[]. : Unprotect[In, Out]; Clear[In, Out]; Protect[In, Out];.

Module, , .


MathOO ( , ), , $HistoryLength . object1 = new[Object1][];a >

+2

Mathematica - () () ( ) ( ) (ANYWAY...) DownValue "x $117 [1] = 2" - , . "x $117", {1,2}. , "x $117" GCed Mma.

[], . ( [] , , , , Clear [], Mma .)

+1

All Articles