Jeff Clites <[EMAIL PROTECTED]> wrote:

> a) As Sam says, in Python "y**z" is just shorthand for
> "y.__pow__(z)"--they will compile down to exactly the same thing
> (required for Python to behave correctly).

I don't think so (and you can replace with add, sub, ... FWIW). All these
binops compile to Parrot opcodes. These call the MMD dispatcher. Now
depending on the type of left and right, we e.g. call into a function
living in classes/*.pmc that does the Right Thing.

A plain PMC does the binop (if it "can" do it). If it's a an object
derived from a PMC it either delegates to the PMC or, if provided by the
user to the __pow__ function. If it's an object it does a full method
lookup for that object ...

> ... Since __pow__ isn't
> "special", we don't need anything to support it that we wouldn't need
> for any other arbitrary method, say "y.elbowCanOpener(z)".

No. One is builtin and one isn't. These are really different. The only
common thing is that the former can be overridden, while the latter is
always provided by user code.

> So I don't think an op really gives us what we want.

This sentence would obviously be true for all binops then. It isn't.

> JEff

leo

Reply via email to