Introspection of exceptions that a function can throw
Arafel
er.krali at gmail.com
Fri Feb 26 07:21:24 UTC 2021
You'd hit a very big wall with separate compilation unless you can
inspect all the code, and know where to find it.
But you'd have a problem, for instance, if you are writing a plugin (.so
/ DLL) for a product for which you only have .di files.
Or even worse the other way round: if you want to allow people to write
plugins for your product, you can't know what they'll throw, even if
they have your code, unless you enforce a `nothrow` interface.
But I guess that if you're not doing any of this, it should be
possible... although I'd still do it as a separate pre-compilation step,
so it could be cached.
On 26/2/21 3:21, James Blachly wrote:
> On 2/24/21 2:38 PM, Mark wrote:
>> Is there a way to obtain a list, at compile-time, of all the exception
>> types that a function might throw (directly or through a call to
>> another function)?
>>
>> Thanks.
>
> Crazy idea:
>
> Could a program import its own source file as a string (`string source =
> import('thisfile.d')`) and `-J<path>` , then use a lexer/parser to
> generate AST of the source code and extract exceptions potentially
> thrown by given functions -- all at compile time?
More information about the Digitalmars-d-learn
mailing list