3 ms·
Stop being scared of pointers, they aren't magic and you've been using them all along. In most high level languages you are using a pointer for any variable tha
by stormbrew 12y ago
Stop being scared of pointers, they aren't magic and you've been using them all along. In most high level languages you are using a pointer for any variable that's not a number. Which is why when you assign one variable to another and modify one it modifies it from the perspective of the other. Because they point to the same object.
Fundamentally, though, they're a value just like any other, just a number that's an index into the giant array called memory. The language provides convenient syntactic sugar to 'dereference' them, which just means evaluate the address and index to it.
Basically:
*blah
is equivalent to:
all_of_memory[blah]
which, incidentally, is equivalent to:
0[blah]
and back around again:
blah[0]
- hadoukenio 12y agoIn all my years, I've never seen anyone describe it like this. Nice one.