On 08/29/2012 02:24 AM, deadalnix wrote:
Le 28/08/2012 17:39, Timon Gehr a écrit :
On 08/27/2012 05:00 PM, deadalnix wrote:
/!\ Shameless autopromotion incoming /!\
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.
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 the way the visitor
operates on it. i.e. it violates the substitution principle by default.
It does indeed. This is why I started by stating that we are interested
in object as data abstraction here, not as behavioral one.
...
There is no obvious difference between data and behaviour.
class A: Node{
auto visit(...){...}
int getFoo(){ return foo; }
}
class B: A{
override int getFoo(){ return 2*foo; }
}