Re: Code generator and visitor pattern

2010-07-18 Thread Mick Krippendorf
Mark Lawrence wrote: > On 17/07/2010 20:38, Mick Krippendorf wrote: >> >> If Java were *really* a multiple dispatch language, it wouldn't be >> necessary to repeat the accept-code for every subclass. Instead a single >> accept method in the base class would suffice. In fact, with true >> multiple d

Re: Code generator and visitor pattern

2010-07-17 Thread Mark Lawrence
On 17/07/2010 20:38, Mick Krippendorf wrote: Karsten Wutzke wrote: The visitor pattern uses single-dispatch, that is, it determines which method to call be the type of object passed in. Say, in Python, I have an object o and want to call one of it's methods, say m. Then which of possibly many

Re: Code generator and visitor pattern

2010-07-17 Thread Mick Krippendorf
Hello, Am 16.07.2010 09:52, Michele Simionato wrote: > [os.path.walk vs os.walk] > There is a big conceptual difference between os.path.walk and os.walk. > The first works like a framework: you pass a function to it and > os.path.walk is in charging of calling it when needed. The second works > li

Re: Code generator and visitor pattern

2010-07-17 Thread Mick Krippendorf
Karsten Wutzke wrote: > The visitor pattern uses single-dispatch, that is, it determines > which method to call be the type of object passed in. Say, in Python, I have an object o and want to call one of it's methods, say m. Then which of possibly many methods m to call is determined by the type

Re: Code generator and visitor pattern

2010-07-16 Thread Thomas Jollans
On 07/16/2010 11:00 AM, Jean-Michel Pichavant wrote: > Karsten Wutzke wrote: >>> Yes, typo, I meant strictly. >>> >>> >> >> Damn, I mean strongly. At least not for identifying which methods to >> call depending on the type/s. >> >> Karsten >> > Stringly is the perfect combination of strictl

Re: Code generator and visitor pattern

2010-07-16 Thread Jean-Michel Pichavant
Karsten Wutzke wrote: Yes, typo, I meant strictly. Damn, I mean strongly. At least not for identifying which methods to call depending on the type/s. Karsten Stringly is the perfect combination of strictly and strongly. Nice one :) JM -- http://mail.python.org/mailman/listinfo/pytho

Re: Code generator and visitor pattern

2010-07-16 Thread Stefan Behnel
Carl Banks, 16.07.2010 07:50: On Jul 15, 8:33 pm, Stefan Behnel wrote: The code I referenced is from the Cython compiler, and we use it to "do stuff" with the AST. The visitor pattern is actually a pretty common way to bind code in a single place that does a certain thing to different parts of a

Re: Code generator and visitor pattern

2010-07-16 Thread Michele Simionato
On Jul 15, 7:58 pm, Karsten Wutzke wrote: > Hello, > > this is obviously a Python OO question: > > Since Python isn't stringly typed, single-dispatch isn't available per > se. So is the "double-dispatch" Visitor pattern, which is usually used > in OO systems to implement code generators. So, what

Re: Code generator and visitor pattern

2010-07-15 Thread Carl Banks
On Jul 15, 8:33 pm, Stefan Behnel wrote: > Carl Banks, 16.07.2010 01:14: > > > > > > > Around these parts, we consider the main use of most Design Patterns > > to be to work around limitations of other languages.  Visitor Pattern > > is probably the worst example of it. > > > In Python it's comple

Re: Code generator and visitor pattern

2010-07-15 Thread Paul Rubin
Karsten Wutzke writes: > Since Python isn't stringly typed, single-dispatch isn't available per > se. So is the "double-dispatch" Visitor pattern, which is usually used > in OO systems to implement code generators. So, what is the de facto > method in Python to handle source code generation? A mi

Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel
Carl Banks, 16.07.2010 01:14: Around these parts, we consider the main use of most Design Patterns to be to work around limitations of other languages. Visitor Pattern is probably the worst example of it. In Python it's completely unnecessary (at least in its boilerplate- heavy incarnation as u

Re: Code generator and visitor pattern

2010-07-15 Thread Carl Banks
On Jul 15, 11:45 am, Karsten Wutzke wrote: > On 15 Jul., 20:28, Thomas Jollans wrote: > > > On 07/15/2010 07:58 PM, Karsten Wutzke wrote: > > > > Hello, > > > > this is obviously a Python OO question: > > > > Since Python isn't stringly typed, > > > I expect this is an innocent typo, and you mean

Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson
On 15/07/2010 18:58, Karsten Wutzke wrote: Hello, this is obviously a Python OO question: Since Python isn't stringly typed, single-dispatch isn't available per se. So is the "double-dispatch" Visitor pattern, which is usually used in OO systems to implement code generators. So, what is the de

Re: Code generator and visitor pattern

2010-07-15 Thread Ian Hobson
On 15/07/2010 18:58, Karsten Wutzke wrote: Hello, this is obviously a Python OO question: Since Python isn't stringly typed, single-dispatch isn't available per se. So is the "double-dispatch" Visitor pattern, which is usually used in OO systems to implement code generators. So, what is the de

Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel
MRAB, 15.07.2010 21:33: Stefan Behnel wrote: Karsten Wutzke, 15.07.2010 20:45: Well, I'm most experienced in OO, so writing OO in Python seems like the way to start with Python. The visitor pattern uses single- dispatch, that is, it determines which method to call be the type of object passed i

Re: Code generator and visitor pattern

2010-07-15 Thread Matt McCredie
Karsten Wutzke web.de> writes: > So, what is the de facto method in Python to handle source code generation? Take a look at the NodeVisitor class in the ast module in python 2.6+. The visitor pattern is implemented in the python standard library. Matt -- http://mail.python.org/mailman/listi

Re: Code generator and visitor pattern

2010-07-15 Thread MRAB
Stefan Behnel wrote: Karsten Wutzke, 15.07.2010 20:45: Well, I'm most experienced in OO, so writing OO in Python seems like the way to start with Python. The visitor pattern uses single- dispatch, that is, it determines which method to call be the type of object passed in. Well, then do that.

Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel
Karsten Wutzke, 15.07.2010 21:00: Yes, typo, I meant strictly. Damn, I mean strongly. At least not for identifying which methods to call depending on the type/s. I think you meant "statically typed". http://c2.com/cgi-bin/wiki?StronglyTyped http://www.c2.com/cgi/wiki?StaticTyping Stefan --

Re: Code generator and visitor pattern

2010-07-15 Thread Stefan Behnel
Karsten Wutzke, 15.07.2010 20:45: Well, I'm most experienced in OO, so writing OO in Python seems like the way to start with Python. The visitor pattern uses single- dispatch, that is, it determines which method to call be the type of object passed in. Well, then do that. Put the types into a d

Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 08:45 PM, Karsten Wutzke wrote: > On 15 Jul., 20:28, Thomas Jollans wrote: >> On 07/15/2010 07:58 PM, Karsten Wutzke wrote: >> >>> Hello, >> >>> this is obviously a Python OO question: >> >>> Since Python isn't stringly typed, >> >> I expect this is an innocent typo, and you mean str

Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
> > Yes, typo, I meant strictly. > Damn, I mean strongly. At least not for identifying which methods to call depending on the type/s. Karsten -- http://mail.python.org/mailman/listinfo/python-list

Re: Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
On 15 Jul., 20:28, Thomas Jollans wrote: > On 07/15/2010 07:58 PM, Karsten Wutzke wrote: > > > Hello, > > > this is obviously a Python OO question: > > > Since Python isn't stringly typed, > > I expect this is an innocent typo, and you mean strictly. > > > single-dispatch isn't available per se. S

Re: Code generator and visitor pattern

2010-07-15 Thread Christian Heimes
> Since Python isn't stringly typed, single-dispatch isn't available per > se. So is the "double-dispatch" Visitor pattern, which is usually used > in OO systems to implement code generators. So, what is the de facto > method in Python to handle source code generation? Do you mean strongly typed l

Re: Code generator and visitor pattern

2010-07-15 Thread Thomas Jollans
On 07/15/2010 07:58 PM, Karsten Wutzke wrote: > Hello, > > this is obviously a Python OO question: > > Since Python isn't stringly typed, I expect this is an innocent typo, and you mean strictly. > single-dispatch isn't available per se. So is the "double-dispatch" Visitor > pattern, Wait, wh

Code generator and visitor pattern

2010-07-15 Thread Karsten Wutzke
Hello, this is obviously a Python OO question: Since Python isn't stringly typed, single-dispatch isn't available per se. So is the "double-dispatch" Visitor pattern, which is usually used in OO systems to implement code generators. So, what is the de facto method in Python to handle source code