Paper acknowledges positively D's approach to purity (locally pure)

Bruno Medeiros brunodomedeiros+spam at com.gmail
Fri Sep 19 04:31:58 PDT 2008


Andrei Alexandrescu wrote:
> bearophile wrote:
>> Andrei Alexandrescu:
>>> It's a great honor and validation to be acknowledged in a paper of
>>> such quality and to see D's approach to purity not only mentioned,
>>> but in praise terms nonetheless (section 9).
>>
>> It seems to contain some comments that are not a praise too:
>>
>>> While this approach avoids the need to eliminate mutable state and
>>> determinism from the global scope, there is a substantial cost in
>>> expressivity as it prevents pure functions from making any use of
>>> impure functions and methods. The result is essentially of a
>>> partition of the program into imperative and purely functional
>>> portions, whereas our approach allows pure functions to make full
>>> use of the rest of the program, limited only by the references they
>>> hold.<
> 
> Any paper will mention the disadvantages of related work in the 
> pertinent section. I'm not worried about that at all. Their system is 
> more expressive but also considerably more complex. That's not 
> necessarily bad, it's a different point in tradeoff space.
> 

I haven't yet read the whole paper, haven't had the time yet, but, are 
we really restricted to the "Functions marked with the pure keyword must 
have only invariant arguments, can only read invariant global state,
and can only call other pure methods." ?
Don and I discussed an idea some time ago, called partially pure 
functions (aka locally pure, aka contextually pure):
http://www.digitalmars.com/d/archives/digitalmars/D/Idea_partially_pure_functions_70762.html
which would lift some of those restrictions, in a way that is safe and 
sound, thus allowing more expressiveness (significantly, IMO).




As a side note, kudos to that paper for the best description of Monads 
I've seen so far:

"Monads can be defined to allow writing in a more imperative
style, in which each operation takes an input state and returns
a monad instance that wraps the result along with auxiliary
information such as side effects."

I've read whole pages of text about Monads that didn't explain as well 
as this paragraph what a monad is, in the general sense.


-- 
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D


More information about the Digitalmars-d-announce mailing list