On Sun, 24 Aug 2003, Benjamin Goldberg wrote:

> Togos wrote:
> > 
> > What's the reasoning behind putting the object a
> > method is being called on in P2 instead of in the
> > first parameter of the method? I have a feeling that
> > putting it as the first parameter of the method would
> > make the lives of the python folks a little bit
> > easier. Would it make it harder for someone else?
> 
> While I've no idea about that, I don't see why you can't have it both
> ways... put it in P2 *and* as the first param, if that's the way your
> language wants it.
> 
> I think this would be useful for both Python and Perl5.


For what it's worth, you can do this in python:

    class Whatever:
        def method(self, arg):
            pass

    w = Whatever()
    Whatever.method(w, arg=1)

This is the same as:

    w = Whatever()
    w.method(arg=1)

For both of those, the P2 and P5 should be "w"
Not to mention this looks exactly like a function
call on a module:

    import module as m
    m.function(arg=1)

... Which doesn't get a "self" parameter passed in.

Old-style classes actually do that Class.meth(instance, arg)
fairly often when overriding methods. New style classes use:

    super(Thing, self).parentMethod(x,y,z)

I'm pretty sure new-style classes can also 
have "classmethods" that don't get passed a "self"
parameter either. 

I haven't really thought about how to implement
any of this stuff, but it looks like fun. :) I
guess if the python compiler knows how to send the
right things, it can't be too hard to figure out.

Sincerely,
 
Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: [EMAIL PROTECTED]
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
--------------------------------------


Reply via email to