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
Message from discussion Named rules and basic OO support landed.
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
 
Leopold Toetsch  
View profile  
 More options May 11 2005, 3:19 am
Newsgroups: perl.perl6.internals
From: l...@toetsch.at (Leopold Toetsch)
Date: Wed, 11 May 2005 09:19:50 +0200
Local: Wed, May 11 2005 3:19 am
Subject: Re: Named rules and basic OO support landed.

Autrijus Tang <autri...@autrijus.org> wrote:
>     class Point {
>    has $.x;
>    has $.y;

The progress pugs makes is really impressive.

[ ... ]

> Pugs's Parrot codegen backend needs to be updated

Object attribute access, yeah. IMHO Parrot's current implementation is
wrong.

0) class construction      # a bit shortened for this example

  .local pmc cl, o, x, y   # decls for example
  cl = newclass "Point"
  addattribute cl, "x"     # "$x" what does Python then?
  addattribute cl, "y"     # "$y" what does Python then?
  o = new "Point"          # make instance -  __init not shown

1) indexed access

  $I0 = classoffset o, "Point"
  x = getattribute o, $I0       # 1st attribute at ofs + 0
  $I1 = $I0 + 1
  y = getattribute o, $I1       # 2nd attribute at ofs + 1

The offset is cached in the bytecode, you could keep it over the whole
program life-time. If the class layout ever changes, things would break
horribly. The compiler needs intimate knowledge of the attribute order
and it's usable for an array-ish object layout only.

2) named access

  x = getattribute o, "Point\0x"

This needs a full qualified attribute name "Class" ~ NUL ~ "Attribute".
That's unusable for at least Python and probably more HLLs as the
compiler has to know in which class the attribute was defined.

We should just have:

  x = getattribute o, "x"

and the set equivalent:

  setattribute o, "x", x

Comments welcome,
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.