#Reference to mutable object that cannot be re-assigned?

1 messages · Page 1 of 1 (latest)

true flax
#

Is it possible to have a variable that cannot be re-assigned, but can be mutated?
Kind of like const* foo in C++, or JS's const keyword.

If it isn't allowed, which seems like the case to me, I'm curious about this design choice.

final whale
#

const foo: *T = &bar; I suppose

#

just a constant pointer to a mutable value

true flax
#

Interestingly, this doesn't work:

const f: *Foo = &Foo{ .bar = 1 }; 

but this does:

var foo = Foo{ .bar = 1 };
const f: *Foo = &foo; 
final whale
#

aye, memory has to live somewhere

#

temporaries are constant

true flax
#

Ah, right

#

Why are temporaries constant?

solar token
true flax
#

I see