Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Basic compilation example (a + b)?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeff Clites  
View profile  
 More options Nov 7 2004, 10:29 pm
Newsgroups: perl.perl6.internals
From: jcli...@mac.com (Jeff Clites)
Date: Sun, 7 Nov 2004 19:29:24 -0800
Local: Sun, Nov 7 2004 10:29 pm
Subject: Basic compilation example (a + b)?
What pasm is supposed to correspond to this snippet of Python code
(assume this is inside a function, so these can be considered to be
local variables):

        a = 7
        b = 12
        c = a + b

Just a basic compilation question, brought to mind by a recent thread,
because the answer isn't obvious to me.

JEff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options Nov 8 2004, 5:47 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Mon, 8 Nov 2004 11:47:21 +0100
Local: Mon, Nov 8 2004 5:47 am
Subject: Re: Basic compilation example (a + b)?

Jeff Clites <jcli...@mac.com> wrote:
> What pasm is supposed to correspond to this snippet of Python code
> (assume this is inside a function, so these can be considered to be
> local variables):
>    a = 7
>    b = 12
>    c = a + b

Run it through pie-thon. It should produce some reasonable code. For
leaf-functions (w/o introspection i.e. calls to locals()), the lexical
handling would get dropped. And a better translator would use lexical
opcodes by index and not by name.

> JEff

leo

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Clites  
View profile  
 More options Nov 8 2004, 9:54 pm
Newsgroups: perl.perl6.internals
From: jcli...@mac.com (Jeff Clites)
Date: Mon, 8 Nov 2004 18:54:34 -0800
Local: Mon, Nov 8 2004 9:54 pm
Subject: Re: Basic compilation example (a + b)?
On Nov 8, 2004, at 2:47 AM, Leopold Toetsch wrote:

> Jeff Clites <jcli...@mac.com> wrote:
>> What pasm is supposed to correspond to this snippet of Python code
>> (assume this is inside a function, so these can be considered to be
>> local variables):

>>        a = 7
>>        b = 12
>>        c = a + b

> Run it through pie-thon. It should produce some reasonable code. For
> leaf-functions (w/o introspection i.e. calls to locals()), the lexical
> handling would get dropped. And a better translator would use lexical
> opcodes by index and not by name.

It doesn't do-the-right-thing in the cases I'm interested in:

% cat pythonClass.py
class A:
         def __add__(x,y) : return "boo"

x = A()
y = x + 3
print y
% python pythonClass.py
boo
% perl pie-thon.pl pythonClass.py | ./parrot --python -
Can't find method '__get_number' for object 'py::A'

It looks like it's trying to get the float-value of x, rather than
calling x's __add__ method.

But the part I was really wondering about is the "a + b". This is what
pie-thon.pl produces for that (you can just run it on the code fragment
"a + b"--it doesn't matter the context):

         $P1 = new PerlInt               # BINARY_ADD
         $P1 = a + b

corresponding pasm:

         find_global P18, "a"
         find_global P17, "b"
         new P16, 32      # .PerlInt
         add P16, P18, P17

That's what worries me, and what prompted the question. You don't know
at compile-time that the return type should be a PerlInt. It could be
anything--it's really up to "a". This is regarding my concern that the
p_p_p ops aren't very useful (in Python at least), and I can't figure
out what we should be using instead.

So I'm still left wondering, how *should* this compile?

JEff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leopold Toetsch  
View profile  
 More options Nov 9 2004, 2:42 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Tue, 09 Nov 2004 08:42:51 +0100
Local: Tues, Nov 9 2004 2:42 am
Subject: Re: Basic compilation example (a + b)?

Jeff Clites wrote:
> % cat pythonClass.py
> class A:
>         def __add__(x,y) : return "boo"

Only a few standard methods are implemented. __add__ IIRC isn't.

>         new P16, 32      # .PerlInt
>         add P16, P18, P17

> That's what worries me, and what prompted the question. You don't know
> at compile-time that the return type should be a PerlInt.

Yes, I've already stated that this needs fixing and I've proposed a
scheme how to fix it.

leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeff Clites  
View profile  
 More options Nov 9 2004, 3:58 am
Newsgroups: perl.perl6.internals
From: jcli...@mac.com (Jeff Clites)
Date: Tue, 9 Nov 2004 00:58:02 -0800
Local: Tues, Nov 9 2004 3:58 am
Subject: Re: Basic compilation example (a + b)?
On Nov 8, 2004, at 11:42 PM, Leopold Toetsch wrote:

> Jeff Clites wrote:

>>         new P16, 32      # .PerlInt
>>         add P16, P18, P17
>> That's what worries me, and what prompted the question. You don't
>> know at compile-time that the return type should be a PerlInt.

> Yes, I've already stated that this needs fixing and I've proposed a
> scheme how to fix it.

Fine then, but in the scheme you recently mentioned, you were
explicitly null-ing out the return register. That shouldn't be
needed--unnecessary overhead. That is, unless we're assuming the
semantics of references types--that the return register would hold a
reference object to store into, always. But I don't think we can mix
the behaviors--unless there's some special flag on a PMC to indicate
that it's a reference type, but that seems awkward. But since the
pie-thon output doesn't do that, I'll assume the plan is not to use
such reference types, if that's meant to be the canonical example.

JEff


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dan Sugalski  
View profile  
 More options Nov 9 2004, 9:14 am
Newsgroups: perl.perl6.internals
From: d...@sidhe.org (Dan Sugalski)
Date: Tue, 9 Nov 2004 09:14:36 -0500
Local: Tues, Nov 9 2004 9:14 am
Subject: Re: Basic compilation example (a + b)?
At 6:54 PM -0800 11/8/04, Jeff Clites wrote:

Right. PerlInt is wrong. The destination type for the intermediates
should be Undef, which changes itself on assignment to the proper
type.
--
                                Dan

--------------------------------------it's like this-------------------
Dan Sugalski                          even samurai
d...@sidhe.org                         have teddy bears and even
                                       teddy bears get drunk


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »