Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: cvs commit: parrot/dynclasses pybuiltin.pmc pyclass.pmc pyfunc.pmc pylist.pmc pynone.pmc

9 views
Skip to first unread message

Leopold Toetsch

unread,
Dec 21, 2004, 6:11:35 AM12/21/04
to Sam Ruby, perl6-i...@perl.org
Sam Ruby <ru...@cvs.perl.org> wrote:
> --- nci.pmc 7 May 2004 10:33:26 -0000 1.27
> +++ nci.pmc 20 Dec 2004 22:27:11 -0000 1.28

> +=item C<PMC* get_attr_str(STRING *name)>
> +
> +Return attribute named C<name>.
> +
> +=cut
> +
> +*/
> +
> + PMC* get_attr_str(STRING* idx) {
> + return VTABLE_getprop(INTERP, SELF, idx);
> + }
> +
> }

What is the rational for this pythonism in Parrot core?

leo

Sam Ruby

unread,
Dec 21, 2004, 6:53:52 AM12/21/04
to l...@toetsch.at, perl6-i...@perl.org
Leopold Toetsch wrote:

Good catch. I've added the following directly to nci.pmc both to
capture the rationale and to record a TODO.

--- nci.pmc 20 Dec 2004 22:27:11 -0000 1.28
+++ nci.pmc 21 Dec 2004 11:50:16 -0000
@@ -159,6 +159,16 @@

=cut

+TODO: refactor into a separate subclass, and either modify Pmc2c.pm and
+enter_nci_method to directly build this subclass, or add code to morph
+NCI instances into the correct subclass later.
+
+The line of code in test case t/pie/b3 that motivates this is:
+
+ print "using", cmp.__name__
+
+Where cmp may be a NCI subroutine.
+
*/

PMC* get_attr_str(STRING* idx) {

Leopold Toetsch

unread,
Dec 21, 2004, 8:28:53 AM12/21/04
to Sam Ruby, perl6-i...@perl.org
Sam Ruby wrote:

> Leopold Toetsch wrote:
>
>> What is the rational for this pythonism in Parrot core?

> +The line of code in test case t/pie/b3 that motivates this is:


> +
> + print "using", cmp.__name__
> +
> +Where cmp may be a NCI subroutine.

Python's builtin "cmp" is basially a Sub PMC. Parrot Sub's have already
a name:

.sub main
.const .Sub c = "cmp"
print c
.end
.sub "cmp"
.end

So I think, you could translate access to the "__name__" attribute
directly to VTABLE_name(). WRT NCI: The b3.py test doesn't need it, but
I can imagine that the method name of Parrots "cmp" method is just
"__cmp" and available with VTABE_name().

leo

Sam Ruby

unread,
Dec 21, 2004, 11:56:45 AM12/21/04
to Leopold Toetsch, perl6-i...@perl.org
Leopold Toetsch wrote:

> Sam Ruby wrote:
>
>> Leopold Toetsch wrote:
>>
>>> What is the rational for this pythonism in Parrot core?
>
>> +The line of code in test case t/pie/b3 that motivates this is:
>> +
>> + print "using", cmp.__name__
>> +
>> +Where cmp may be a NCI subroutine.
>
> Python's builtin "cmp" is basially a Sub PMC. Parrot Sub's have already
> a name:

At the moment, Python's builtin "cmp" is implemented thus:

enter_nci_method(interp, my_enum_class_PyBuiltin,
F2DPTR(Parrot_PyBuiltin_cmp),
"cmp", "PIOPP");

> .sub main
> .const .Sub c = "cmp"
> print c
> .end
> .sub "cmp"
> .end
>
> So I think, you could translate access to the "__name__" attribute
> directly to VTABLE_name(). WRT NCI: The b3.py test doesn't need it, but
> I can imagine that the method name of Parrots "cmp" method is just
> "__cmp" and available with VTABE_name().

For this test to pass, the __name__ must be "cmp".

As this issue is obviously very important to you, I'll drop what I am
doing make creating a new subclass of NCI for my purposes my top priority.

- Sam Ruby

Simon Glover

unread,
Dec 21, 2004, 3:35:59 PM12/21/04
to Sam Ruby, perl6-i...@perl.org

The attached patch fixes this warning in pybuiltin.pmc:

pybuiltin.pmc: In function `make_type':
pybuiltin.pmc:76: warning: declaration of `nameprop' shadows previous local


Simon

pybuiltin.patch
0 new messages