Posted: Tue Dec 12, 2006 10:44 pm Post subject: 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.
Sponsor Sponsor
ericfourfour
Posted: Tue Dec 12, 2006 10:50 pm Post subject: (No subject)
When dealing with variables, why send an entire copy of a variable if you only need a reference to its location?
Danjen
Posted: Tue Dec 12, 2006 10:56 pm Post subject: (No subject)
So like, it lets you get the value of a variable without typing in that variable's specific name??
ericfourfour
Posted: Tue Dec 12, 2006 11:08 pm Post subject: (No subject)
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:
code:
^pointer_name
A pointer inside a record:
code:
^ (record_name.pointer_name)
Danjen
Posted: Wed Dec 13, 2006 9:13 am Post subject: (No subject)
Ah, okay that clears it up then
Tony
Posted: Wed Dec 13, 2006 11:45 am Post subject: (No subject)
Danjen wrote:
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.