std.patterns: it was about time

Michel Fortin michel.fortin at michelf.com
Sun Feb 1 04:45:25 PST 2009


On 2009-01-31 22:52:09 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> In wake of the increasing power of templates in D2, I am starting the 
> std.patterns module, which is to contain boilerplate for a number of 
> common design patterns (as in the GoF book). For now I'm adding a 
> Visitor implementation, which was lying in my codebase for a while.
> 
> http://ssli.ee.washington.edu/~aalexand/d/web/phobos/std_patterns.html
> http://ssli.ee.washington.edu/~aalexand/d/web/phobos/std_patterns.d
> 
> Comments and suggestions are as always welcome.

Using mixins to implements common patterns and place them in the 
standard library is a great idea. By the way, the correct URL for the 
code seems to be: 
<http://ssli.ee.washington.edu/~aalexand/d/patterns.d>.

A general comment about the visitor pattern: if we had class extensions 
where you could add new methods to Object, then the ability to add 
overrides of those methods by extending various derived classes, you 
wouldn't even need the visitor pattern. When you're used to that in 
Objective-C, the visitor pattern feels like a clever but cumbersome 
workaround for the lack of class extensibility.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list