This is helpful actually. I’ve seen the term used a lot but never knew what it meant
I’ve had a similar noob knowledge gap that I haven’t found the answer to: what is the use case for a “box”?
a single mutable location that you can pass around as a value
The docs say “minimal mutable storage” but why would I need the boxing/unboxing mechanism
you can pass a box as an argument or store it somewhere, which you can’t do with a variable that you use with set!
So if I define
a variable x
and use set!
on it I can no longer use x
as an argument in a function call? Or are you saying this is a way to pass it by reference instead of by value so the function can also (set! x 5)
and x is now 5 at the calling site too
the latter
Ah ok!
Was there something I missed or would this be useful to add to the box section in the Racket Guide?
One way to think of a box is as a pointer: unboxing is like dereferencing.
Yes ok. That totally makes sense
More examples are always great
My cat has learnt the shortcut to rfkill
my laptop.
I don’t know the rfkill
shortcut.
But he does it approximately 19 out of 20 times he walks on my laptop.
:keyboard::tiger2:
@hyamanak has joined the channel