What is the semantics meaning of 'object'?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Jun 23 21:12:11 EDT 2013


On Sun, 23 Jun 2013 13:09:21 -0600, Ian Kelly wrote:

> On Sun, Jun 23, 2013 at 12:50 PM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
>> What else would you call a function that does lookups on the current
>> object's superclasses?
> 
> Well, as James Knight points out in the "Super Considered Harmful"
> article, the equivalent in Dylan is called "next-method", which isn't a
> valid identifier in Python but seems like a reasonable starting point.


I don't believe it is. Dylan's next-method is an implicit, automatically 
generated method parameter (a little like Python's "self") which holds 
the current value of the next method in the inheritance chain. Unlike 
super, it's only defined inside methods, because it is an implicit 
parameter to each method. It does not return a proxy object like Python's 
super, it's merely an alias to the next method in the chain (or Dylan's 
equivalent of False, when there is no such method), so you can't use it 
for arbitrary attribute lookups like you can with super.

I am not an expert on Dylan, but I'm pretty sure the above is correct. 
Here are some definitive references:

http://opendylan.org/books/drm/Method_Dispatch#HEADING-50-32

http://opendylan.org/documentation/intro-dylan/objects.html


next-method and super can be used for similar things, but they work in 
completely different ways, and next-method is quite limited compared to 
super. But suppose super had been named "next_method", as you suggest. 
Given a class C and an instance c, if I say `x = next_method(C, c)`, 
which method is x the next method of?

That's a trick question, of course. x is not a method at all, it is a 
proxy object such that when you do attribute lookup on it, it will return 
the appropriate attribute.



-- 
Steven



More information about the Python-list mailing list