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@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@puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
_______________________________________________
phobos mailing list
phobos@puremagic.com
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to