Visitor pattern revisited in D
Pragma Tix
pragmatix at orange.fr
Mon Aug 27 15:20:38 PDT 2012
Am 27.08.2012 17:00, schrieb deadalnix:
> I have recently put some effort into exploring alternatives to visitor
> pattern and see what can be done in D. I ended up with a solution which
> is a real improvement compared to plein old visitor pattern and wanted
> to share this here.
Thanks 4 sharing, Once I had a hope for std.pattern (Eiffel library
like) but.. this was long time ago D 1 or so..
Maybe your code is an improvement over conventional OO code (i doubt it)
, but for sure plain old readability/ and understanding of code gets
completely lost.
Despite that, IF you want to use the visitor pattern to do AST walking,
make sure that u understand the Hierarchical Visitor Pattern.
Anyway.. I (just me) find your code hard to understand,UN-maintainable
in other words : Yet Another Reason To Consider D2 Unusable. A language
should not allow such things.
auto dispatch(
alias unhandled = function typeof(null)(t) {
throw new Exception(typeid(t).toString() ~ " is not supported
by visitor " ~ typeid(V).toString() ~ " .");
}, V, T
)(ref V visitor, T t) if(is(T == class) || is(T == interface))
....................
If you consider this as smart code you should see your doctor really
soon.. my 2 cents
More information about the Digitalmars-d-announce
mailing list