At 11:50 PM -0500 2/14/04, Michal Wallace wrote:

Maybe for python, findmethod and getprop (or whatever the new eqivalent is) are the same... But I'd suspect that getprop is all any (working) python compiler will use.

I've chopped out everything but this bit, since it's perfectly valid, and I think it's the important bit -- getprop and findmethod may well do exactly the same thing on python objects, and that's just fine. From what I can tell, the rule when fetching a 'property' (that is, a named thingie tacked onto a PMC) is "return a bound method doodad if it exists, otherwise return the property result"


The big question is whether you treat the returned value as a plain scalar thing, or as a subroutine. That is, if you do:

x = object.some_name

can you then do:

x(1, 2, 3)

or not?

I'm not sure that, in the general case, too many compilers will use findmethod anyway, as I'm not sure it's too common an activity, and I think (but may be wrong) that making the result bound won't be universal at all.

This may well be a case where a python compiler actually emits a chunk 'o code, perhaps something like:

   fetchmethod METHOD, OBJECT, "Foo"
   isnull METHOD, getproperty
   bind SUB_PMC, OBJECT, METHOD
   return SUB_PMC
  getproperty:
   getprop PROPERTY, OBJECT, "Foo"
   isnull PROPERTY, whine
   return PROPERTY
  whine:
   throw UNBINDABLE_NAME, "Can't bind Foo"

or something kinda sorta like that. (Assuming we provide a bind op to turn an object/method pair into a sub PMC that, when called, acts like you called the method on the object)

I *think* I'd prefer the PMC findmethod vtable entry to return an unbound method, since I think I'd like to have the plain method invocation use that vtable entry to find the method, and if so I'd like to use the result in the cache system as well.

I've no problem providing a binding scheme as part of the core, nor of providing some sort of mutant "method_or_prop" op that looks for a method and, if no joy, looks for a property.

We may end up with some sort of compiler game here, though.
--
                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to