Exception programming difficult

Timon Gehr timon.gehr at gmx.ch
Mon Aug 13 09:09:27 PDT 2012


On 08/13/2012 05:54 PM, Dmitry Olshansky wrote:
> On 13-Aug-12 19:50, Timon Gehr wrote:
>> On 08/13/2012 05:32 PM, Dmitry Olshansky wrote:
>>>
>>> I think the true cryptonite that melts "checked exceptions" to a pile of
>>> green goo is templated code:
>>>
>>> So (*yawn*) tell what kind of exception specification the following
>>> function should have:
>>>
>>> auto joiner(RoR, Separator)(RoR r, Separator sep);
>>>
>>> How would you guarantee upfront what kind of exceptions it can throw is
>>> beyond me. It all depends on code that you can't reach or know by the
>>> very definition of template.
>>>
>>
>> Well, presumably the exception specification would be inferred
>> automatically for templates.
>
> What's the propose then?

The same as the OT describes. Don't get me wrong, I am certainly no
proponent of adding Java-style checked exceptions to D.

> And how end user will get any idea what to put
> in his function where he uses it?

The end user is aware of what the template arguments are.

> I see one, but it's not pretty - run compiler once - see complaints,
> add requested types to throws, re-run the compiler?
>

Either add requested types to throws or catch and handle the respective
exceptions. I assume that this is basically the entire point of
statically checked exception specifications.


More information about the Digitalmars-d mailing list