@nogc
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 11 00:02:21 PDT 2014
Walter Bright:
> I've thought of allowing "throw new ...", and yours would be in
> addition to that, in @nogc functions, but was waiting to see
> how this would play out a bit first.
It's true that currently significant parts of Phobos can't be
@nogc, but the solution is not to turn @nogc into its opposite.
See:
https://d.puremagic.com/issues/show_bug.cgi?id=12768
With a comment by monarchdodra:
>> static err = new immutable(RangeError)();
>
> I'm surprised this works. If the exception is Immutable,
> then how can we chain it? If we catch "Exception", then
> we are making something immutable mutable. If we mutate
> the exception, then not only do we break the type system,
> but it also means the code isn't actually pure:
>
> //----
> void foo() pure
> {
> static err = new immutable(RangeError)("error");
> throw err;
> }
>
> void main()
> {
> try
> foo();
> catch(Error e)
> {
> e.msg = "yo!";
> }
>
> foo(); //core.exception.RangeError at main.d(7): yo!
> }
Bye,
bearophile
More information about the Digitalmars-d
mailing list