

Ask HN: Is there a name for the concept of "value changes upon read"? - uvTwitch

I'm trying to think of a name to use to describe a value which will reliably change upon being read. Not the nature of the change, but naming this concept of change-upon-read.<p>For example, I have this, complete with syntax error:
class Alternator{ bool value; implicit cast(bool) { get { return value = !value; } } }<p>I know that this phenomenon exists in quantum physics - that the state of a particle will change due to the act of reading the particle's state - but I don't know if there is a term for it, though if there is it would be ideal.<p>I figure naming it is important, because otherwise i'm left with mystery object with dodgy tacit behaviour, which is not cool for the uninitiated.
======
shaunmaxawesome
I mean "In* quantum mechanics* a wave function* is said to "collapse" when
observed, so maybe a collapsing value?"

~~~
uvTwitch
This sounds about right; and 'collapsing' has the added benefit of sounding
inherently dangerous-handle-with-care. Thanks! :D

------
bigiain
I'm not sure what the right name for _that_ is, but I have no doubt it'll be
used to write heisenbugs...

~~~
uvTwitch
exactly why I want a name for it, to reduce heisenbug potential.

It certainly necessitates careful application, but does have it's uses in
reducing copypasta.

------
damian2000
Not sure what it was called, but some early RAM technology had this exact
behaviour. Whenever you read one bit from memory, it got toggled so you had to
immediately write it back again, which toggled it back to the correct value.

------
shaunmaxawesome
In quantum mechanics a wave function is said to "collapse" when observed so
maybe a collapsing value?

------
timecircuits
"a write"

------
shasty
Its typicaly considered the worst of all side effects of a programming
language. Ive heard it referred to only as a side effect. But there is the
issue of representation in quantum physics which is real, observation does
change the state.

Good question but programming languages avoid this, you would have to coin
your own.

------
shasty
I would call it a "volatile read". Maybe it changes the state maybe it doesnt.
Especially since we dont know yet _why_ exactly this occurs.

