[Issue 8185] Pure functions and pointers

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 4 11:27:41 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8185



--- Comment #49 from art.08.09 at gmail.com 2012-06-04 11:29:39 PDT ---
As this discussions was mostly about what *should* be happening, I decided to
see what actually *is* happening right now.
It seems that the compiler will only optimize based on "pureness" if a function
takes an 'immutable T*' argument, even 'immutable(T)*' is enough to turn the
optimization off.
So, right now, it is extremely conservative - and there is no bug in the
implementation. (accessing mutable data via an immutable pointer can be done,
but would be clearly illegal, just as using a cast)

But that also means that a lot of valid optimizations aren't done, making
purity significantly less useful than it could be. Basically, only functions
that don't take any (non-immutable) references as arguments can benefit from
"pure". But it also means D can still be incrementally fixed, as long as a sane
definition of function purity is used.

But this bug is a spec issue, hence probably INVALID, as there is no
specification. Sorry for the noise.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list