Calls to struct methods and immutable
bearophile
bearophileHUGS at lycos.com
Thu Nov 15 06:36:26 PST 2012
Joseph Rushton Wakeling:
> Is it appropriate to have 'nothrow' given that the assert could
> fail?
Failing asserts produce errors, not exceptions. "nothrow" only
deals with exceptions. And thankfully in this case your D code
doesn't need to be "appropriate", because D refuses nothrow if
the function is able to throw.
> So, in practice, it seems like that function should cast it to
> immutable as it returns -- and this would be safe, no?
Try to avoid casts as much as possible in D, they are a great
source for bugs. Take a look at assumeUnique, or better make
your makeFoo pure so its output is assignable to immutable.
> By the way, I should add -- I recognize I'm deluging the list
> with a bunch of questions in these last days, and I'm very
> grateful for the amount of advice you and others have been
> giving. I hope it's not becoming too overwhelming or annoying!
For me it's not a problem: when I don't have time to answer I
don't answer :-)
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list