Change the name of ArrayBoundsException in druntime
Max Samukha
samukha at voliacable.com.removethis
Wed Oct 22 09:08:57 PDT 2008
On Wed, 22 Oct 2008 10:06:24 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
>Jarrett Billingsley wrote:
>> On Wed, Oct 22, 2008 at 6:49 AM, Jacob Carlborg <doobnet at gmail.com> wrote:
>>> I think the name ArrayBoundsException should be changed to a more general
>>> name like BoundsException, OutOfBoundsException or
>>> IndexOutOfBoundsException. Then you can use the exception in every class
>>> that have some sort of index operation and not just for an array/array
>>> class.
>>>
>>
>> 2nded.
>
>I agree. In fact I wanted to ask you all the following question. What do
>you think about the current exception hierarchy in phobos? I think it is
>terrible. Each module in std you open, the first piece of code to be
>seen is the "class ThisModuleNameException" definition. In many (most?)
>cases the module-specific exception does absolutely nothing in addition
>to its base class. The putative reader (including me) tends to scroll
>non-critically over that passage without even blinking, mumbling in a
>trance - of course, yes, each module should define at least one
>exception type.
>
>Until one day when you stop scrolling and say, wait a minute. This all
>is repetition. And there are alternatives to catching by type - you can
>catch the base type and consult a field. And in fact I don't remember
>seeing code that depends on exceptions thrown from different modules
>having different types. There's something wrong here!
>
>I think most exception classes in phobos should be yanked if it's
>possible for their functionality (often nil) to be moved in the
>Exception base class. The module name should be a member. If someone
>needs to deal with an exception thrown from a specific module, they can
>always inspect the field. We don't need a huge hierarchy for that.
>
>
>Andrei
Good idea. What about exceptions thrown from templated code? I suppose
mixins and ordinary template instances should be treated differently:
modue a;
template Foo()
{
void Foo()
{
throw new Exception;
}
}
----
module b;
alias Foo!() foo; // Exception's module should probably be 'a'
mixin Foo; // Exception's module is 'b'?
More information about the Digitalmars-d
mailing list