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


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugd...@yahoo.com.au


--- Comment #1 from Don <clugd...@yahoo.com.au> 2009-10-01 08:09:24 PDT ---
(In reply to comment #0)
> 2. When a function takes a reference type parameter, the chanses are slim, 
> that
> the return value doesn't depend on the referenced data. 

Yes.

> So the referenced data must be immutable.

That conclusion does not follow. I don't think you're seeing all of the
benefits of 'pure'.
Consider foo(a) + foo(a). This can be changed into 2*foo(a), even though a is
not immutable.

It is true that in the case where all parameters are immutable, additional
optimisations (such as caching) can be performed. But there's more to pure than
that.

> 4. (??) Replace immutability of explicit pointer type with constness, since
> even if the referenced data is immutable, the code doesn't know, where the
> immutable data ends and can access subsequent possibly mutating data. This 
> will
> instantly make any function, taking a pointer, impure. This should not apply 
> to
> objects and byref data.

That's a memory integrity issue, not a purity issue. That could only happen in
an unsafe module.

You are asking for a feature to be removed from the language, but I'm not
really sure why.

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

Reply via email to