[phobos] Drought of functions that throw exceptions

Don Clugston dclugston at gmail.com
Thu Nov 1 08:42:28 UTC 2018


Absolutely there is a reason. Exceptions are very expensive, especially in
low-level functions. In the situation you're talking about, it's a simple
logic error in the calling code. That situation will never happen in
bug-free code.
This is very different from the situation with something like a file
operation where "disk full" is a genuine exceptional situation.



On Thu, 1 Nov 2018 at 09:02, Richard Palme via phobos <phobos at puremagic.com>
wrote:

> Is there a reason why so few functions in phobos throw
> exceptions? For example there is std.bitmanip.BitArray.flip that
> gets an index as argument and flips the bit that the index
> references, and this function does not throw an exception when
> given an invalid argument.
>
> I'd be willing to fix this, but first I wanted to ask if there
> might be a reason for this. I think that throwing an exception
> should be preferable to a segmentation fault (which happens in
> the case of BitArray.flip).
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20181101/83c301bf/attachment.html>


More information about the phobos mailing list