Metaclasses?
Robb Shecter
shecter at darmstadt.gmd.de
Tue Apr 25 22:27:57 EDT 2000
Michael Hudson wrote:
>
> b) How, when you've "fixed" Python do you propose, in method bodies,
> to distinguish between local and instance variables? I might drop
> my longstanding habit of complaining about people complaining about
> the necessity of "self" if you can answer this question...
>
Ah hah. I see the problem. The language would need to be extended in
one of three ways, right? Either:
Choice A: Have a smalltalk-like instance variable declaration.
Choice B: Have a smalltalk-like local declaration in each method.
...and then, depending on which way the language changed, this would
determine the lookup rules for the variable. (ie. with choice A, it'd
be: "if it's not explicitly declared, then it's a local variable.")
Choice C: Have both A & B (like smalltalk does).
This last one is probably not necessary, and not very much like a
scripting language anymore. Now that I've written this all out, I have
to say that I like "Choice A". I come from Java, and it did bug me a
bit that there was no one easy place to see what instance variables a
class has. It made understanding the XML parser source code harder, for
example.
PS: I didn't mean to imply that Python is "broken". I guess that the
repeated "self" just rubs me the wrong way.
- Robb
More information about the Python-list
mailing list