Visitor pattern revisited in D

deadalnix deadalnix at gmail.com
Tue Aug 28 17:28:32 PDT 2012


Le 28/08/2012 00:20, Pragma Tix a écrit :
> Am 27.08.2012 17:00, schrieb deadalnix:
> 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
>

The whole point is that you don't need to do this crazy stuff. You can 
just use it.

It make the code a lot cleaner in all other places and improve what you 
can do with a plein old visitor pattern.


More information about the Digitalmars-d-announce mailing list