Vladimir Marangozov wrote: > > ... > > I don't see the purpose of attaching state (vars) to an algorithm > (i.e. a function). A function is also an object. > What are the benefits compared to class instances? If I follow you, you are saying that whenever you need to associate information with a function, you should wrap up the function and object into a class. But the end result of this transformation could be a program in which every single function is a class. That would be incredibly annoying, especially with Python's scoping rules. In general, it may not even be possible. Consider the following cases: * I need to associate a Java-style type declaration with a method so that it can be recognized based on its type during Java method dispatch. How would you do that with instances? * I need to associate a "grammar rule" with a Python method so that the method is invoked when the parser recognizes a syntactic construct in the input data. * I need to associate an IDL declaration with a method so that a COM interface definition can be generated from the source file. * I need to associate an XPath "pattern string" with a Python method so that the method can be invoked when a tree walker discovers a particular pattern in an XML DOM. * I need to associate multiple forms of documentation with a method. They are optimized for different IDEs, environments or languages. > And these special assignment rules because of the real overlap with > real instances... Grrr, all this is pretty dark, conceptually. I don't understand what you are saying here. > Once the puzzle would be solved, we'll discover that there would be only > one additional little step towards inheritance for modules. How weird! > Sounds like we're going to metaclass again... I don't see what any of this has to do with Barry's extremely simple idea. Functions *are objects* in Python. It's too late to change that. Objects can have properties. Barry is just allowing arbitrary properties to be associated with functions. I don't see where there is anything mysterious here. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself "I and my companions suffer from a disease of the heart that can only be cured with gold", Hernan Cortes
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4