Introspection of exceptions that a function can throw

James Blachly james.blachly at gmail.com
Fri Feb 26 02:21:29 UTC 2021


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