conv text and pure

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 28 19:08:08 PDT 2013


On Monday, October 28, 2013 13:40:03 Daniel Davidson wrote:
> On Thursday, 24 October 2013 at 00:02:30 UTC, bearophile wrote:
> > Jonathan M Davis:
> >> Progress is being made on that however (as evidenced by the
> >> fact that format can now be pure in the beta for 2.064).
> > 
> > Now two of the most common "offenders" of pure/nothrow in my
> > high level code are iota() and arr.dup.
> > 
> > Bye,
> > bearophile
> 
> Is arr.dup really impure or is it something queued up to become
> pure?

It's essentially a bug that the compiler does not consider it pure. Memory 
allocation is valid in pure functions, and dup is just as pure as new is. It 
can't be pure if copying the array's elements isn't pure (e.g. if the elements 
have impure postblits), but it can certainly be pure for the built-in types 
and any user-defined types for which copying is pure.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list