Re: Visitor pattern revisited in D

2012-08-28 Thread Timon Gehr
to share this here. I think this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/ An issue is that the proposed scheme does not support subclassing a node to tweak its behaviour without changing

Re: Visitor pattern revisited in D

2012-08-28 Thread deadalnix
compared to plein old visitor pattern and wanted to share this here. I think this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/ An issue is that the proposed scheme does not support subclassing

Re: Visitor pattern revisited in D

2012-08-28 Thread deadalnix
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) ||

Re: Visitor pattern revisited in D

2012-08-28 Thread Timon Gehr
with a solution which is a real improvement compared to plein old visitor pattern and wanted to share this here. I think this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/ An issue

Visitor pattern revisited in D

2012-08-27 Thread deadalnix
this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/

Re: Visitor pattern revisited in D

2012-08-27 Thread Michal Minich
On Monday, 27 August 2012 at 15:00:11 UTC, deadalnix wrote: the fastCast could probably be faster this way (I didn't checked / compiled) private U fastCast (U) (object t) { return cast(U)(cast(void*)t); } one less de/reference. btw, in your implementation should be (is(T == class) ||

Re: Visitor pattern revisited in D

2012-08-27 Thread Michal Minich
visitor pattern and wanted to share this here. I think this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/ This is nice use of d magic. If the implementation could recompute the functions

Re: Visitor pattern revisited in D

2012-08-27 Thread deadalnix
is a real improvement compared to plein old visitor pattern and wanted to share this here. I think this is short enough to be a good example to show what can be done with D capabilities. http://www.deadalnix.me/2012/08/25/visitor-pattern-revisited-in-d/ This is nice use of d magic

Re: Visitor pattern revisited in D

2012-08-27 Thread Michal Minich
-pattern-revisited-in-d/ This is nice use of d magic. If the implementation could recompute the functions pointers during compilation, this seems as nice generally function. This makes me thing of computed goto (to functions) One possibility to achieve this result for visitor is to use mixin. I

Re: Visitor pattern revisited in D

2012-08-27 Thread Pragma Tix
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,