659
you are viewing a single comment's thread
view the rest of the comments
[-] abraham_linksys@sh.itjust.works 5 points 1 year ago

So it's sort of like "proxying" through pointers to enforce memory isolation?

[-] AlmightySnoo@lemmy.world 9 points 1 year ago* (last edited 1 year ago)

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.

[-] Iridium@lemmy.world 7 points 1 year ago

that’s the whole idea of passing by address in C

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?

[-] olorin99@kbin.social 9 points 1 year ago

Yes passing "by reference" is essentially the same as "by pointer" but with some syntactical sugar to make it easier to work with.

load more comments (1 replies)
load more comments (1 replies)
load more comments (1 replies)
this post was submitted on 13 Jul 2023
659 points (96.6% liked)

Programmer Humor

32415 readers
579 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS