Le 23/02/2012 21:00, mist a écrit :
Hello!
I have been asked few question recently from a Haskell programmer about
D2 and, after experimenting a bit, have found that I really can't
provide a good answe myself, as I am not getting a design limititations
(if any).
Here is the snippet, it is pretty self-descriptive:
http://codepad.org/DBdCJYI2
Am i right, that all information about purity & Co is lost at runtime
and there is no way to write pure-aware higher-order function using
dynamic function pointers? That would have made me really sad :(
Information is lost because of what f2 accept as a type. f2'q param
isn't pure, so you gat what you except.
Within f2, the fact that your function is pure is lost. f2 accept any
function, pure or not.
pure function can be casted automatically to non pure, because it is
safe, but the other way around, it is impossible (because purity
constraint would be broken).