Is it bad for object.di to depend on core.exception?

Sean Kelly sean at invisibleduck.org
Wed Mar 7 20:06:55 PST 2012


On Mar 3, 2012, at 6:45 PM, H. S. Teoh wrote:

> So I'm still working on fixing issue 5030, which *should* have been a
> trivial fix. But I'm running into a bunch of circumstantial problems,
> among which is this new method in AssociativeArray(Key,Value):
> 
>    Value opIndex(Key key, string file=__FILE__, size_t line=__LINE__)
>    {
>    	auto p = key in *cast(Value[Key]*)(&p);
> 	if (p) return *p;
> 	throw new RangeError(file, line);
>    }
> 
> Originally it was simply Value opIndex(Key key) without any range check,
> which is probably a bad idea, so I added the throw RangeError in there.
> 
> However, this introduces a dependency from object.di to core.exception.

Have the function above call something like:

Value opIndex(…) {
    …
    throw _d_newRangeError(file, line);
}

Throwable _d_newRangeError(string, size_t); // defined in object_d (not .di).


More information about the Digitalmars-d mailing list