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
