It’s just data

Pirate update

Some people like to do crossword puzzles, lately I've been amusing myself by getting some new feature of Python implemented on Parrot.

Here are some recent successes:

print filter(lambda x: x<5, range(10)) == range(5)
args={'a':1,'b':2,'c':3}
def f(a,b,c): return (a,b,c)
def g(b,c,a): return (a,b,c)
for j in [f,g]: print j(1,2,3)
for j in [f,g]: print j(a=1,b=2,c=3)
for j in [f,g]: print j(*[1,2,3])
for j in [f,g]: print j(**args)

The most fun discovery I have come across so far is that Subs (a.k.a. functions) are true objects, i.e., can have properties and can be specialized by overriding the invoke method.  This has allowed me to implement features like default argument defaults.

Major todos include reconciling Python and Parrot exceptions, and getting classes to work right.


Functions are objects in Python as well. Is there a correlation between their properties and your custom properties?

Posted by Yo at

There will be.

At the moment, I've implemented what I need, which is __call__ and func_defaults.

Posted by Sam Ruby at

Add your comment