Le 20/02/2012 21:57, Andrei Alexandrescu a écrit :
On 2/20/12 1:45 PM, Jonathan M Davis wrote:
On Monday, February 20, 2012 20:42:28 deadalnix wrote:
Le 20/02/2012 20:27, Jonathan M Davis a écrit :
On Monday, February 20, 2012 11:15:08 H. S. Teoh wrote:
That's why I proposed to use runtime reflection to scan the exception
object for applicable fields. Then you get the best of both worlds:
the
message formatter doesn't need to know what the fields are, and you
get
full compile-time type checking for catching code that directly
accesses
the fields.
That would certainly be better.
- Jonathan M Davis
This is way better than Variant[string], but unimplemented ATM.
Yes, but you can use compile-time constructs to generate it. And as you
pointed out in another post, tupleof should do the trick. Regardless, the
point is that using reflection of some kind is a much better solution
than
using variant.
Agreed. Ideally adding a sort of mixin to any class would enable it for
advanced run-time information:
class DRoxException : Exception
{
mixin(enableRTTI);
... normal implementation ...
}
Andrei
Why not using std.rtti and generate run time reflection info from
compile time reflexion capability ?
This would enable that feature without writing it the language, so it
would prevent to bloat the binary when size matter and reflexion isn't
needed.