Re: Pugs on Windows

2007-02-06 Thread Audrey Tang


在 Feb 6, 2007 11:07 PM 時,Gabor Szabo 寫到:


On http://www.pugscode.org/ when I click "Download"
I get to the wiki on rakudo and (yippi it works again !)
but the link to the Win32 binary builds of Pugs and Parrot
brings me to http://jnthn.net/public_html/perl6/ which is 404.


Fix the rakudo wiki to point to http://jnthn.net/perl6/ ?

Cheers,
Audrey



Re: [perl #41453] [BUG] Test failure in t/pmc/object-meths.t

2007-02-06 Thread Leopold Toetsch
Am Dienstag, 6. Februar 2007 17:54 schrieb Allison Randal:
> This is a failing test Leo added in r16783. It looks to me like calling:
>  >  o = new 'MyClass', $P0
>
> actually should call init_pmc, rather than init, even when $P0 is null.
>   Leo, are you saying the choice between init and init_pmc should be
> based on the content of the argument rather than the signature of the call?

No. I was saying that there should be just one init :vtable that is called 
with any arguments (or none) according to pdd03 calling convs.

> Allison

my 2¢
leo


PIR syntax (was: Re: What Skills Do We Need to Finish Parrot?)

2007-02-06 Thread Klaas-Jan Stol

Allison Randal wrote:

James Keenan wrote:


Which leads to my next questions:

Given a knowledge of a dynamic language (I believe there's one called 
Perl 5), what is the trajectory for learning PIR?


Is there any tutorial in the docs?


There's docs/imcc/syntax.pod. Not a tutorial, but a decent introduction.


Is the "Parrot Essentials" book (still) of any use in this regard?


It's still a good starting point, but the content needs to be updated. 
I haven't yet been successful in getting O'Reilly to release those 
chapters to the Parrot project for inclusion in the repository.


Failing that, a PIR tutorial is a good project for someone to take on. 
You interested in working on it?
It's not a tutorial, but I'm working on 
languages/PIR/docs/pirgrammar.pod (and a html version). As languages/PIR 
aims to be a kind of reference PIR implementation (well, that's my goal 
:-), it should come *very* close to the language that IMCC accepts. 
Anyway, pirgrammar.pod is a human-readable, cleaned-up version of the 
languages/PIR PGE implementation (no error handling). I also sent a 
patch that embeds examples into it.




Allison

klaas-jan



Re: Q on PIR vs PASM

2007-02-06 Thread Allison Randal

Klaas-Jan Stol wrote:

hi,

IIRC, IMCC started as a kind of pre-processor for PASM, in other words, 
it allowed more readable shortcuts for several constructs. Eventually, 
everything was translated to pure PASM, that is, 1 long list of real 
Parrot instructions (no .sub/.end blocks etc).


Yes, PIR was initially nothing more than a little syntactic sugar.

At some point, IMCC was merged with Parrot as its parser. Since then, a 
lot of additions have been done, like the .sub pragmas like :load 
,:main, :init, :outer etc. (When Perl6 and Parrot essentials was 
written, these flags were not there)


Now, my question, is it still true that every PIR construct has a PASM 
form as well, can every PIR construct be translated directly to PASM? 
That is, can one still get the same behaviour that is achieved by all 
those high-level PIR constructs like :outer(...), in PASM as well?


Ideally, yes. In practice, many tests are written in PIR these days, so 
we may not have complete coverage for the PASM syntax versions. It's one 
of those ongoing low-level tasks for cage cleaners.


Allison


Re: What Skills Do We Need to Finish Parrot?

2007-02-06 Thread Allison Randal

James Keenan wrote:


Which leads to my next questions:

Given a knowledge of a dynamic language (I believe there's one called 
Perl 5), what is the trajectory for learning PIR?


Is there any tutorial in the docs?


There's docs/imcc/syntax.pod. Not a tutorial, but a decent introduction.


Is the "Parrot Essentials" book (still) of any use in this regard?


It's still a good starting point, but the content needs to be updated. I 
haven't yet been successful in getting O'Reilly to release those 
chapters to the Parrot project for inclusion in the repository.


Failing that, a PIR tutorial is a good project for someone to take on. 
You interested in working on it?


Allison


Re: [perl #41453] [BUG] Test failure in t/pmc/object-meths.t

2007-02-06 Thread Allison Randal

This is a failing test Leo added in r16783. It looks to me like calling:

>  o = new 'MyClass', $P0

actually should call init_pmc, rather than init, even when $P0 is null. 
 Leo, are you saying the choice between init and init_pmc should be 
based on the content of the argument rather than the signature of the call?


Allison


Re: Prototype object model for Parrot

2007-02-06 Thread Allison Randal

Kevin Te wrote:
I was just starting to port Class::MOP to C PMCs, I would be happy to 
help port smop to C PMCs.


Great, let's meet on #parrot later this week.

Allison


Re: Negative array subscripts

2007-02-06 Thread Smylers
Blair Sutton writes:

> David Green wrote:
> 
> > In some ways, I like not having a [0] index at all: programmers may
> > be used to counting from zero, but normal humans start with first,
> > second, third, ... third last, second last,...
> 
> My feelings are Perl 6 should stick to 0 being the index of the first
> element of a list. Otherwise we might alienate programmers from P5 and
> nearly every other language. Couldn't the first array index be
> adjusted by adding a user defined Parrot grammar definition that
> applies the transformation +1 inside [] operators instead; maybe this
> could be accessible via a Perl "use" pragma.

Hmmm, a pragma's a bit heavyweight for this; how about being able to set
this with a special global variable -- that sure sounds handy ...

Smylers


Re: Prototype object model for Parrot

2007-02-06 Thread Kevin Te
I was just starting to port Class::MOP to C PMCs, I would be happy to 
help port smop to C PMCs.


Kevin

   Allison Randal wrote:
I spent yesterday pair programming with Sam Vilain on a prototype 
object model written in PIR. We actually wrote two prototypes. The 
first one had 2 levels of meta objects and the system was getting 
pretty convoluted, so we scrapped it and started over.


I just checked in the second prototype to compilers/smop (Simple Meta 
Object Protocol). The prototype has two classes, Class.pir, and 
Attribute.pir. The instance of Class.pir is a class object, and the 
instance of a class object is an object.


.local pmc class, init_args, myobj
init_args = new Hash
init_args['name'] = 'MyClass'
class = new 'Class', init_args
class.add_attribute('myattribute')
myobj = class.'new'( 'myattribute' => "Foo" )

The prototype code bootstraps off the existing object model, so for 
now you create a class object with "new 'Class'". Ultimately this will 
be the newclass opcode instead:


#   class = newclass 'MyClass'

An Attribute is a simple datatype that stores the attribute name, its 
type (if any), and a link back to the class that contains the 
attribute. (It's the class's pattern for the attribute, not the 
storage for the attribute value.)


This is a simple object model, but it can be used to implement as many 
meta-levels as a particular HLL needs. Each level of class object is 
just an instance of the next higher level of meta class object.


To move past bootstrapping on the current object model, the next step 
is to implement this prototype at the C PMC level, and incorporate 
much of the functionality of src/objects.c.


Allison




Re: Negative array subscripts

2007-02-06 Thread Blair Sutton

David Green wrote:

On 2/5/07, David Green wrote:
Then we wouldn't need * to count backwards, although it's still 
useful to allow us to count past the end of an array. There are all 
sorts of variations on this scheme, such as whether * is the last 
element or the one after that, etc., or whether 0 should be the first 
element or the last, and so on.


In some ways, I like not having a [0] index at all: programmers may be 
used to counting from zero, but normal humans start with first, 
second, third, ... third last, second last,...
My feelings are Perl 6 should stick to 0 being the index of the first 
element of a list. Otherwise we might alienate programmers from P5 and 
nearly every other language. Couldn't the first array index be adjusted 
by adding a user defined Parrot grammar definition that applies the 
transformation +1 inside [] operators instead; maybe this could be 
accessible via a Perl "use" pragma.


Pugs on Windows

2007-02-06 Thread Gabor Szabo

On http://www.pugscode.org/ when I click "Download"
I get to the wiki on rakudo and (yippi it works again !)
but the link to the Win32 binary builds of Pugs and Parrot
brings me to http://jnthn.net/public_html/perl6/ which is 404.

Gabor


[perl #41454] [PATCH] add 2 new tests for object method dispatch

2007-02-06 Thread via RT
# New Ticket Created by  Sam Vilain 
# Please include the string:  [perl #41454]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=41454 >



Previously, inherited method dispatch was only tested with a simple
parent/child class.  Add tests for method dispatch with three classes
in a straight line, as well as a simple 4-class diamond inheritance
heirarchy.
---
 t/pmc/object-meths.t |   93 -
 1 files changed, 91 insertions(+), 2 deletions(-)diff --git a/t/pmc/object-meths.t b/t/pmc/object-meths.t
index 403b7ff..38cfbbf 100644
--- a/t/pmc/object-meths.t
+++ b/t/pmc/object-meths.t
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 36;
+use Parrot::Test tests => 38;
 
 =head1 NAME
 
@@ -942,7 +942,7 @@ CODE
 foofoo
 OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', "super 1" );
+pir_output_is( <<'CODE', <<'OUTPUT', "super 1 - two classes" );
 .sub main :main
 .local pmc o, cl
 cl = newclass 'Parent'
@@ -973,6 +973,95 @@ Parent foo
 Parent bar
 OUTPUT
 
+pir_output_is( <<'CODE', <<'OUTPUT', "super 2 - three classes" );
+.sub main :main
+.local pmc o, p, c, g
+p = newclass 'Parent'
+c = subclass p, 'Child'
+g = subclass c, 'GrandChild'
+o = new 'GrandChild'
+o."foo"()
+.end
+
+.namespace ['Parent']
+.sub foo :method
+print "Parent foo\n"
+self."foo"()
+.end
+
+.namespace ['Child']
+.sub foo :method
+print "Child foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+
+.namespace ['GrandChild']
+.sub foo :method
+print "GrandChild foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+
+CODE
+GrandChild foo
+Child foo
+Parent foo
+OUTPUT
+
+pir_output_is( <<'CODE', <<'OUTPUT', "super 3 - diamond" );
+.sub main :main
+.local pmc o, p, c1, c2, i
+p = newclass 'Parent'
+c1 = subclass p, 'Child1'
+c2 = subclass p, 'Child2'
+i = subclass c1, 'Inbred'
+addparent i, c2
+o = new 'Inbred'
+o."foo"()
+.end
+
+.namespace ['Parent']
+.sub foo :method
+print "Parent foo\n"
+self."foo"()
+.end
+
+.namespace ['Child1']
+.sub foo :method
+print "Child1 foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+
+.namespace ['Child2']
+.sub foo :method
+print "Child2 foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+
+.namespace ['Inbred']
+.sub foo :method
+print "Inbred foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+
+CODE
+Inbred foo
+Child1 foo
+Child2 foo
+Parent foo
+OUTPUT
+
+
+
 pir_output_is( <<'CODE', <<'OUTPUT', "delegate keyed_int" );
 .sub main :main
 .local pmc cl, o


[perl #41456] [PATCH] add a Super PMC test for addparent-established inheritance trees

2007-02-06 Thread via RT
# New Ticket Created by  Sam Vilain 
# Please include the string:  [perl #41456]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=41456 >


From:  <[EMAIL PROTECTED]>

Check that if we create an inheritance tree with addparent, that it
performs like one made with subclass
---

 t/pmc/object-meths.t |   46 --
 1 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/t/pmc/object-meths.t b/t/pmc/object-meths.t
index 38cfbbf..77ae501 100644
--- a/t/pmc/object-meths.t
+++ b/t/pmc/object-meths.t
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 use lib qw( . lib ../lib ../../lib );
 use Test::More;
-use Parrot::Test tests => 38;
+use Parrot::Test tests => 39;
 
 =head1 NAME
 
@@ -942,11 +942,45 @@ CODE
 foofoo
 OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', "super 1 - two classes" );
+pir_output_is( <<'CODE', <<'OUTPUT', "super 1 - two classes, subclass" );
 .sub main :main
-.local pmc o, cl
+.local pmc o, cl, cl2
 cl = newclass 'Parent'
-cl = subclass cl, 'Child'
+#cl = subclass cl, 'Child'
+cl2 = newclass 'Child'
+addparent cl2, cl
+o = new 'Child'
+o."foo"()
+.end
+
+.namespace ['Parent']
+.sub foo :method
+print "Parent foo\n"
+self."bar"()
+.end
+.sub bar :method
+print "Parent bar\n"
+.end
+
+.namespace ['Child']
+.sub foo :method
+print "Child foo\n"
+.local pmc s
+s = new .Super, self
+s."foo"()
+.end
+CODE
+Child foo
+Parent foo
+Parent bar
+OUTPUT
+
+pir_output_is( <<'CODE', <<'OUTPUT', "super 2 - two classes, addparent" );
+.sub main :main
+.local pmc o, p, c
+p = newclass 'Parent'
+c = newclass 'Child'
+addparent c, p
 o = new 'Child'
 o."foo"()
 .end
@@ -973,7 +1007,7 @@ Parent foo
 Parent bar
 OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', "super 2 - three classes" );
+pir_output_is( <<'CODE', <<'OUTPUT', "super 3 - three classes" );
 .sub main :main
 .local pmc o, p, c, g
 p = newclass 'Parent'
@@ -1011,7 +1045,7 @@ Child foo
 Parent foo
 OUTPUT
 
-pir_output_is( <<'CODE', <<'OUTPUT', "super 3 - diamond" );
+pir_output_is( <<'CODE', <<'OUTPUT', "super 4 - diamond" );
 .sub main :main
 .local pmc o, p, c1, c2, i
 p = newclass 'Parent'



Re: Negative array subscripts

2007-02-06 Thread TSa

HaloO,

David Green wrote:
Also, this would solve a problem I've been wondering about with "funny" 
shapes being lexically scoped.  [..]

However, what if you pass the funny array along with a (funny) index?
E.g. our @flavours (1..32);
 my $favourite = get_fave(@flavours);  #returns index of selected 
flavour

 warn "Sorry, all out of @flavours[$favourite]!"
unless in_stock(@flavours, $favourite);

Which means that you'd be checking for the wrong thing to be in stock.  
(Actually, you'd also get the wrong index back from get_fave(), so in 
this limited example, the two errors would probably cancel each other 
out, but the warning message will print the wrong flavour because it's 
using the shifted index.)


It's interesting to get the signature for this &get_fave routine.
As stated it should be :(@a --> Int where {$_ ~~ @[EMAIL PROTECTED]).
The implementation of &get_favo has to be generic with respect to
the array shape otherwise a type error occurs when e.g. the shape
is (-5..-1) and the body of &get_favo is coded in terms of (0..4).

And I wonder how this generic index handling can be done by means
of * dwimmery along the lines of

  sub get_favo (@a --> Int where {$_ ~~ @[EMAIL PROTECTED])
  {
 my $idx = *+0; # how is this connected to @a?

 while check_favo(@a[$idx]) and $idx < *-0 # same as @a.end?
 {
 $idx++;
 }
 return $idx;
  }

BTW, is the where clause in the signature still seeing the outside
shape? Or does one have to say something like @a.OUTER::begin to
get at it because the @a of the sub always has got shape ([EMAIL PROTECTED])?


Regards, TSa.
--