3 ms·
Ask HN: Is there a name for the concept of "value changes upon read"?
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.
For example, I have this, complete with syntax error:
class Alternator{ bool value; implicit cast(bool) { get { return value = !value; } } }
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.
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 14y agoI mean "In* quantum mechanics* a wave function* is said to "collapse" when observed, so maybe a collapsing value?"
- uvTwitch 14y agoThis sounds about right; and 'collapsing' has the added benefit of sounding inherently dangerous-handle-with-care. Thanks! :D
- bigiain 14y agoI'm not sure what the right name for _that_ is, but I have no doubt it'll be used to write heisenbugs...
- uvTwitch 14y agoexactly 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 14y agoNot 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 14y agoIn quantum mechanics a wave function is said to "collapse" when observed so maybe a collapsing value?
- shasty 14y agoIts 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 14y agoI would call it a "volatile read". Maybe it changes the state maybe it doesnt. Especially since we dont know yet why exactly this occurs.
- timecircuits 14y ago"a write"