DIP49 - Define qualified postblit

Kenji Hara k.hara.pg at gmail.com
Sun Nov 10 05:38:21 PST 2013


2013/11/10 Daniel Murphy <yebblies at nospamgmail.com>

> "Kenji Hara" <k.hara.pg at gmail.com> wrote in message
> news:mailman.336.1384083327.9546.digitalmars-d at puremagic.com...
> >
> > This is valid. Because not only strongly pure function will return unique
> > object.
> >
> > For example:
> >  immutable(int)[] foo(int[] iarr) pure { ... }
> >  int[] marr = foo([1,2,3]);
> >  // foo will never return the arr argument (without unsafe cast).
> >
>
> This one is incorrect, the value returned from foo could be an immutable
> global.  The unique conversion is only capable of changing non-mutable to
> immutable, not the other way around.
>

foo is pure, so it cannot return "immutable global".

Maybe you meant something like this?
>
> int[] foo(const(int)[] iarr) pure { ... }
>

Of course, both your case and mine are valid.

Kenji Hara
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131110/35831f89/attachment.html>


More information about the Digitalmars-d mailing list