Re: [PATCH] allow find-method to be inherited

2004-11-14 Thread Sam Ruby
Sam Ruby wrote:
A patch is attached, but it bears a little discussion.
Well, that didn't exactly work.  I've since commmitted these patches,
and more.  A the moment, all the python and pirate unit tests pass.  (Woot!)
In the absense of other direction, I plan to write more tests and use
them to drive the evolution of object.c and related sources.  A
description of my current thinking can be found at[1], but I am open to
any implementation which continues to pass the tests that I define.  In
fact, the unit tests can change, as long as alternatives are provided
that I can build upon to get the desired functionallity as defined by
the pirate tests.
Now that dynclasses build as a part of the 'all' target, I'm planning on
adding the dynclass tests to the 'test' target.  I've noticed that the
test target is not successful unless the all target had been built
previously, so this should not be a problem.  If anybody has an issue
with this then perhaps a 'testall' target can be defined.
- Sam Ruby
[1] http://www.intertwingly.net/blog/2004/11/14/Parrot-classes


[PATCH] allow find-method to be inherited

2004-11-09 Thread Sam Ruby
A patch is attached, but it bears a little discussion.
Methods in pie-thon are stored as attributes.  Methods in pirate are 
stored as properties.  I'm not clear on what the difference is, and 
which should be used.

In neither case are methods stored as methods, and this would prevent 
other languages which expect to invoke methods on Python objects from 
doing so - at least without this patch.  This patch allows properties to 
be transparently accessed as methods.

I'm also of the belief that getprop and/or getattribute should also be 
inheritable.  My initial testing indicates that getprop is not 
currently.  Before providing a patch, I'd like some reassurance that 
this assumption is correct.

I have a set of classes and changes I'd like to see get into the Parrot 
cvs sooner or later.  In fact, I'd prefer if it were sooner as 
maintaining what effectively is a separate branch is getting tiresome.

You can see all the changes at [1] or [2].  It is mostly new files, but 
for the files that have changed, both the full source and current diffs 
are provided.

With these changes, and with the corresponding changes to Pirate [3], 
all non-skipped Parrot and Pirate tests will pass, with the exception of 
the getprop test mentioned above.

I've also posted more thoughts and background at [4].
- Sam Ruby
[1] http://intertwingly.net/stories/2004/11/09/parrot/
[2] http://intertwingly.net/stories/2004/11/09/parrot.tgz
[3] http://intertwingly.net/stories/2004/11/09/pirate/
[4] http://www.intertwingly.net/blog/2004/11/09/Python-vs-Parrot
Index: src/objects.c
===
RCS file: /cvs/public/parrot/src/objects.c,v
retrieving revision 1.123
diff -u -u -r1.123 objects.c
--- src/objects.c   3 Nov 2004 14:29:58 -   1.123
+++ src/objects.c   9 Nov 2004 15:41:07 -
@@ -1212,7 +1212,6 @@
 STRING *isa;
 UINTVAL start;
 INTVAL pos;
-find_in_pmc:
 
 class_name = class-vtable-whoami;
 method = Parrot_find_global(interpreter,
@@ -1287,7 +1286,7 @@
 class = curclass;
 if (class-vtable-base_type == enum_class_delegate)
 break;
-goto find_in_pmc;
+return VTABLE_find_method(interpreter, curclass, method_name);
 }
 method = Parrot_find_global(interpreter,
 VTABLE_get_string(interpreter,