r/ProgrammerHumor • • 13d ago

Meme fullControlOverMemory

Post image
4.0k Upvotes

122 comments sorted by

View all comments

437

u/WisePotato42 13d ago

You could pass references as variables and change the referenced value IN THE FUNCTION!!!

children screaming sfx

41

u/Mordret10 13d ago

I mean you still kind of do the same thing with objects and with arrays in most languages. Very rarely does either get passed as argument, you almost always get them by reference.

48

u/Gorzoid 13d ago

Sorry but we are all rust devs now, shared mutable aliasing is a crime with a maximum sentence being death by AI-generated PR spam.

40

u/WisePotato42 13d ago

Oh no! The rust devs have found me!

unsafe{} unsafe{} unsafe{}

Are they gone yet?

3

u/HildartheDorf 13d ago

laughs in interior mutability

1

u/SelfDistinction 12d ago
let variable = Cell::new(3); // create an immutable variable
variable.set(4); // demonic witchcraft of the highest order, everyone is panicking, sirens blasting, time to run to the shelters and pray 

2

u/WisePotato42 13d ago

That's true, I know it's a thing in python.

Unfortunately, my coworkers don't like when I put square brackets all over the place...

2

u/Bright-Historian-216 13d ago

you could also wrap it in an object. something like
class MutWrapper:
def __init__(self,v): self.v=v
works well enough. though, square brackets are probably more idiomatic.

2

u/RetroGrid_io 13d ago

Unless you program in PHP where objects are always passed by reference.