
-----------------------------------
Danjen
Tue Dec 12, 2006 10:44 pm

Why Pointers
-----------------------------------
In what situation would you use pointers and what are they? As far as I can tell, they are just used to check the next value in a sequence. :?

-----------------------------------
ericfourfour
Tue Dec 12, 2006 10:50 pm


-----------------------------------
When dealing with variables, why send an entire copy of a variable if you only need a reference to its location?

-----------------------------------
Danjen
Tue Dec 12, 2006 10:56 pm


-----------------------------------
So like, it lets you get the value of a variable without typing in that variable's specific name??

-----------------------------------
ericfourfour
Tue Dec 12, 2006 11:08 pm


-----------------------------------
If you want to be simple, I guess that sums it up.

In Turing you can dereference but you cannot reference. That is one of the downsides of Turing. :( There is a function called addr but it returns the address as an integer, not a pointer.

Dereference gets the variable the pointer is pointing to. Reference gets a pointer pointing to the variable.

To dereference use:
^pointer_name

A pointer inside a record:
^ (record_name.pointer_name)

-----------------------------------
Danjen
Wed Dec 13, 2006 9:13 am


-----------------------------------
Ah, okay that clears it up then  :)

-----------------------------------
Tony
Wed Dec 13, 2006 11:45 am


-----------------------------------
So like, it lets you get the value of a variable without typing in that variable's specific name??

Better yet, you can switch where the pointer points to, and perform the same operations on a different "variable", without really needing to know which one exactly it is.
