Re: [pirate] Setting up Pirate Parrot

2005-07-01 Thread Kevin Tew

Curtis Hall wrote:
Ok, update.  Have Pirate and Parrot running smoothly now.  Had Python 
version
2.4, which Pirate didn't like.  Had to link it to my 2.3 version.  Had 
to mess

with PATHing a bit and now I'm all set.

Wanted to introduce myself.  I'm a senior here at the UofA in Tucson, 
AZ working
in comp sci.  I'm going to be working on Pirate so as to generalize 
the IMC
emitter, plus work on some of the constructs such as slices, floor 
divisions,
power operators, and to-string operators. Hopefully, in that order, 
and by the
end of summer. I'm learning as much as I can about Pirate and Parrot 
and would

welcome any advice or expertise.

Curt

___
pirate mailing list
[EMAIL PROTECTED]
http://cornerhost.com/mailman/listinfo/pirate

I've been working on a python compiler also, feel free to take a look,,
svn co http://svn.openfoundry.org/pyparrot languages/python/pyparrot

My current boggle is how to handle the self parameter to method functions.
You can do things like this in python

def foobar( arg1, arg2 ):
   print arg1, arg2

class A():
   self.__add__ = foobar

aa = A()
print aa + 5


I'm happy to help out and discuss.
Kevin Tew


Re: [pirate] Setting up Pirate Parrot

2005-07-01 Thread Leopold Toetsch

Kevin Tew wrote:


I've been working on a python compiler also, feel free to take a look,,
svn co http://svn.openfoundry.org/pyparrot languages/python/pyparrot

My current boggle is how to handle the self parameter to method functions.
You can do things like this in python

def foobar( arg1, arg2 ):
   print arg1, arg2

class A():
   self.__add__ = foobar

aa = A()
print aa + 5


Well, the Python translator has to recognice that __add__ and such has 
a special meaning in CPython. Therefore the getattribute (in that case 
of the class - but not only) has to check for such special names and in 
that case store the Sub object for foobar into the A namespace under 
the name __add - that is Parrot's notation for the thingy.


The rest i.e. calling the sub on the last line, is done by Parrot's MMD 
implementation.



Kevin Tew


leo



Re: [pirate] Setting up Pirate Parrot

2005-07-01 Thread Leopold Toetsch


On Jul 1, 2005, at 19:46, Michal Wallace wrote:


aa = A()
print aa + 5


Hmm. I'm pretty sure this is handled automagically by the Python pmc's 
in pirate... Using the + in pir (or the add op) actually invokes a 
dispatch


Err, *if* the python translater emits

  $Px = aa + 5

it's of course up to Parrot to call A.__add() (it one is there). If 
the Python translator creates a function call for each 'add' opcode, 
well then performance will suck.



... I'm
not 100% sure if Sam implemented it, but if so it
would be in the pmc's, not the code generator.


I'm pretty sure that he did not implement it.



Pirate doesn't have to know anything special about
__add__ because foobar is just another pmc - one
that happens to be a callable.


Well foobar is a plain subroutine.


The only tricky
part I see is that because foobar doesn't have
the explicit self parameter,



Err, why should a plain subroutine have a self parameter?


Anyway, I *think* the existing pmc's solve all
these problems.


Why not test it?

leo



Re: [pirate] Setting up Pirate Parrot

2005-07-01 Thread Michal Wallace

On Fri, 1 Jul 2005, Leopold Toetsch wrote:


Kevin Tew wrote:


I've been working on a python compiler also, feel free to take a look,,
svn co http://svn.openfoundry.org/pyparrot languages/python/pyparrot

My current boggle is how to handle the self parameter to method functions.
You can do things like this in python

def foobar( arg1, arg2 ):
   print arg1, arg2

class A():
   self.__add__ = foobar

aa = A()
print aa + 5


Well, the Python translator has to recognice that __add__ and such has a 
special meaning in CPython. Therefore the getattribute (in that case of the 
class - but not only) has to check for such special names and in that case 
store the Sub object for foobar into the A namespace under the name 
__add - that is Parrot's notation for the thingy.


The rest i.e. calling the sub on the last line, is done by Parrot's MMD 
implementation.



Hmm. I'm pretty sure this is handled automagically 
by the Python pmc's in pirate... Using the + in 
pir (or the add op) actually invokes a dispatch

method in the PMC that handles the situation. I'm
not 100% sure if Sam implemented it, but if so it
would be in the pmc's, not the code generator.

Pirate doesn't have to know anything special about
__add__ because foobar is just another pmc - one
that happens to be a callable. The only tricky
part I see is that because foobar doesn't have
the explicit self parameter, it has to be handled
differently by getattr. (In cpython there's a 
difference beween a function and a 'bound'
method, and I think the magic happens in 
getattr)


Anyway, I *think* the existing pmc's solve all
these problems.

Sincerely,

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