Dylan variables differ from those found in C and Pascal. Instead of holding their values, Dylan variables refer to them. Conceptually, they resemble a cross between pointers and C++ references. Like references, Dylan variables may be evaluated without any indirection. Like pointers, they may be set to point to new objects whenever the programmer desires.
Furthermore, there's only one of any given numeric value in a Dylan program, at least from the programmer's point of view. All variables which refer to the integer 2—or, in Dylan-speak, are bound to the integer 2—point to the exact same thing.
let x = 2; // creates x and binds it to 2 x := 3; // rebinds x to the value 3 let y = x; // creates y, and binds it to // whatever x is bound to
If two variables are bound to one object with internal structure, the results may suprise C and Pascal programmers.
let car1 = make(<car>); // bind car1 to a // new car object car1.odometer := 10000; // set odometer let car2 = car1; // bind new name car2.odometer := 0; // reset odometer car1.odometer; // evaluates to 0!
As long as one or more variables refer to an object, it continues to exist. However, as soon as the last reference either goes out of scope or gets rebound, the object becomes garbage. Since there's no way that the program could ever refer to the object again, the garbage collector feels free to reuse the memory which once held it.
Note that Dylan variables must be bound to a particular value when they are declared. In the name of type safety and implementation efficiency, every variable must refer to some well-defined object.