Leopold Toetsch wrote:
> 
> Above Parrot interface function tries to locate Sub objects in the
> namespace of the invocant's class and in the MRO of it. When you go back
> to the PIR translation of your code there is e.g.
> 
>   class Foo:
>     def g(self,y):
> 
> I have translated this to:
> 
> .namespace ["Foo"]
> .sub g
>     .param pmc self
> 
> Therefore all the static / default / common "methods" inside Python code
> would be callable with the plain Parrot method call syntax.
> 
> The classname contributes the namespace. The sub declaration creates an
> entry in that namespace, which is retrievable as:
> 
>   func = findglobal "Foo", "g"

Honestly, I don't believe that that is workable for Python.  Modules are
global in Python.  Classes are lexically scoped.  All subs emitted by
Pirate are @anon.

Modules are namespaces and can contain classes, functions, and
variables.  The way to retrieve a method from a Python class defined in
module __main__ would be:

  $P1 = findglobal "__main__", "Foo"
  getattribute $P2, $P1, 'g'

- Sam Ruby

Reply via email to