659
pointers are very eleganto
(lemmy.world)
Post funny things about programming here! (Or just rant about your favourite programming language.)
So it's sort of like "proxying" through pointers to enforce memory isolation?
I'm not entirely sure what you mean by memory isolation here, but the basic idea is that if you have a pointer to something then you know where it is located in memory and you can write in it, that's the whole idea of passing by address in C.
Now pointers themselves are merely variables. Yes they have a special meaning, they "point" to something and you can dereference them with the
*
operator, but at the end of the day they're still variables. They have a physical existence in memory or CPU registers, and their content is simply the address to which you want to point. Once you accept this, then the idea of the address of a pointer (ie the location of the variable you're calling "pointer", and not the address it contains) is not strange anymore and you can perfectly have a pointer-to-pointer in order to, among other things, pass pointers by address.Wait stop, so in other languages like C#, when you pass a variable into a function “by reference” is that just passing the pointer to the variable?
Have I been baited into using pointers my whole life?
Yes passing "by reference" is essentially the same as "by pointer" but with some syntactical sugar to make it easier to work with.