Re: Perl 6 and Parrot VM presentation slides

2005-05-25 Thread chromatic
On Tue, 2005-05-24 at 23:59 -0400, [EMAIL PROTECTED] wrote:

 I distinctly get the impression that I'm on of the few dumb Americans
 participating in all this.  So far, there hasn't been a single 
 English-language presentation offered.

I gave a talk on Parrot SDL last year.  It may be helpful, but the point
is mostly on programming PIR and SDL, not as much about the design of
Parrot:

http://www.wgz.org/chromatic/talks/parrot_sdl/

-- c



Re: Perl 6 and Parrot VM presentation slides

2005-05-25 Thread BÁRTHÁZI András

Hi,

I've found another presentation:
http://mail.pm.org/pipermail/grand-rapids-pm-list/2003-November/000367.html

Shouldn't we make a list about these presentations?

Bye,
  Andras

chromatic wrote:

On Tue, 2005-05-24 at 23:59 -0400, [EMAIL PROTECTED] wrote:


I distinctly get the impression that I'm on of the few dumb Americans
participating in all this.  So far, there hasn't been a single 
English-language presentation offered.


I gave a talk on Parrot SDL last year.  It may be helpful, but the point
is mostly on programming PIR and SDL, not as much about the design of
Parrot:

http://www.wgz.org/chromatic/talks/parrot_sdl/

-- c





Re: mmd

2005-05-25 Thread Leopold Toetsch

Jeff Horwitz wrote:

[ mmd test code ]

the pmc version of bar() is never called, even when passing a PMC. 


This is fixed now. A differing argument count had a too low distance 
penalty. But please note that the MMD system still has no clue what is 
an invocant and what a plain call argument because current calling 
conventions don't provide this information.


If a multi is found all arguments are used for distance calculation. If 
the function is called with less arguments there, is an arbitrary bigger 
penalty for this candidate then for a matching argument count.



-jeff


leo



Re: about python on parrot

2005-05-25 Thread Nicholas Clark
On Wed, May 25, 2005 at 01:29:51PM +0800, [EMAIL PROTECTED] wrote:
 hi
 
   python on parrot  already have not develop?

That question doesn't make sense as is - I think it lost something in
translation. By develop did you mean developers (humans) or development
(as in a sense of progress, is it stalled?). And already ... not feels like
a double negative, which adds to my confusion.

Nicholas Clark



Re: Perl 6 and Parrot VM presentation slides

2005-05-25 Thread Yuval Kogman
 However, I'm completely unfamiliar with the .spork format, and I'm
 fraid of what google will tell me it is.

Spork is 'slide presentation (only really kwiki)'.

What it does is let you write slides in a kwiki like language.

A quick introduction would be to get it from the CPAN, do 'spork
-make' and then 'spork -start', fudging the config.yaml so that the
'spork -start' command works OK, and then looking at the default
presentation. It's a quick intro to spork.

 From there on it's really just editing the Spork.slides file, which
 is really very simple, and playing around with plugin classes.

-- 
 ()  Yuval Kogman [EMAIL PROTECTED] 0xEBD27418  perl hacker 
 /\  kung foo master: *shu*rik*en*sh*u*rik*en*s*hur*i*ke*n*: neeyah



pgpqq4tV9kFs4.pgp
Description: PGP signature


ordered hash thoughts

2005-05-25 Thread Leopold Toetsch
The OrderedHash PMC provides indexed access by a (string) key as well as 
indexed access by insertion order. It's currently implemented as an hash 
holding the index value into the data array.
The problem is of course deleting items (and adding items w/o string 
key). The former is done by storing a new Undef item, the latter just 
messes up the whole thing, IIRC.


Anyway, we can achieve the same effect by indexing into the hash bucket 
store directly (at least after reversing the free_list order).


E.g. an (ordered) hash with 4 entries, these are hashed in the bucket 
index and point to the bucket store:


  buckets   keys (bucket**)
  b0 b1 b2 b3   h2 h1h3 h0

The buckets just come in order from the free_list - or for the 
specialized ordered hash - are just given away in array indexed order.


This would suffice for the planned used cases, which are typically:
- add (push) items by key
- retrieve items by key or by numeric index

E.g.:
- lexicals
- PMC/class types
- object attributes
- constant string table
- ...

leo



Re: Perl 6 and Parrot VM presentation slides

2005-05-25 Thread Matt Diephouse
[EMAIL PROTECTED] wrote:
 I distinctly get the impression that I'm on of the few dumb Americans
 participating in all this.  So far, there hasn't been a single
 English-language
 presentation offered. 

Dan Sugalski posted some slides he presented last August:

  http://www.sidhe.org/~dan/presentations/Parrot_Implementation.pdf

I have an old Perl 6 presentation, but it's at least 3 years old, very
badly out of date, and it wasn't a great presentation to begin with.

-- 
matt diephouse
http://matt.diephouse.com


takers wanted: a C job - list.c and arrays

2005-05-25 Thread Leopold Toetsch
src/list.c is the base for several array-ish PMC inside classes. But 
it's mostly outdone by other PMCs like ResizableIntegerPMC.


OTOH it has some features which are not covered by other array classes:
- implementation of splice, shift, unshift, ...
- chunked allocation with (limited) support for sparse arrays
- much faster shift/unshift for big arrays

I think we should do:

1) implement missing vtables (shift,unshift,splice,push,pop,delete) in 
*all* {Fixed,Resizable}typeArray PMCs


2) cleanup and simplify list.c. E.g. the growing policy for allocation 
can be dropped. We need only fixed-sized chunks of e.g one page size 
(and maybe sparse chunks).


3) get rid of Parrot_allocate* inside list.c because on each GC run the 
memory might move. We just use mem_sys_allocate (_realloc) instead.


4) treat list.c just as another policy: namely chunked array storage and 
use it when necessary. That is:

- new (small) arrays start as one of the mentioned types in 1)
- if the array gets big or has considerable shift/unshift operations, 
switch the array vtable to use the chunked based approach of list.c 
where the existing allocated memory is just one list chunk.


These are several more or less independent steps, 1) and 2+3) can be 
done in parallel.


Takers wanted  thanks
leo



Re: [perl #35855] Problem with Perl 5.6.1

2005-05-25 Thread jerry gay
thanks, applied (r8164)

On 5/24/05, Vladimir Lipsky [EMAIL PROTECTED] wrote:
  I notice that building with Perl 5.6.1 (on Win32 with  Perl 5.6.1
  ActiveState-build 635 and MinGW) causes problem.
 
  $ parrot
  Assertion failed: (int)io-image-bufused = 0, file src/pmc_freeze.c,
  line 478
  abnormal program termination
 
  This assertion occurs in parrot_get_config_string().
  The data parrot_config[] (file src/parrot_config.c) is not valid.
  This data is the frozen version of runtime/parrot/include/config.fpmc
  runtime/parrot/include/config.fpmc is a transformation of config_lib.pasm
  And I don't found a real explanation ...
 
 On windows, run-time libraries supplied with compilers distinguish between
 files open in the text and binary mode and the perl 5.6.* default open mode
 for plain files is text (this is not true as of perl 5.8.*, correct me if I
 am wrong). So after the following lines are executed
 
$_ = F;
my @c = split '';
 
 @c ends up containing only 208 chars, though config.pmc is of 11588 chars. I
 can't talk about implementation of fread in all the windows compillers, but
 MS VC's one does as follows: first it slurps the whole file in the buffer,
 then it checks if is running in the text mode, and if so, moves the pointer
 to the begin of the buffer and starts scanning it for CR-LF and CTRL-Z. If
 fread encounters CR-LF, it maps CR-LF to LF, if encounters CTRL-Z it stops
 the scanning and assigns the position, where CTRL-Z is found at, to the
 number of  bytes read.
 
 In this particular case, fread gets CTRL-Z at 209 position, so the script
 parrot_config_c.pl produces incomplete frozen pmc representation which is of
 208 chars only, and that's why assertion fails when thaw_pmc tries to thaw
 it.
 
 The patch applied fixes the problem at least on my PC which runs perl 5.6.2
 
 



Re: ordered hash thoughts

2005-05-25 Thread Dan Sugalski

At 3:34 PM +0200 5/25/05, Leopold Toetsch wrote:
The OrderedHash PMC provides indexed access by a (string) key as 
well as indexed access by insertion order. It's currently 
implemented as an hash holding the index value into the data array.
The problem is of course deleting items (and adding items w/o string 
key). The former is done by storing a new Undef item, the latter 
just messes up the whole thing, IIRC.


Given the usage this is supposed to be for, that is:


E.g.:
- lexicals
- PMC/class types
- object attributes
- constant string table
- ...


I'd just pitch an exception if code deletes an entry or adds one with 
no string key. Or if you're going to make it work maybe it'd be worth 
renaming the current PMC class into something else and creating a new 
class. (Assuming the changes would slow down or add complexity to the 
current class, since we'd really like it fast and simple enough to be 
reasonably auditable)

--
Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


Re: [perl #35305] [PATCH] skip threads 'detatch' test on win32

2005-05-25 Thread jerry gay
On 5/9/05, jerry gay [EMAIL PROTECTED] wrote:
 much better! one failing test now...

my initial exuberance was unfounded. one test fails in
t/pmc/threads.t, but hundreds fail in the rest of the test suite. it
seems this line (from above) is the culprit:

 -#  ifdef _MCS_VER1
 +#  ifdef _MCS_VER

so it seems the definition of THREAD_CREATE_JOINABLE() (which follows
this directive in include/parrot/thr_windows.h) is incorrect.

On 5/19/05, Leopold Toetsch [EMAIL PROTECTED] wrote:
 Vladimir Lipsky [EMAIL PROTECTED] wrote:
 
  Parrot_really_destroy needs to be fixed
 
 $verbose++ please, thanks
 
yes, please. until this issue is fixed, i'm rolling back these patches
so the threads test 6 is again skipped on windows, and the 200-odd
failing tests will work again. feel free to send more patches, i'll
happily test them (more carefully next time) and work out the bugs
before applying.

patch applied as r8165.
~jerry


This week's Perl 6 Summary

2005-05-25 Thread The Perl 6 Summarizer
The Perl 6 Summary for the week ending 2005-05-24
Note to self: It's generally not a good idea to go installing Tiger on
the day you return from holiday. It's especially not a good idea to fail
to check that it didn't completely and utterly radish your Postfix
configuration. And your emacs. And the backing store for your website.
And a bunch of other stuff. It's an especially bad idea not to have
backups of things like your aliases file...

Nor is it a good idea to get preoccupied with all these joys and
completely forget that you're supposed to be writ ting the Perl 6
summary.

Ahem.

I'm very, very sorry.

So, on with the show.

This week in perl6-compiler
  Inline::Pugs
Autrijus announced the availability of Inline::Pugs. If you've ever been
moved to mix up Perls 5 and 6 in one program, your prayers have been
answered. Just grab Pugs and Inline and you're set. Brian Ingerson made
things even more delightfully evil:

 #!perl
 use pugs;
 sub postfix:! { [*] 1..$_ }
 sub sum_factorial { [+] 0..$_! }
 no pugs;
 print sum_factorial(3); # 21

http://xrl.us/f73s

  Experimental Coroutine support
Autrijus announced that Pugs now has an experimental implementation of
coroutines. It's almost certainly not final, but it's good enough for
exploration and feedback purposes.

http://xrl.us/f73t

  Graphing tool for PerlGuts Illustrated
Yuval Kogman asked what tool was used to generate the 'pretty diagrams'
in PerlGuts Illustrated because he wanted to use it for diagrams in a
forthcoming PugsGuts Illustrated. Ingy said that Gisle had hand hacked
postscript based on initial diagrams drawn on graph paper. After some
discussion, the plan seems to be that Yuval will just draw diagrams,
scan them and bung them into the pugs repository. He'll rely on the
LazyWeb to turn them into beautiful scalable graphics.

http://www.lazyweb.org/

http://xrl.us/f73u

  Perl Development Server
Okay everyone, repeat after me: Juerd is a star!

You may ask me why, and I shall tell you.

Juerd and his cosponsors, Twistspace will making a Perl 6 development
server available over the internet to any Perl 6 developers who are
working on 'everything that improves Perl 6 development'. So, if you've
been put off working on Pugs by the hassles of getting Haskell working
on your machine, or if you have the kind of bandwidth that makes svn
updates a painful prospect, worry no longer. Just sign up for a
development account.

There was much rejoicing and suggesting of hostnames. Rather bizarrely,
there was also discussion of the etymology of 'sipuli' (Finnish for
'onion' in case you were wondering).

http://xrl.us/f73v

  Two releases in one day
Autrijus announced the release of Pugs 6.2.4. About half an hour later
he announced the release of Pugs 6.2.5.

http://xrl.us/f73w

  Undef issues
Adrian Taylor thought he'd found some issues with Perl 6's understanding
of undef. It turned out that he'd found some issues with his own
understanding of same.

http://xrl.us/f73x

  Method/attribute chaining
Alex Gutteridge found some weirdness with the chaining of autogenerated
attribute methods (I wonder if the same weirdness occurs with hand
rolled attribute methods). So far it remains unfixed, but given the
speed of Pugs development I doubt it'll stay that way for long.

http://xrl.us/f73y

Meanwhile, in perl6-internals
  Parrot as an extension language
Colin Adams continued to have problems using Parrot as an extension
language for Eiffel. It turns out that interfacing between statically
strongly typed languages and Parrot isn't easy.

http://xrl.us/f73z

  Fixing t/src/manifest.t
Dino Morelli reported problems with t/src/manifest.t and wondered how
some of the failures came about. Jürgen Bömmels thought that the problem
was an overzealous test -- the original version of which simply ensured
that version control and the MANIFEST were in sync. He provided his
suggested version of a less eager, but still svn compatible test.
Further discussion thrashed out the various difference use cases for
manifest checking.

http://xrl.us/f733

  More t/p6rules tests
Dino Morelli posted a bunch of tests for the Perl 6 rules. Well, he did
once he'd done battling his mailer's somewhat bizarre choice of MIME
type for his test files. Remember, if you're about to attach a .t file
to a message you send to the list, make sure your mailer doesn't declare
it to be an application/x-troff file -- text/plain is your fiend.

Patches were applied.

http://xrl.us/f734

  Stressing the hash
Leo asked for some stress and bench mark tests for hashes because he was
in the process of redoing src/hash.c. Bob Rogers provided one.


[perl #35971] [NEW] p6rules subrules tests

2005-05-25 Thread via RT
# New Ticket Created by  Dino Morelli 
# Please include the string:  [perl #35971]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=35971 


I implemented unit testing for subrules. I added new code to
Parrot::Test::PGE which accepts a ref to an array of arrays containing
named rules, generating the PIR to compile and store the rules in a
loop. Documentation changes to the POD are also included.

Also included is a new t/p6rules script to exercise it.

There are potentially lots of ways to go about this, this is just a
first crack at it. It's sort of a big change, let me know what I'm
missing. :)


files:

M MANIFEST
M lib/Parrot/Test/PGE.pm
A t/p6rules/subrules.t


-Dino

-- 
 .~.Dino Morelli
 /V\email: [EMAIL PROTECTED]
/( )\   weblog: http://categorically.net/d/blog/
^^-^^   preferred distro: Debian GNU/Linux  http://www.debian.orgIndex: MANIFEST

===

--- MANIFEST(revision 8164)

+++ MANIFEST(working copy)

@@ -1740,6 +1740,7 @@

 t/p6rules/capture.t   []

 t/p6rules/cclass.t[]

 t/p6rules/escape.t[]

+t/p6rules/subrules.t  []

 t/p6rules/ws.t[]

 t/perl/Parrot_Distribution.t  [devel]

 t/perl/Parrot_Docs.t  [devel]

Index: lib/Parrot/Test/PGE.pm

===

--- lib/Parrot/Test/PGE.pm  (revision 8164)

+++ lib/Parrot/Test/PGE.pm  (working copy)

@@ -10,6 +10,13 @@

   use Parrot::Test::PGE;

 

   p6rule_is('abc', '^abc', 'BOS abc');

+  p6rule_is(   int argc ,

+[

+[ type= 'int | double | float | char' ],

+[ ident   = '\w+' ],

+[ _MASTER = ':wtype ident' ],

+],

+simple subrules test);

   p6rule_isnt('abc', '^bc', 'BOS bc');

   p6rule_like('abcdef', 'bcd', qr/0: bcd @ 1/, '$0 capture');

 

@@ -31,33 +38,63 @@

 =item Cp6rule_is($target, $pattern, $description)

 

 Runs the target string against the Perl 6 pattern, passing the test

-if they match.  Note that the pattern should be specified as a string

-and without leading/trailing pattern delimiters.  (Hint: if you try

-using qr// for the $pattern then you're misreading what this does.)

+if they match.  Note that patterns should be specified as strings

+and without leading/trailing pattern delimiters.

 

+(Hint: if you try using qr// for the $pattern then you're misreading

+what this does.)

+

+subrules: In addition to a simple scalar string, the pattern can be a

+reference to an array of arrays. Containing subrules that refer to each

+other. In this form:

+

+[

+[ name1 = 'pattern 1' ],

+[ name2 = 'pattern 2' ],

+[ name3 = 'name1 pattern 3' ],

+[ _MASTER = 'name1 name2 name3' ],

+],

+

+The last rule, labelled with _MASTER, is the rule that your target string

+will be matched against. The 'outer rule' if you will.

+

 =cut

 

 sub p6rule_is {

 my ($target, $pattern, $description) = @_;

-Parrot::Test::pir_output_is(

+if (ref $pattern) {

+Parrot::Test::pir_output_is(

+Parrot::Test::PGE::_generate_subrule_pir($target, $pattern),

+'matched',

+$description);

+} else {

+Parrot::Test::pir_output_is(

 Parrot::Test::PGE::_generate_pir_for($target, $pattern),

 'matched',

 $description);

+}

 }

 

 =item Cp6rule_isnt($target, $pattern, $description)

 

-Runs the target string against the Perl 6 pattern, passing the test

-if they do not match.

+Runs the target string against the Perl 6 pattern, passing the test if

+they do not match. The same pattern argument syntax above applies here.

 

 =cut

 

 sub p6rule_isnt {

 my ($target, $pattern, $description) = @_;

-Parrot::Test::pir_output_is(

+if (ref $pattern) {

+Parrot::Test::pir_output_is(

+Parrot::Test::PGE::_generate_subrule_pir($target, $pattern),

+'failed',

+$description);

+} else {

+Parrot::Test::pir_output_is(

 Parrot::Test::PGE::_generate_pir_for($target, $pattern),

 'failed',

 $description);

+}

 }

 

 =item Cp6rule_like($target, $pattern, $expected, $description)

@@ -125,7 +162,58 @@

   match_end:

 .end\n);

 }

- 

+

+sub _generate_subrule_pir {

+my($target, $pattern) = @_;

+$target = _parrot_stringify($target);

+

+# Beginning of the pir code

+my $pirCode = qq(

+.sub _PGE_Test

+.local pmc p6rule_compile

+load_bytecode PGE.pbc

+find_global p6rule_compile, PGE, p6rule

+

+.local string target

+.local pmc rulesub

+   

Re: takers wanted: a C job - list.c and arrays

2005-05-25 Thread jerry gay
On 5/25/05, Leopold Toetsch [EMAIL PROTECTED] wrote:
 src/list.c is the base for several array-ish PMC inside classes. But
 it's mostly outdone by other PMCs like ResizableIntegerPMC.
 
 OTOH it has some features which are not covered by other array classes:
 - implementation of splice, shift, unshift, ...
 - chunked allocation with (limited) support for sparse arrays
 - much faster shift/unshift for big arrays
 
 I think we should do:
 
 1) implement missing vtables (shift,unshift,splice,push,pop,delete) in
 *all* {Fixed,Resizable}typeArray PMCs
 
i've added pop to ResizablePMCArray. i'll make sure the others are
added and move on to FixedPMCArray next.

 These are several more or less independent steps, 1) and 2+3) can be
 done in parallel.
 
 Takers wanted  thanks
 leo
 
 
BTW if you enter these as tickets into RT, we can truly have takers. :)
~jerry


Re: about python on parrot

2005-05-25 Thread Michal Wallace

On Wed, 25 May 2005, [EMAIL PROTECTED] wrote:


hi

python on parrot  already have not develop?


Hi there,

I'm not sure I understand your question either...
But maybe this will help?

   http://pirate.tangentcode.com/


- Michal
http://withoutane.com/


Re: takers wanted: a C job - list.c and arrays

2005-05-25 Thread Leopold Toetsch

jerry gay wrote:

On 5/25/05, Leopold Toetsch [EMAIL PROTECTED] wrote:



i've added pop to ResizablePMCArray. i'll make sure the others are
added and move on to FixedPMCArray next.


Great, thanks. WRT fixed arrays - its a policy thing: do these map to 
not resizable, not changable (Python tuples) or watever ...



These are several more or less independent steps, 1) and 2+3) can be
done in parallel.



BTW if you enter these as tickets into RT, we can truly have takers. :)


Yeah. As these are several steps, I'd like to have some takers first, or 
interest, or ...Except the first item its more a long term plan. I don't 
know if tickets really track it all.



~jerry


leo



refcounts and DOD

2005-05-25 Thread Michal Wallace


Hi all,

So I'm still thinking about a generic
wrapper for python modules. I would like 
to be able to recompile the python standard 
library (and other libraries) to run on parrot

with only a few minor patches.

I realize this is probably completely foolish,
but I'm lazy, so... :)

I've done experiments in the past running
PythonObjects outside the python VM. This 
should be possible by replacing a few generic

routines that refer to the interpreter.

One of the major issues is garbage collection.
Python's VM does refcounting. There are two 
macros it uses: Py_INCREF(x) and Py_DECREF(x).
They're pretty self-explanitory, but the docs 
are here:


   http://www.python.org/doc/2.4/ext/refcountsInPython.html

It seems to me that these macros could be 
replaced with something that puts the objects 
in the right place for parrot to deal with them.


I've read the memory_internals and pdd09_gc
docs but I'm still trying to understand how
this would work.

It seems that instead of looking at the *count*
of references, the DOD system actually walks
through the graph of references. So it seems
you could fake refcounting just by adding 
references and removing pointers from 
somewhere in the tree that gets walked.


So: Py_INCREF(x) could be rewritten to (for example)
append a reference to x in a parrot array, 
and Py_DECREF(x) would pop it off the array.


Am I on the right track here? I'm sure this is
a very naive and inefficient implementation, but
I don't see why it wouldn't work. If it would work,
is there a better way?

Also, my understanding is that parrot uses only
a Mark and Sweep system. Is that correct? pdd09
describes the three general methods, but doesn't
say which one(s) parrot actually usess. memory_internals.html
seems to imply the mark and sweep system only...
Or does parrot do all three?


- Michal
http://withoutane.com/



Re: refcounts and DOD

2005-05-25 Thread Nicholas Clark
On Wed, May 25, 2005 at 06:08:42PM -0400, Michal Wallace wrote:

 So: Py_INCREF(x) could be rewritten to (for example)
 append a reference to x in a parrot array, 
 and Py_DECREF(x) would pop it off the array.

I think that you can use Parrot_register_pmc and Parrot_unregister_pmc
IIRC they count up the number of registrations, and only stop tracking that
PMC when the count returns to zero.

Nicholas Clark


[perl #35976] [PATCH] Add Unicode, Hex, and Octal escapes to Tcl

2005-05-25 Thread via RT
# New Ticket Created by  Will Coleda 
# Please include the string:  [perl #35976]
# in the subject line of all future correspondence about this issue. 
# URL: https://rt.perl.org/rt3/Ticket/Display.html?id=35976 


The attached patch provides a (possibly naive) implementation of the remaining 
escape characters from:

http://www.tcl.tk/man/tcl8.5/TclCmd/Tcl.htm#M16

that were missing, namely

\ooo (octal)

\xhh (hex)

and

\u (unicode)

Supplied as a patch as I know someone's in the middle of working on the parser 
right now. 

For this to *really* work, we need to be able to append ascii and unicode 
strings together with impunity. (Which *might* already work.)
4c4
  * $Id: tclparser.pmc 7926 2005-04-25 16:17:41Z coke $
---
  * $Id: tclparser.pmc 8055 2005-05-10 21:14:59Z mdiep $
601c601
 goto backslash_escape_octal;
---
 goto backslash_escape_not;
606,683c606,607
 backslash_escape_octal:
   /* Octal Escape (XXX: Too ASCII?) */
   /* We can take one to three digits. */
   if (I0 = 48  I0 = 57) {
  I0 -= 48;
  I1 = string_index(INTERP, buffer, start_word+1);
  if (I1 =48  I1 =57) {
escape_length++; 
I0 = 8*I0 + I1-48;
I1 = string_index(INTERP, buffer, start_word+2);
if (I1 =48  I1 =57) {
escape_length++; 
I0 = 8*I0 + I1 - 48;
}
  } 
  Parrot_call_method(INTERP, P1, word, ConcatChar, vI, I0);
  goto escape_done;
   }
 
 backslash_escape_hex:
   /* 
* Hex Excape:
* Take as many hex digit as we can get, but only the last
* two are used to generate the character.
*/
   if (I0 == 120) {
 /* loop, getting characters. Keep a running total in I0 */
 I0 = 0;
 while (1) {
   I1 = string_index(INTERP, buffer, start_word + escape_length);
   if (I1 =48  I1 =57) {   /* 0-9 */
 I0 = I0 * 16 + I1-48; 
   } else if (I1=65  I1=70) {  /* A-Z */
 I0 = I0 * 16 + I1 - 65 + 10;
   } else if (I1=97  I1=102) { /* a-z */
 I0 = I0 * 16 + I1 - 97 + 10;
   } else {
 break;
   }
   I0 = I0 % 256;  /* Toss away anything bigger than two digits. */
   escape_length++;
 }
 if (escape_length == 1) {
   Parrot_call_method(INTERP, P1, word, ConcatChar, vI, 120);
 } else {
   Parrot_call_method(INTERP, P1, word, ConcatChar, vI, I0);
 }
 goto escape_done;
   }
 
 backslash_escape_unicode:
   /* 
* Unicode Excape:
* Take 1-4 hex digits.
*/
   if (I0 == 117) {
 /* loop, getting characters. Keep a running total in I0 */
 I0 = 0;
 while (escape_length = 4) {
   I1 = string_index(INTERP, buffer, start_word + escape_length);
   if (I1 =48  I1 =57) {   /* 0-9 */
 I0 = I0 * 16 + I1-48; 
   } else if (I1=65  I1=70) {  /* A-Z */
 I0 = I0 * 16 + I1 - 65 + 10;
   } else if (I1=97  I1=102) { /* a-z */
 I0 = I0 * 16 + I1 - 97 + 10;
   } else {
 break;
   }
   escape_length++;
 }
 if (escape_length == 1) {
   Parrot_call_method(INTERP, P1, word, ConcatChar, vI, 117);
 } else {
   Parrot_call_method(INTERP, P1, word, ConcatChar, vI, I0);
 }
 goto escape_done;
   }
---
 /* XXX - here is where the \o, \x, \u escapes will go, pending more
trans-charset joy */
685c609
   /* A backslash that didn't have any special meaning */
---
 backslash_escape_not:
689c613
   /* skip the escaped char(s)*/
---
   /* skip the escaped char*/


'char constant' in PIR

2005-05-25 Thread Bob Rogers
   imcc/docs/syntax.pod has the following:

=item 'char constant'

Are delimited by B'. They are taken to be Cascii encoded. No escape
sequences are processed.

But in fact B' behaves like B without escapes or encoding/charset
prefixes:

[EMAIL PROTECTED] cat foo.pir
.sub _main @MAIN
S1 = 'xyzzy\n'
print S1
print ascii:\n
.end
[EMAIL PROTECTED] parrot foo.pir
xyzzy\n
[EMAIL PROTECTED] 

A syntax for specifying multiple characters without escapes seems like a
useful thing, a la Perl5, but being unable to specify an encoding or
charset seems less useful, even for a single character.  In fact, I was
expecting a single character to be represented as an integer internally,
or at least to be easily converted to one, so I was surprised that this
didn't print 120\n:

[EMAIL PROTECTED] cat bar.pir
.sub _main @MAIN
I1 = 'x'
print I1
print \n
.end
[EMAIL PROTECTED] parrot bar.pir
0
[EMAIL PROTECTED] 

That would seem to be the one reasonable use for character constants,
but 'x' behaves no differently from x in this example.

   So what should 'x' mean in PIR?  I would suggest:

   1.  B' in PIR is like B' in Perl5, i.e. accept the status quo,
but add encoding/charset prefix syntax, and fix the doc; and

   2.  Support character constants via either string syntax by defining

I1 = 'x'

mean the equivalent of

S1 = 'x'
I1 = ord S1

to match my naive assumption.  Does that sound reasonable?

-- Bob Rogers
   http://rgrjr.dyndns.org/