Closed cblp closed 7 years ago
@cblp Thanks for the comment, and sorry for the very late reply.
In talking with @elliottt, there are few reasons:
let
binding to a deref
expression that has different values if used in different locations, if memory is written to in between.Besides, I think it is too big of a change to entertain at this point.
It keeps the option open to add volatile support.
There may be a separate effectful deref for volatile variable, and a "pure" deref for non-volatile variable only.
It prevents some possible confusion with doing a
let
binding to aderef
expression that has different values if used in different locations, if memory is written to in between.
Hm, this makes sense a little. But it shouldn't be confusing for a haskeller.
Besides, I think it is too big of a change to entertain at this point.
What if I do this?
By "too big of a change", I was more referring to the (at least) ~250k LOCs of Ivory code I know about in the wild.
We can do it in several years. Introduce new function, mark old function as deprecated, remove it some years later.
Hm... I think analogy with readIORef may be involved. Reading from external resource is an impure effect.
Yes, agreed about the analogy.
In any event, I don't think we'll make this change in the GaloisInc version of Ivory we're supporting, given the backwards incompatibility and it hasn't been a hinderance to have it as an effect.
deref seems to have no side effects. Why is it bound to Ivory type?
There is a freshName call and statement emission in the source of deref.
What if deref was emitting expression? And freshName is not needed, it is a work for the CSE optimizer.
This should make code much easier.
By the way, reading volatile memory must be effectful, but Ivory can't work with volatile currently.