Just wrapping up an all-night coding spree...
Py-pirate can now handle:

   - functions (closures, recursion, etc)
   - global variables
   - tuples (but they turn into lists)
   - dictionaries (create, setitem, getitem, print)
   - list comprehensions
   - raise (strings only)
   - try...except (partial)
   - try...finally
   - assert

The only "tricky" parts left for the code 
generator are classes, exec/eval/import,
and possibly slices.

Right now, I'm a bit stuck with classes. I've 
got the class statement working, and it creates
a parrot class... But I'm not quite sure
how to instantiate a class.

The problem is that for:

   class Clown:
       pass

I have a lexical variable "Clown" pointing at
a parrotclass pmc.

However, when I go to instantiate Clown, I do
this:

   bozo = Clown()

There's no "new" operator like in java, so
the problem is that this looks just like a 
function call to python. So I have to figure
out whether to call "invoke" or "new"... Though
now that I think about it, I'm not really sure
what operator to use to make a new instance.

Anyway, there's no way to tell at compile-time
whether something is a constructor or a normal
function... So I'm trying to decide between two
approaches:

   * make parrotclass handle "invoke"
     this strikes me as the most efficient,
     but I'm not really confident with C 
     so I'm hesitant to try it

   * grab the lexical, check whether it's a class, 
     and if so, do "newclass" instead of "invoke".

I also thought about making a constructor into
just a normal function, but then the lexical would
have to bind to either the class or the function,
and that's no good because classes and functions 
can both have attributes in python.

Any advice?

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