Python vs D [ was Re: Bartosz about Chapel ]

Jonathan M Davis jmdavisProg at
Thu Nov 10 03:45:59 PST 2011

On Thursday, November 10, 2011 03:34:07 Walter Bright wrote:
> On 11/10/2011 2:00 AM, Russel Winder wrote:
> > Purity is not really something I understand here without some lead in.
> > I guess I failed to read part of Andrei's book ;-)
> A pure function in D is one that has no side effects. It is set by adding
> the keyword "pure" to a function, and is checked by the compiler.
> A pure function may not modify any data reachable through its parameters,
> may not read or write to any mutable global state, and can only call
> functions that also are either pure or restrict the variables they modify
> to those of the calling pure function's.
> A pure function may allocate data via new, and may throw an exception.

That's not really true anymore thanks to the distinction of strongly pure and 
weakly pure. It's true for strongly pure, but for pure as a whole, all it 
guarantees is that the function doesn't access any mutable global or static 
state and only calls functions which are pure. pure on its own makes _zero_ 
guarantees about the parameters. It's only when the parameters are immutable 
or implicitly convertible to immutable that anything about the parameters is 

- Jonathan M Davis

More information about the Digitalmars-d mailing list