S5 updated

2004-09-15 Thread Larry Wall
I've been working at updating the various synopses on dev.perl.org.
In particular, you folks might like to know that the regex synopsis at

http://dev.perl.org/perl6/synopsis/S05.html

is no longer two years out of date.  :-)

Larry


NCI basics

2004-09-15 Thread p6
Hi all,

I'm using Ruby/wxWindows for the application I'm currently working on, but I've been 
fooling around with Parrot for the past few days in the hope of writing some wxWindows 
bindings to test the feasability of migrating to [cardinal | perl6]/wxWindows sometime 
in the (possibly near?)future. However, I've been stymied at the first step, because I 
can get nothing but the simplest native calls to load properly... forget about the 
callbacks!

Now I realize this is truly basic, but just to establish some sanity, I'm trying to 
call the c functions defined in the attached c file, from the attached imc file. 
The output, when I uncomment one of the offending lines looks like this:

with nothing
with int 5
Segmentation fault

I've tried many different function signatures, but only the 'vv' and 'vi' seem to 
work. All of the others cause parrot to segfault when on the line that actually loads 
the function. As such, there is never even an opportunity to invoke it. 

That it happens when I try to load the function, and not invoke it would lead me to 
believe that there is something wrong with the shared library I'm generating from the 
C source, but for the life of me, I can not figure out what I could change about the 
source, or the generation of the shared object, and my knowledge of how the C world 
fits together is still... developing.  anyhow.

I compile it like so:
gcc -fPIC -c cb.c
gcc -shared -o libcb.so cb.o
cp libcb.so runtime/parrot/dynext

I've tried to fiddle with inumerable switches even compiling it with g++ and wrapping 
it with a extern C{...}, as well as rearranging the order of the c-function 
declarations.

Now, I'm fairly confident that I'm doing something bone-headed because, for example, 
the PQt.C/QtHelloWorld.pasm works just fine. And of course, there is always that the 
first two function invocations work just swimmingly. But where I'm going astray has 
got me truly stumped.

Is there anyone who could help remove said bone from my head?

cheers,
Charles

___
NOCC, http://nocc.sourceforge.net

cb.imc
Description: Binary data

void with_nothing() {
  printf(with nothing\n);
}

void with_int(const int i) {
  printf(with int %i\n, i);
}

void with_short(const short s) {
  printf(with short %i\n, s);
}

void with_float(const float f) {
  printf(with float %f\n, f);
}

void with_string(const char* message) {
  printf(with string %s, message);
}
  


Language::Zcode - Translates Z-code to Perl (and, kinda maybe, to PIR)

2004-09-15 Thread Amir Karger
Just a year after my last status report, I've uploaded Language::Zcode
to CPAN.  It's a Perl module that lets you work with Z-code files.
(For Z-newbies: Z-code is the machine language for the Z-machine, a
virtual machine used for the Infocom text adventure games, among
others.)

Language::Zcode v0.8 includes a program called plotz, which will 
translate a Z-code file to another language. (My brother, The 
Professor, claims that this is technically compiling.) Current target
languages include:
- Perl: full (?) z3 support, meaning you can translate and run most 
  of the Infocom games (and some more modern ones)
- XML: create an XML tree with XML::Simple. I've started an XSL file
  to display the Z-code nicely, but really don't know what I'm doing.
- PIR (aha!): I just started working on this. Lame support for 25 or
  so opcodes. But I can get a working Hello, World. Mostly.

For those who don't remember, Dan Sugalski started this Fool's Errand
(http://www.fools-errand.com/) by suggesting that the Parrot VM could
be tricked into thinking it's a Z-machine.  When I screamed for help,
folks suggested a staged plan:

1. Translate Z-code to Perl

2. Translate Z-code to PIR
2a. Write some Z-code opcodes in C, to be called by the PIR (step 2).

3. Dynamically load a Z-code opcode library (2a) into Parrot, and run
a (non-translated, or just a teensy-bit translated) Z-code file as if
it's Parrot bytecode. aka the Z-machine running natively on Parrot.

4. Profit?

I've made much progress on step 1, and a tiny bit on step 2.
Still gibbering with fear about steps 2a  3.

Depending on how brave I am in upcoming months (and how much time my
kids give me), I'll be upgrading step #1 or getting serious about #2.
If the latter, I'll probably be asking lots of questions about PIR
best practices. So be nice.

Comments, advice, help will be much appreciated.

-Amir Karger



___
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com


Re: NCI basics

2004-09-15 Thread Jens Rieks
Hi!

On Wednesday 15 September 2004, [EMAIL PROTECTED] wrote:
 Is there anyone who could help remove said bone from my head?
It now prints an error message:

with nothing
with int 5
Parrot VM: PANIC: vt is an unknown signature type.
CAN_BUILD_CALL_FRAMES is disabled, add the signature to src/call_list.txt!
C file src/nci.c, line 4485
Parrot file (unknown file), line 0

jens


Re: S5 updated

2004-09-15 Thread Herbert Snorrason
Wh! :)

Childish? Who?

On Tue, 14 Sep 2004 23:22:08 -0700, Larry Wall [EMAIL PROTECTED] wrote:
 I've been working at updating the various synopses on dev.perl.org.
 In particular, you folks might like to know that the regex synopsis at
 
http://dev.perl.org/perl6/synopsis/S05.html
 
 is no longer two years out of date.  :-)
 
 Larry
 

-- 
Schwäche zeigen heißt verlieren;
härte heißt regieren.
  - Glas und Tränen, Megaherz


Re: Current state?

2004-09-15 Thread Herbert Snorrason
On Tue, 14 Sep 2004 08:43:08 -0700, Larry Wall [EMAIL PROTECTED] wrote:
 I'd suggest looking at the t/op/re_tests file from Perl 5.  It's based
 on the test suite that originally came with Henry Spencer's regular
 expression package.  It would, of course, need to be translated and
 extended, but it contains a lot of torturous tests for the standard
 rx behavior.  And it's all just a table of tests and results, so no
 Perl code at all.
So ... I suppose I'll start by (trying and) translating that into Perl
6 rules, and then ask for further guidance. :

-- 
Schwäche zeigen heißt verlieren;
härte heißt regieren.
  - Glas und Tränen, Megaherz


Updated doc and some code to reflect new Parrot_new() interface

2004-09-15 Thread Stéphane Payrard

--- ./src/test_main.c.old   2004-01-29 15:49:44.0 +0100
+++ ./src/test_main.c   2004-09-15 14:47:07.113244016 +0200
@@ -72,7 +72,7 @@
 char *filename;
 Parrot_PackFile pf;
 
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 
 if (!interpreter) {
 return 1;
--- ./docs/tests.pod.old2004-02-28 01:30:39.0 +0100
+++ ./docs/tests.pod2004-09-15 14:50:18.802102880 +0200
@@ -63,7 +63,7 @@
 
 int main(int argc, char* argv[]) {
 Parrot_Interp interpreter;
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 
 if (!interpreter)
 return 1;
--- ./docs/embed.pod.old2004-02-28 01:30:39.0 +0100
+++ ./docs/embed.pod2004-09-15 14:49:34.16160 +0200
@@ -16,7 +16,7 @@
 
 argc--; argv++; /* skip the program name */
 
-interp=Parrot_new();
+interp=Parrot_new(NULL);
 Parrot_init(interp);
 
 if(PARROT_JIT_CAPABLE) {
@@ -178,9 +178,10 @@
 
 =over 4
 
-=item CParrot_Interp Parrot_new()
+=item CParrot_Interp Parrot_new(Parrot_Interp parent)
 
-Allocates and returns a new Parrot interpreter.
+Allocates and returns a new Parrot interpreter. Cparent is NULL for the
+main interpreter that will be destroyed last.
 
 =item Cvoid Parrot_init(Parrot_Interp)
 
--- ./build_tools/pbc2c.pl.old  2004-04-23 11:20:13.0 +0200
+++ ./build_tools/pbc2c.pl  2004-09-15 14:51:00.498764024 +0200
@@ -231,7 +231,7 @@
 INTVAL i;
 PMC *userargv;
 
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 if (!interpreter) {
 return 1;
 }
@@ -366,4 +366,4 @@
 This program is free software. It is subject to the same license
 as the Parrot interpreter.
 
-=end ADDITIONAL
\ No newline at end of file
+=end ADDITIONAL


[perl #23084] [The Parrot Primer] Japanese Translation

2004-09-15 Thread Will Coleda via RT
Sasada-san -

Thanks for your translation. I apologize - your message came into our
ticketing system sideways, and I don't think a notification about your
work came to the [EMAIL PROTECTED] mailing list. 

I'm generating a reply to the list so that the project leads can let us
know what direction they wish to take.

I'd recommend to them that we find some way to either include your work
in the website, or at the very least link to it. (And potentially
solicit for other translations.)

Thanks again for your effort.

 [EMAIL PROTECTED] - Tue Jul 22 01:47:21 2003]:
 
 Hi. My name is Koichi Sasada, a Japanese university student.
 
 I have tried to translate The Parrot Primer(*1) to Japanese, and put
 it on
 my web site(*2).
 
 *1) http://www.parrotcode.org/docs/intro.pod.html
 *2) http://www.namikilab.tuat.ac.jp/~sasada/prog/parrot-intro.html
 (Japanese)
 
 I have 2 question.
 
 i)
 I don't know who has copyright of this document.
 I want to add his/her name on translation.
 
 ii) (more important)
 Can I publicise this translation?
 Can I continue to put it on my web site?
 
 
 
 
 I'm very interesting in an interpreter(Parrot and Python, Ruby, and so
 on).
.. and I'm a
 rubyist :)
 
 Parrot has many documents. It's very cool.
 I want to understand Parrot technology someday :)
 
 
 
 Thanks.
 
 
 



S5: grammar compositions

2004-09-15 Thread Dave Whipp
I was rereading S5, and the example of grammatical inheritance caught my
eye:

grammar Letter {
rule greet :w { [Hi|Hey|Yo] $to:=(\S+?) , $$}
...
}

grammar FormalLetter is Letter {
rule greet :w { Dear $to:=(\S+?) , $$}
...
}

My first reaction was that we need a bit more factoring here. I assume we
could do:

grammar Letter {
rule greet :w { greet_word $to:=(\S+?) , $$}
rule greet_word { [Hi|Hey|Yo] }
...
}

grammar FormalLetter is Letter {
rule greet_word{ Dear }
...
}

Will the :w do the right thing here?


My second though was that inheritance might be overused here. My refactoring
was the template method pattern. How would I use a strategy instead. I
know I can define a rule that accepts a parameter, but if I did that then
I'd need to pass that parameter all the way down the tree. Is it possible to
write something like

  $letter =~ /(Letter but greet_word(rule :w { Guten Tag })).text;

?


Dave.




Re: S5: grammar compositions

2004-09-15 Thread Luke Palmer
Dave Whipp writes:
 grammar Letter {
 rule greet :w { greet_word $to:=(\S+?) , $$}
 rule greet_word { [Hi|Hey|Yo] }
 ...
 }
 
 grammar FormalLetter is Letter {
 rule greet_word{ Dear }
 ...
 }
 
 Will the :w do the right thing here?

In the new S5 revision, :w changed from static to dynamic.  :w is about
the text now, not the rules.  So, yes, it will.

 My second though was that inheritance might be overused here. 

Perhaps, perhaps not.  In the multimethod paper that's coming soon (it's
turned out to be a lot more than just a multimethod paper; more of an
object model paper), inheritance may become much more useful than it
once was, at least in an abstract sense.  In particular, subtypes can be
a form of inheritance in the system.  And the best part is that we don't
have to change anything from S12 to apply the model.

But that's beside the point.   I just had to give all y'all a little
preview.

It's my suspicion that the template method pattern is often going to be
the right thing to do in rules.

 My refactoring was the template method pattern. How would I use a
 strategy instead. I know I can define a rule that accepts a parameter,
 but if I did that then I'd need to pass that parameter all the way
 down the tree. Is it possible to write something like
 
   $letter =~ /(Letter but greet_word(rule :w { Guten Tag })).text;

Hmm... this pattern seems a lot kludgier for this situation.  You could
use a parameterized grammar, I suppose:

grammar Letter[?$greeter = / [Hi|Hey|Yo] /] {
rule greet :w { $greeter $to := (\S+?) , $$ }
}

Which may be a better solution if you're expecting a lot of different
types.

By the way, you can't say:

$letter ~~ /( ...

Because ( starts a conditional assertion.  The usage becomes:

$letter ~~ /Letter[/:w Guten Tag /].greet/

Luke


Re: S5: grammar compositions

2004-09-15 Thread Larry Wall
Grammar roles?

Larry


S5: array interpolation

2004-09-15 Thread John Siracusa
 An interpolated array:
 
 / @cmds /
 
 is matched as if it were an alternation of its elements:
 
 / [ @cmds[0] | @cmds[1] | @cmds[2] | ... ] /
 
 As with a scalar variable, each one is matched as a literal.

Like this?  (Assuming single quotes don't interpolate @foo[...])

@a = ('a', 'b', 'c');

'@a[0]' ~~ m:/ @a /; # true
'@a[2]' ~~ m:/ @a /; # true
'@a[9]' ~~ m:/ @a /; # false

If so, that seems pretty wacky...

-John




[perl #31590] [PATCH] additional tests int/pmc/nci.t

2004-09-15 Thread via RT
# New Ticket Created by  Bernhard Schmalhofer 
# Please include the string:  [perl #31590]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31590 


Hi,

this patch adds two tests to t/pmc/nci.t. 
One test retrieves a pointer to a static integer in libnci.so, modifies the
referenced integer, and check wether the modification has taken place.

Furthermore I tried to make the naming of the tests more consistent.

CU, Bernhard

-- 
/* [EMAIL PROTECTED] */

NEU: GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
+++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++

nci_test_20040915.patch
Description: Binary data


Re: NCI basics

2004-09-15 Thread Brent 'Dax' Royal-Gordon
Jens Rieks [EMAIL PROTECTED] wrote:
 It now prints an error message:
 
 with nothing
 with int 5
 Parrot VM: PANIC: vt is an unknown signature type.
 CAN_BUILD_CALL_FRAMES is disabled, add the signature to src/call_list.txt!
 C file src/nci.c, line 4485
 Parrot file (unknown file), line 0

I'm not sure this is a panic-worthy error--panics are really meant for
cases where something has gone horribly, unfixably wrong in the
interpreter's guts, like a critical pointer in the ParrotInterp got
nulled out, or some important flags in the GC system got trashed.  It
should be virtually impossible to cause a panic from Parrotspace.

-- 
Brent 'Dax' Royal-Gordon [EMAIL PROTECTED]
Perl and Parrot hacker

There is no cabal.
[I currently have a couple Gmail invites--contact me if you're interested.]


Re: S5: array interpolation

2004-09-15 Thread Brent 'Dax' Royal-Gordon
John Siracusa [EMAIL PROTECTED] wrote:
  An interpolated array:
 
  / @cmds /
 
  is matched as if it were an alternation of its elements:
 
  / [ @cmds[0] | @cmds[1] | @cmds[2] | ... ] /
 
  As with a scalar variable, each one is matched as a literal.
 
 Like this?  (Assuming single quotes don't interpolate @foo[...])
 
 @a = ('a', 'b', 'c');
 
 '@a[0]' ~~ m:/ @a /; # true
 '@a[2]' ~~ m:/ @a /; # true
 '@a[9]' ~~ m:/ @a /; # false

I think he means as opposed to a subrule.  In Perl 5 terms, there's
an implicit \Q\E around each value in the array.

-- 
Brent 'Dax' Royal-Gordon [EMAIL PROTECTED]
Perl and Parrot hacker

There is no cabal.
[I currently have a couple Gmail invites--contact me if you're interested.]


[perl #31591] [PATCH] Parrot_new() doc update

2004-09-15 Thread via RT
# New Ticket Created by  Stephane Payrard 
# Please include the string:  [perl #31591]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=31591 


The interface has been modified but not reported everywhere.
Patch attached.
This was sent today but not according to the proper procedure.

--
 stef


--- ./src/test_main.c.old   2004-01-29 15:49:44.0 +0100
+++ ./src/test_main.c   2004-09-15 14:47:07.113244016 +0200
@@ -72,7 +72,7 @@
 char *filename;
 Parrot_PackFile pf;
 
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 
 if (!interpreter) {
 return 1;
--- ./docs/tests.pod.old2004-02-28 01:30:39.0 +0100
+++ ./docs/tests.pod2004-09-15 14:50:18.802102880 +0200
@@ -63,7 +63,7 @@
 
 int main(int argc, char* argv[]) {
 Parrot_Interp interpreter;
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 
 if (!interpreter)
 return 1;
--- ./docs/embed.pod.old2004-02-28 01:30:39.0 +0100
+++ ./docs/embed.pod2004-09-15 14:49:34.16160 +0200
@@ -16,7 +16,7 @@
 
 argc--; argv++; /* skip the program name */
 
-interp=Parrot_new();
+interp=Parrot_new(NULL);
 Parrot_init(interp);
 
 if(PARROT_JIT_CAPABLE) {
@@ -178,9 +178,10 @@
 
 =over 4
 
-=item CParrot_Interp Parrot_new()
+=item CParrot_Interp Parrot_new(Parrot_Interp parent)
 
-Allocates and returns a new Parrot interpreter.
+Allocates and returns a new Parrot interpreter. Cparent is NULL for the
+main interpreter that will be destroyed last.
 
 =item Cvoid Parrot_init(Parrot_Interp)
 
--- ./build_tools/pbc2c.pl.old  2004-04-23 11:20:13.0 +0200
+++ ./build_tools/pbc2c.pl  2004-09-15 14:51:00.498764024 +0200
@@ -231,7 +231,7 @@
 INTVAL i;
 PMC *userargv;
 
-interpreter = Parrot_new();
+interpreter = Parrot_new(NULL);
 if (!interpreter) {
 return 1;
 }
@@ -366,4 +366,4 @@
 This program is free software. It is subject to the same license
 as the Parrot interpreter.
 
-=end ADDITIONAL
\ No newline at end of file
+=end ADDITIONAL




Re: [perl #31573] Bus Error from compreg/compile

2004-09-15 Thread Matt Diephouse
This bug is a result of the last change to ops/core.ops (1.368).
Checking out version 1.367 made everything run smoothly. Maybe the
change should be undone? Leo?

The test code I provided still blew up, but that was because of how
I'd return it. I rewrote correctly (and have attached the file), but I
wasn't sure where to place the test.

-- 
matt


language.pir
Description: Binary data


[S3, S4, S5]: =~ becomes ~~

2004-09-15 Thread Herbert Snorrason
I know that, you know that ... but the synopses never actually say it.
It's evident from context, but it's never said explicitly. I would
*think* that should be in the Operator renaming section of S3, and
presume this is an oversight?
--
Schwäche zeigen heißt verlieren;
härte heißt regieren.
  - Glas und Tränen, Megaherz


Re: [S3, S4, S5]: =~ becomes ~~

2004-09-15 Thread Luke Palmer
Herbert Snorrason writes:
 I know that, you know that ... but the synopses never actually say it.
 It's evident from context, but it's never said explicitly. I would
 *think* that should be in the Operator renaming section of S3, and
 presume this is an oversight?

Okay, it ought to be there soon.  I added it in the New operators
section, since it's pretty different from =~.

Arguably the ~~ table should go in S3 instead of S4.

Luke


Re: S5: grammar compositions

2004-09-15 Thread chromatic
On Wed, 2004-09-15 at 12:47, Larry Wall wrote:

 Grammar roles?

It seems sensible, having said Here's a better method of type checking
and code re-use and Here's a generalization of pattern matching to
make it more like programming.

Not doing it would be like making closures that can't write to the
closed-over variables.  That's just crazy!

-- c