[svn:perl6-synopsis] r12875 - doc/trunk/design/syn

2006-10-09 Thread larry
Author: larry
Date: Mon Oct  9 00:22:24 2006
New Revision: 12875

Modified:
   doc/trunk/design/syn/S05.pod

Log:
P5's s[pat][repl] syntax is dead, now use s[pat] = "repl"


Modified: doc/trunk/design/syn/S05.pod
==
--- doc/trunk/design/syn/S05.pod(original)
+++ doc/trunk/design/syn/S05.podMon Oct  9 00:22:24 2006
@@ -14,9 +14,9 @@
Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and
Larry Wall <[EMAIL PROTECTED]>
Date: 24 Jun 2002
-   Last Modified: 4 Oct 2006
+   Last Modified: 8 Oct 2006
Number: 5
-   Version: 35
+   Version: 36
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I rather than "regular
@@ -88,10 +88,18 @@
 
  s/pattern/{ doit() }/
 
+or:
+
+ s[pattern] = doit()
+
 Instead of C say:
 
  s/pattern/{ eval doit() }/
 
+or:
+
+ s[pattern] = eval doit()
+
 =item *
 
 Modifiers are now placed as adverbs at the I of a match/substitution:
@@ -2876,15 +2884,71 @@
 the longest one wins.  In the case of two identical sequences the
 first in order wins.
 
+=back
+
+=head1 Substitution
+
 There are also method forms of C and C:
 
- $str.match(//);
- $str.subst(//, "replacement");
- $str.subst(//, {"replacement"});
- $str.=subst(//, "replacement");
- $str.=subst(//, {"replacement"});
+ $str.match(/pat/);
+ $str.subst(/pat/, "replacement");
+ $str.subst(/pat/, {"replacement"});
+ $str.=subst(/pat/, "replacement");
+ $str.=subst(/pat/, {"replacement"});
 
-=back
+There is no syntactic sugar here, so in order to get deferred
+evaluation of the replacement you must put it into a closure.  The
+syntactic sugar is provided only by the quotelike forms.  First there
+is the standard "triple quote" form:
+
+s/pattern/replacement/
+
+Only non-bracket characters may be used for the "triple quote".  The
+right side is always evaluated as if it were a double-quoted string
+regardless of the quote chosen.
+
+As with Perl 5, a bracketing form is also supported, but unlike Perl 5,
+Perl 6 uses the brackets I around the pattern.  The replacement
+is then specified as if it were an ordinary item assignment, with ordinary
+quoting rules.  To pick your own quotes on the right just use one of the C
+forms.  The substitution above is equivalent to:
+
+s[pattern] = "replacement"
+
+or
+
+s[pattern] = qq[replacement]
+
+This is not a normal assigment, since the right side is evaluated each
+time the substitution matches (much like the pseudo-assignment to declarators
+can happen at strange times).  It is therefore treated as a "thunk", that is,
+as if it has implicit curlies around it.  In fact, it makes no sense at
+all to say
+
+s[pattern] = { doit }
+
+because that would try to substitute a closure into the string.
+
+Any scalar assignment operator may be used; the substitution macro
+knows how to turn
+
+$target ~~ s:g [pattern] op= expr
+
+into something like:
+
+$target.subst(rx:g [pattern], { $() op expr })
+
+So, for example, you can multiply every dollar amount by 2 with:
+
+s:g [\$ <( \d+ )>] *= 2
+
+(Of course, the optimizer is free to do something faster than an actual
+method call.)
+
+You'll note from the last example that substitutions only happen on
+the "official" string result of the match, that is, the C<$()> value.
+(Here we captured C<$()> using the C<< <(...)> >> pair; otherwise we
+would have had to use lookbehind to match the C<$>.)
 
 =head1 Positional matching, fixed width types
 


Re: [perl #40455] [PATCH] Bring dotnet back into unified languages testing

2006-10-09 Thread François PERRAD

At 12:26 04/10/2006 -0700, you wrote:

# New Ticket Created by  Bernhard Schmalhofer
# Please include the string:  [perl #40455]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=40455 >


Hi,

since a while 'languages/dotnet' showed up as all red in unified
languages testing, which is
invoked with "make languages-test". The culprits were the usual bunch:
@INC and pathes to executables.

I have expanded the library search path in the test scripts. Also
DotnetTesting.pm now asks
Parrot::Test for the path to the parrot executable.

Could somebody check for breakage on Windows?


Your patch works on Win32/MinGW.
See 
http://smoke.parrotcode.org/smoke/parrot-smoke-0.4.6-devel-r14861-unknown--i386-MSWin32-gcc-default--1160383280-1044--2034-1692-342-40-19-0--6c616e677561676573--c2f964d92d75f247ee11b48087ad2be4.html


François.


Any other suggestions?

CU, Bernhard





Re: [perl #40455] [PATCH] Bring dotnet back into unified languages testing

2006-10-09 Thread François PERRAD

At 12:26 04/10/2006 -0700, you wrote:

# New Ticket Created by  Bernhard Schmalhofer
# Please include the string:  [perl #40455]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=40455 >


Hi,

since a while 'languages/dotnet' showed up as all red in unified
languages testing, which is
invoked with "make languages-test". The culprits were the usual bunch:
@INC and pathes to executables.

I have expanded the library search path in the test scripts. Also
DotnetTesting.pm now asks
Parrot::Test for the path to the parrot executable.

Could somebody check for breakage on Windows?
Any other suggestions?


1) remove the need of the file languages/dotnet/config/N2PConfig.pm
2) generate languages/dotnet/Makefile with config/gen/languages.pm, not 
with languages/dotnet/Configure.pl


François.


CU, Bernhard





Questions about DEPRECATED.pod

2006-10-09 Thread Paul Cochrane

Hi all,

I was having a poke around in DEPRECATED.pod and I've got a couple of
questions about the items therein:

.imc file extension paragraph:

There aren't any .imc files in parrot anymore as far as I can tell.
So, should this paragraph be in DEPRECATED.pod anymore?  If not, I can
supply a patch removing it.  From looking at the parrot-porters thread
associated with the paragraph, there might still be some outstanding
issues, with this change.  Is this still the case?

Deprecated opcodes paragraph:

To remove the deprecated C opcode does one simply remove
the references to it in src/ops/object.ops (and other .ops files), and
remove the function from src/ops/ops.num?  Does one then move all of
the ops numbers "up" so that there isn't a gap caused by removing the
opcodes?  Is this relabelling of the opcode numbers going to break
anything else?  If not, should I go through and remove references to
C and fix up ops.num and patch?

Thanks heaps in advance!

Paul


Re: class interface of roles

2006-10-09 Thread TSa

HaloO,

Stevan Little wrote:

I think that maybe we need to seperate the concept of roles as types
and roles as partial classes, they seem to me to be in conflict with
one another. And even they are not in conflict with one another, I
worry they will bloat the complexity of roles usage.


The bloat aside I believe it is essential to have roles as the key
players of the type system. I propose to handle the typeish aspect of
roles as described in the paper I linked to: there should be a trait
'is augmented' that is applicable to a role and to methods in a role.
In such a method a call to next METHOD should invoke the class's method.
Alternatively we could make the method combination behavior the default
and have a class method trait 'is disambig' or 'is override' for the
case where the class needs to have the final word.

Note that the superclass interface of roles should be mostly inferred
from the usage of next METHOD. As such it is a useful guidance for
error reports in the class composition process.



My experiences thus far with roles in Moose have been that they can be
a really powerful means of reuse. I point you towards Yuval Kogman's
latest work on Class::Workflow, which is basically a loose set of
roles which can be composed into a highly customizable workflow
system. This is where I see the real power of roles coming into play.


Is this a set of free mixins or are they dependent on the class to
provide a certain interface to fully achieve the means of the roles?
I also consider roles a powerful tool but I believe that the type
system should play a role in the composition process that goes beyond
simple checking of name clashes.


Regards,
--


Re: class interface of roles

2006-10-09 Thread TSa

HaloO,

Jonathan Lang wrote:

TSa wrote:
 > Dispatch depends on a partial ordering of roles.

Could someone please give me an example to illustrate what is meant by
"partial ordering" here?


In addition to Matt Fowles explanation I would like to
give the following example lattice build from the roles

  role A { has $.x }
  role B { has $.y }
  role C { has $.z }

There can be the four union combined roles A|B, A|C, B|C
and A|B|C which complete the type lattice:

 Any={}
/  |  \
   /   |   \
  /|\
 / | \
/  |  \
  A={x}  B={y}  C={z}
   | \/ \/ |
   |  \  /   \  /  |
   |   \/ \/   |
   |   /\ /\   |
   |  /  \   /  \  |
   | /\ /\ |
 A|B={x,y} A|C={x,z} B|C={y,z}
\  |  /
 \ | /
  \|/
   \   |   /
\  |  /
A|B|C={x,y,z}

Note that A = (A|B) & (A|C) is the intersection type of A|B and A|C.
Note further that A|B is a subtype of A and B written A|B <: A and
A|B <: B and so on. Usually the A|B|C is called Bottom or some such.
I think it is the Whatever type of Perl6. It is the glb (greatest lower
bound) of A, B and C. In a larger lattice this type gets larger as well.
Any is the trivial supertype of all types.

This lattice can then be used for type checks and specificity
comparisons in dispatch. BTW, such a lattice can be calculated lazily
from any set of packages. In pure MMD the selected target has to be
the most specific in all dispatch relevant positions.

Regards,
--


Re: class interface of roles

2006-10-09 Thread TSa

HaloO,

TSa wrote:

Note that the superclass interface of roles should be mostly inferred
from the usage of next METHOD. As such it is a useful guidance for
error reports in the class composition process.


Actually 'next METHOD' doesn't catch all superclass interface issues.
There is the simple case of calling e.g. accessor methods on super
which should result in the requirement to provide them. So I still
propose a super keyword that in roles means the object as seen from
the uncomposed class.


Regards,
--


Re: class interface of roles

2006-10-09 Thread TSa

HaloO,

Stevan Little wrote:

I do not think method combination should be the default for role
composition, it would defeat the composeability of roles because you
would never have conflicts.


I don't get that. The type system would give compile time errors.
The current spec means that in case of a "conflicting" method the
class version simply overrides the role version. That is there is
simple, short or long name based "conflict" checking with priority
to the class.



 > I see that quite different: roles are the primary carrier of type
 > information!

Well yes, they do seem to have taken on this role ;).


If it is not roles that carry type information then the Perl6 type
system is as of now completely unspecced. Even with roles I miss
some clear statements about their theoretical background.



However, roles
as originally envisioned in the Traits paper are not related to the
type system, but instead related to class/object system. In fact the
Trait paper gave it's examples in Smalltalk, which is not a strongly
typed language (unless you count the idea that *everything* is an
object and therefore that is their type).


Remember the paper did not include state for traits and thus nicely
avoided several typing issues particularly in SmallTalk that is based
on single inheritance and dispatch along these lines.



I think we need to be careful in how we associate roles with the type
system and how we assocaite them with the object system. I worry that
they will end up with conflicting needs and responsibilities and roles
will end up being too complex to be truely useful.


My current understanding is that properly typed roles can obliviate
the need of the things described in theory.pod and directly go with
F-bounded polymorphism as the theoretical model of the type system.
It e.g. is strong enough to model Haskell type classes. Note that there
are free mixins that pose no requirements on the class in the theory
as described in the article.



 > Dispatch depends on a partial ordering of roles.

Type based dispatch does (MMD), but class based method dispatch
doesn't need it at all.


I strongly agree. The two hierarchies should be separated. The
only interweaving that occurs is the class composition process.
And this process should IMHO be directed by the type system and
provide for method combination when the correct typing of the role
requires it. Typical examples that need method combination are
equality checking, sorting support and generic container types.

There seems to be another connection from the class hierarchy to
the role hierarchy that is that a class has a role of the same
name so that class names can be used where a type is expected or
however this is supposed to work. In the end there shall be some
mixing of class and type based dispatch or some kind of embedding
of the class dispatch into type dispatch.



The whole fact that dispatching requires roles to be partially ordered
actually tells me that maybe roles should not be so hinged to the type
system since roles are meant to be unordered.


But how else do we define a subtype relation if not through a role
type lattice?



Possiblely we should be seeing roles as a way of *implementing* the
types, and not as a core component of the type system itself?


Hmm, again what is the type system then? All indications from the
Synopsis and this list go for roles taking over the responsibility
of key player in the type department. E.g. type parameters also go
with roles not with classes.


Regards,
--


Re: class interface of roles

2006-10-09 Thread TSa

HaloO,

TSa wrote:

Note that A = (A|B) & (A|C) is the intersection type of A|B and A|C.
Note further that A|B is a subtype of A and B written A|B <: A and
A|B <: B and so on. Usually the A|B|C is called Bottom or some such.
I think it is the Whatever type of Perl6. It is the glb (greatest lower
bound) of A, B and C. In a larger lattice this type gets larger as well.
Any is the trivial supertype of all types.


Damn it! I always puzzle glb and lub (least upper bound). So it should
read lub there. This is because the intension set gets larger even
though a subtype is formed. Note that the extension set "the instances"
becomes smaller! In a limiting case the Whatever type has got no
instances at all :)

Sorry,
--


Parrot Bug Summary

2006-10-09 Thread Parrot Bug Summary
Parrot Bug Summary

http://rt.perl.org/rt3/NoAuth/parrot/Overview.html
Generated at Mon Oct 9 13:15:14 2006 GMT
---

  * Numbers
  * New Issues
  * Overview of Open Issues
  * Ticket Status By Version
  * Requestors with most open tickets

---

Numbers

Ticket Counts: 91 new + 274 open = 365
Created this week: 13
Closed this week: 5

---

New Issues

New issues that have not been responded to yet

1 - 2 weeks old
40443 Separate vtable functions from methods (using :vtable)
2 - 3 weeks old
3 - 4 weeks old
40347 Can't determine revision under Subversion 1.4.0
4 - 5 weeks old
40313 [TODO] Tcl - full namespace support
40312 [TODO] Tcl - support namespaces in [info commands]
5 - 6 weeks old
6 - 7 weeks old
40217 Parrot_autoload_class() knows about Python and Tcl
7 - 8 weeks old
40191 [PATCH] PGE simple grammar test file revisited
40182 [TODO] Convert PGE::CodeString to .pmc
40156 [TODO] - Can't use an Iterator with a DynLexPad PMC
40153 [CAGE] TEST_PROG
8 - 9 weeks old
40138 [TODO] Tcl - add tcl's tests into our repository
40132 [TODO] Remove set_pmc vtable method
40124 [TODO] Document HLL mappings
40123 [TODO] push_eh + .param for argument mismatch errors
9 - 10 weeks old
40090 [TODO] Tcl - make 'tcl.pbc --pir' work.
40072 [CAGE] tools/dev/mk_manifest_and_skip.pl requires svn
40060 [CAGE] Fix non-symbol-table namespace pollution in public headers
40059 [CAGE] Fix symbol table namespace pollution
40053 Empty PGE rule causes error. rule x { }
10 - 11 weeks old
40010 [TODO] Add a mutex to eval_nr in compilers/imcc/parser_util.c
39992 [TODO] t/op/01-parse_ops.t: figure out how to test parsing of pmc
  constant parameters
39939 [TODO] exhaustively test new {set,get}*global and get*namespace opcodes
39932 [TODO] enable bulk operations in rt
39927 [TODO] named/slurpy parameters for PMC methods
11 - 12 weeks old
39913 [BUG] TGE - Can't use } in the transform definitions.
39908 [BUG] IMCC treats $S as a non-register instead of throwing an error
39855 [CAGE] configuration: define MIN/MAX macros for all integral typedefs
12 - 13 weeks old
39852 [TODO] Tcl - Create the ::tcl namespace properly
39851 [BUG] .HLL doesn't reset the .namespace
39845 [TODO] Better IMCC Errors: unexpected IDENTIFIER
39844 [BUG] Parrot doesn't do args checking for a sub without params
39833 [TODO] Tcl - Make [rename] handle namespaces
39827 [TODO] [CAGE] implement is_abs_path()
39802 [PATCH] [CAGE] turning up the warnings levels in gcc as much as we can
39784 Make Parrot's default namespace be untyped
13 - 14 weeks old
39738 bind fails with errno EADDRNOTAVAIL on darwin and FreeBSD
14 - 15 weeks old
39648 PGE - bad variable name
15 - 16 weeks old
16 - 17 weeks old
39430 Method cache not always invalidated
17 - 18 weeks old
39329 Check to make sure PMC_str_val, etc. are used appropriately
18 - 19 weeks old
19 - 20 weeks old
39197 [CAGE] lib/Parrot/Test.pm ignores core dumps failures!
20 - 21 weeks old
---

Overview of Open Issues

Platform   Severity   Tag  Lang
aix   0abandoned 05005threads   0  Amber0
All   2fatal 3bounce0  BASIC0
bsdos 0High  0Bug  29  bc   0
cygwin0low   1compiler  0  befunge  0
cygwin_nt 0medium0configure 0  bf   0
darwin0none  0core  0  cola 0
dec_osf   0Normal1dailybuild0  forth0
dgux  0unknown   0docs  0  jako 0
dos   0Wishlist  3duplicate 0  Lisp 0
dynixptx  0  install   1  m4   0
freebsd   0   library   0  ook  0
generic   0   notabug   0  perl60
gnu   0   notok 0  plot 0
HPUX  0   ok0  punie1
irix  0   Patch32  python   0
irix640   regex 0  ruby 0
Linux 1   sendToCPAN0  scheme   0
lynxos0   Todo194  tcl 30
mac   0   unknown   0  urm  0
machten   0   utilities 0  Zcode0
macos 0   wontfix   0
MacOS X   0
mswin32   0
netbsd0
next  0
openbsd   1
os2   0
os390 0
other 0
powerux   0
qnx   0
riscos0
sco   0
Solaris

[perl #40477] [PATCH] Coda fix of boilerplate generating code

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40477]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40477 >


Hi,

This patches the perl scripts which output a C-code coda when they
output boilerplate code to use the coda defined in pdd07.

Regards,

Paul

files affected:
tools/build/vtable_extend.pl
tools/dev/check_source_standards.pl
Index: tools/build/vtable_extend.pl
===
--- tools/build/vtable_extend.pl	(revision 14845)
+++ tools/build/vtable_extend.pl	(working copy)
@@ -132,11 +132,8 @@
 
 /*
  * Local variables:
- * c-indentation-style: bsd
- * c-basic-offset: 4
- * indent-tabs-mode: nil
+ *   c-file-style: "parrot"
  * End:
- *
  * vim: expandtab shiftwidth=4:
  */
 EOF
Index: tools/dev/check_source_standards.pl
===
--- tools/dev/check_source_standards.pl	(revision 14845)
+++ tools/dev/check_source_standards.pl	(working copy)
@@ -356,11 +356,8 @@
 my @end_boilerplate = split /\n\s*/, qq(
/*
 * Local variables:
-* c-indentation-style: bsd
-* c-basic-offset: 4
-* indent-tabs-mode: nil
+*   c-file-style: "parrot"
 * End:
-*
 * vim: expandtab shiftwidth=4:
 */
 );


[perl #40480] [PATCH] C-code coda not output multiple times in platform.[ch]

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40480]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40480 >


Hi,

This patch ensures that when platform.c and platform.h are generated,
that the C-code coda isn't included more than once, and that it is
included at the end of the generated file.

HTH,

Regards,

Paul

files affected:

config/gen/platform.pm
Index: config/gen/platform.pm
===
--- config/gen/platform.pm	(revision 14845)
+++ config/gen/platform.pm	(working copy)
@@ -50,6 +50,15 @@
 print " ($generated) " if $verbose;
 print("\n") if defined $verbose && $verbose == 2;
 
+my $coda = <<'CODA';
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
+CODA
+
 # headers are merged into platform.h
 my @headers = qw/
 io.h
@@ -88,13 +97,20 @@
 local $/ = undef;
 print("\t$header_file\n") if defined $verbose && $verbose == 2;
 open IN_H, "< $header_file" or die "Can't open $header_file: $!";
+
+	# slurp in the header file
+	my $in_h = ;
+
+	# remove the (in this case) superfluous coda
+	$in_h =~ s{\Q$coda\E\n*\z}{}xgs;
+
 print PLATFORM_H <<"END_HERE";
 /*
 ** $header_file:
 */
 #line 1 "$header_file"
 END_HERE
-print PLATFORM_H , "\n\n";
+print PLATFORM_H $in_h, "\n\n";
 close IN_H;
 }
 
@@ -129,6 +145,12 @@
 #endif
 END_HERE
 
+# append the C code coda to the generated file
+print PLATFORM_H <<"END_HERE";
+
+$coda
+END_HERE
+
 close PLATFORM_H;
 
 # implementation files are merged into platform.c
@@ -162,13 +184,20 @@
 if (-e "config/gen/platform/$platform/begin.c") {
 local $/ = undef;
 open IN_C, "< config/gen/platform/$platform/begin.c" or die "Can't open begin.c: $!";
+
+	# slurp in the C file
+	my $in_c = ;
+
+	# remove the (in this case) superfluous coda
+	$in_c =~ s{\Q$coda\E\n*\z}{}xgs;
+
 print PLATFORM_C <<"END_HERE";
 /*
 ** begin.c
 */
 #line 1 "config/gen/platform/$platform/begin.c"
 END_HERE
-print PLATFORM_C , "\n\n";
+print PLATFORM_C $in_c, "\n\n";
 close IN_C;
 }
 
@@ -188,13 +217,20 @@
 local $/ = undef;
 print("\t$impl_file\n") if defined $verbose && $verbose == 2;
 open IN_C, "< $impl_file" or die "Can't open $impl_file: $!";
+
+	# slurp in the C file
+	my $in_c = ;
+
+	# remove the (in this case) superfluous coda
+	$in_c =~ s{\Q$coda\E\n*\z}{}xgs;
+
 print PLATFORM_C <<"END_HERE";
 /*
 ** $impl_file:
 */
 #line 1 "$impl_file"
 END_HERE
-print PLATFORM_C , "\n\n";
+print PLATFORM_C $in_c, "\n\n";
 close IN_C;
 }
 }
@@ -217,6 +253,12 @@
 }
 }
 
+# append the C code coda to the generated file
+print PLATFORM_C <<"END_HERE";
+
+$coda
+END_HERE
+
 close PLATFORM_C;
 
 if ($conf->data->get('platform_asm')) {


[perl #40476] [PATCH] dos -> unix line endings of pm files

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40476]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40476 >


Hi,

Recently I found some .pm files with dos line endings.  This patch
changes these to unix line endings.  Should there be a test for line
endings in t/codingstd ??

Regards,

Paul

files affected:

lib/Parrot/Docs/Section/Compilers.pm
config/inter/libparrot.pm
languages/lua/Lua/parser.pm


[perl #40475] [PATCH] Adding pmc files to C-coda checks

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40475]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40475 >


Hi,

PMC files are just C-language files in a sense, right?  If so, then
here's a patch that gets Parrot::Distribution to find all the .pmc
files, and adds a check to the c_code_coda.t test so that after a
"make realclean; perl Configure.pl; make" more of the c_code_coda
tests pass.

HTH,

Paul

files affected:

lib/Parrot/Distribution.pm
t/codingstd/c_code_coda.t
Index: lib/Parrot/Distribution.pm
===
--- lib/Parrot/Distribution.pm	(revision 14845)
+++ lib/Parrot/Distribution.pm	(working copy)
@@ -186,7 +186,59 @@
 return;
 }
 
+=item C
 
+Returns the directories which contain PMC source files.
+
+=cut
+
+sub pmc_source_file_directories
+{
+my $self = shift;
+
+return
+map $self->directory_with_name($_) =>
+	'compilers/bcg/src/pmc',
+	'languages/APL/src/pmc',
+	'languages/WMLScript/pmc',
+	'languages/amper/lib/kernel/pmc',
+	'languages/cardinal/src/pmc',
+	'languages/dotnet/pmc',
+	'languages/lua/pmc',
+	'languages/perl6/src/pmc',
+	'languages/pugs/pmc',
+	'languages/python/pmc',
+	'languages/tcl/src/pmc',
+map("src/$_" => qw),
+'t/tools',
+;
+}
+
+
+=item C
+
+Returns the PMC source file with the specified name.
+
+=cut
+
+sub pmc_source_file_with_name
+{
+my $self = shift;
+my $name = shift || return;
+
+$name .= '.pmc';
+
+foreach my $dir ($self->pmc_source_file_directories)
+{
+return $dir->file_with_name($name)
+if $dir->file_exists_with_name($name);
+}
+
+print 'WARNING: ' . __FILE__ . ':' . __LINE__ . ' File not found:' . $name ."\n";
+
+return;
+}
+
 =item C
 
 Returns the Perl module file for the specified module.
Index: t/codingstd/c_code_coda.t
===
--- t/codingstd/c_code_coda.t	(revision 14845)
+++ t/codingstd/c_code_coda.t	(working copy)
@@ -92,6 +92,7 @@
 return (
 map( $_->files_of_type('C code'),   $DIST->c_source_file_directories ),
 map( $_->files_of_type('C header'), $DIST->c_header_file_directories ),
+map( $_->files_of_type('PMC code'),   $DIST->pmc_source_file_directories ),
 );
 }
 


[perl #40479] [PATCH] Adding and correcting C-code coda in autogenerated code

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40479]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40479 >


Hi,

This patch adds the C-code coda to the autogenerated C language code,
and fixes a couple of pre-existing codas for autogenerated code.  This
gets more of the coda tests to pass, especially after making parrot.

HTH!

Regards,

Paul

files affected:

tools/build/jit2c.pl
tools/build/ops2pm.pl
tools/build/nativecall.pl
tools/build/vtable_h.pl
tools/build/vtable_extend.pl
tools/build/ops2c.pl
tools/build/fingerprint_c.pl
tools/build/c2str.pl
tools/build/parrot_config_c.pl
tools/build/revision_c.pl
lib/Parrot/Pmc2c/Library.pm
config/gen/core_pmcs.pm
config/gen/config_h.pm
config/gen/platform.pm
config/gen/config_h/config_h.in
config/gen/config_h/feature_h.in
Index: tools/build/jit2c.pl
===
--- tools/build/jit2c.pl	(revision 14845)
+++ tools/build/jit2c.pl	(working copy)
@@ -456,6 +456,17 @@
 EOC
 }
 
+# append the C code coda
+print JITCPU <<"EOC";
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
+EOC
+
 print("jit2c: JITed $njit (+ $vjit vtable) of $core_numops ops\n");
 
 sub make_subs {
Index: tools/build/ops2pm.pl
===
--- tools/build/ops2pm.pl	(revision 14845)
+++ tools/build/ops2pm.pl	(working copy)
@@ -298,6 +298,16 @@
 #endif
 
 END_C
+
+# append the C code coda
+print OUT <', 'src/extend_vtable.c' or die $!;
@@ -132,11 +143,8 @@
 
 /*
  * Local variables:
- * c-indentation-style: bsd
- * c-basic-offset: 4
- * indent-tabs-mode: nil
+ *   c-file-style: "parrot"
  * End:
- *
  * vim: expandtab shiftwidth=4:
  */
 EOF
Index: tools/build/ops2c.pl
===
--- tools/build/ops2c.pl	(revision 14845)
+++ tools/build/ops2c.pl	(working copy)
@@ -281,6 +281,17 @@
 }
 my $bs = "${base}${suffix}_";
 
+# append the C code coda
+print HEADER {opt}{library},
   map { $_->{class} => $_ }
   values %{$self->{pmcs}} );
+$cout .= $self->c_code_coda;
 
 return $cout;
 }
@@ -166,6 +168,26 @@
 "$cout\n";
 }
 
+=item C
+
+Returns the Parrot C code coda
+
+=cut
+
+sub c_code_coda() {
+my $self = shift;
+my $cout = "";
+$cout .= <<"EOC";
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
+EOC
+"$cout\n";
+}
+
 =back
 
 =head1 SEE ALSO
Index: config/gen/core_pmcs.pm
===
--- config/gen/core_pmcs.pm	(revision 14845)
+++ config/gen/core_pmcs.pm	(working copy)
@@ -64,6 +64,13 @@
 };
 
 /* &end_gen */
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
 END_H
 
 close OUT;
@@ -132,6 +139,13 @@
 print OUT "register_pmc(interp, registry, enum_class_$_);\n" foreach (@pmcs);
 print OUT <<'END_C';
 }
+
+/*
+ * Local variables:
+ *   c-file-style: "parrot"
+ * End:
+ * vim: expandtab shiftwidth=4:
+ */
 END_C
 
 close OUT;
Index: config/gen/config_h.pm
===
--- config/gen/config_h.pm	(revision 14845)
+++ config/gen/config_h.pm	(working copy)
@@ -118,6 +118,17 @@
 }
 }
 
+# append the C code coda
+print HH <

[perl #40482] [PATCH] Perl::Critic policy for perl -w, and unix-specific shebang lines

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40482]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40482 >


Hi,

This patch adds a new policy for the Parrot Perl::Critic tests, namely
to check that the shebang line doesn't use 'perl -w', rather 'use
warnings;' and that the shebang line doesn't use something unix
specific such as '#!/usr/bin/perl' and rather '#! perl'.  Would it be
a good idea to group all of the code standards-related stuff into a
directory CodeStandards?  As such, should I then make a patch for
CodeLayout::UseParrotCoda to go under CodeStandards::UseParrotCoda
instead?  I'm also wondering what the policy is on svn Id keywords in
files, and whether or not the svn:keywords property is set to a
particular value.  I don't think there's a standard or anything
defined for this yet.  Should there be?  If so, should I put a request
into RT?

TIA

Regards,

Paul

files affected:

lib/Perl/Critic/Policy/CodeStandards/CheckPerlShebang.pm
Index: lib/Perl/Critic/Policy/CodeStandards/CheckPerlShebang.pm
===
--- lib/Perl/Critic/Policy/CodeStandards/CheckPerlShebang.pm	(revision 0)
+++ lib/Perl/Critic/Policy/CodeStandards/CheckPerlShebang.pm	(revision 0)
@@ -0,0 +1,76 @@
+# $Id#
+package Perl::Critic::Policy::CodeStandards::CheckPerlShebang;
+
+use strict;
+use warnings;
+use Perl::Critic::Utils;
+use Perl::Critic::Violation;
+use base 'Perl::Critic::Policy';
+
+our $VERSION = '0.1';
+$VERSION = eval $VERSION;## no critic
+
+my $minus_w_desc = q{Need to use 'perl -w' instead of 'use warnings;'};
+my $minus_w_expl = q{All perl source in parrot must 'use warnings;' not the older 'perl -w' usage};
+
+my $unix_desc = q{Found unix-specific perl shebang line};
+my $unix_expl = q{Perl source in parrot should use the platform-independent shebang line: #! perl};
+
+#
+
+sub default_severity { return $SEVERITY_LOW }
+sub applies_to   { return 'PPI::Document' }
+
+#
+
+sub violates {
+my ( $self, $elem, $doc ) = @_;
+
+my @elements = $doc->children();
+
+# look for the shebang line, if any
+foreach my $element ( @elements) {
+if ($element =~ m/^#! .* perl/xgs) {
+# if the shebang line matches 'perl -w', report the violation
+if ($element =~ m/perl \s* -w/xgs) {
+my $sev = $self->get_severity();
+return Perl::Critic::Violation
+->new( $minus_w_desc, $minus_w_expl, $element, $sev ); 
+}
+elsif ($element =~ m{/usr(/local)?/bin/perl}xgs) {
+my $sev = $self->get_severity();
+return Perl::Critic::Violation
+->new( $unix_desc, $unix_expl, $element, $sev ); 
+}
+else {
+last;  # shebang line ok; skip to the end of the elements
+}
+}
+}
+
+# we didn't find any dodgy shebang lines, so return with success
+return;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Perl::Critic::Policy::CodeStandards::CheckPerlShebang
+
+=head1 DESCRIPTION
+
+Check to see if the old 'perl -w' shebang line is used to switch on
+warnings.  Also check to see that the perl shebang line isn't unix-specific 
+i.e. uses something like #!/usr/bin/perl instead of the cross-platform #! perl.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:


What are the final words on GMP, BigNums and *BooleanArrays ?????????????

2006-10-09 Thread Karl Forner

Hi,

It's not that easy to contribute to parrot development.
I got into that by picking a TODO task about *BooleanArrays, that seemed
appropriate for a Parrot newbie that
knows a bit about algorithmics and Data structures.

Answering one of my mail, Bernhard raised the question of using a common
implementation for strings, boolean arrays.
And that maybe this implementation could be borrowed from the Perl5
Bit::Vector library.

It reminded me of something I read on this list, about the GMP library.
So I checked the GMP website, ok looks great.
I've also noted that there are some GMP-based implementations and GMP stuff
in Parrot, and a GMP test.

But a priori not a word in the specifications and the design documents.
So I tried to track all the GMP related threads, and that's not that easy,
for instance there does not seem to be a "search" feature on the nntp
archive. I tried using some news readers then found my happiness with Google
Groups (always Google). But there's also some materials in the blogs for
example.

So what did I found, among other stuff ?

in Joshua Gatcomb mail, 2004-07-31

The "make ICU optional"
 was supposed to read "make ICU like GMP" - autodetect
 it if present, but do not force it upon the user.


in the Perl 6 Summary for the week ending 2004-07-18:

  GMP Licensing
 Armin Obersteiner reported his investigations into the licensing
 requirements of the GMP maths library. It appears that the FSF's 'GPL



 Compliance Engineer' reckons we won't need to include the GMP's

source

 code with binary distributions. We just have to make it available

from

 the same source as the distribution. Which is handy.


A thread "GMP's license looks Parrot-compatible" starting on 2004-06-30

SO MY POINT IS:

1) it seems that a decision has been made, but that it not written anywhere,
and at least not on the parrot site.
This decision is,  in my understanding,  to use an internal fall-back poor
man's implementation.

2) Nor could I find the rationale for that decision. I've read some IMHO
good arguments for including or for linking, but not a definitive summary,
because from the last stuff I read, it seems that the Licensing issues are
not blocking

3) I spent more time trying to figure out the right thing to do than in my
opinion coding something useful.

WHAT I'D LIKE:

* Some place, in the docs/ part of the parrot website, where that kind of
decision is recorded, along with pointers to relevant information.
A kind of proceedings, or critical review, I'm not sure about the word in
English.

* The particular details for the GMP decision.

AND YET OTHER QUESTIONS

* What is the intended usage, or in other words, the usefulness of the
*BooleanArrays ?

I'm somewhat puzzled, because there is no API for using these boolean arrays
(a la Bit::Vector for example)

* If it's just a kind of storage, I can go on and implement it with a
custom, simple and small implementation, but I've still 2 solutions for
Resizables  :
 - either grow smartly only on the right (push, pop), an alloc/copy when
changes are needed on the left (that saves on INTVAL attribute)
 - allocate a third INTVAL attribute on the heap, and grows smartly in both
directions

Thank you very much for your attention

Karl Forner


Parrot Configure error

2006-10-09 Thread Paul Cochrane

Hi all,

In r14862, Configure.pl throws an error when processing the Manifest.
The error is:

Checking MANIFEST...No such file: ext/Parrot-Embed/Embed.xs

Ack, some files were missing!  I can't continue running
without everything here.  Please try to find the above
files and then try running Configure again.


step init::manifest failed: no result returned at Configure.pl line 501


After some digging I found that Embed.xs actually resides in
ext/Parrot-Embed/lib/Parrot/.  I don't know which is the correct
location though, so I don't know how to fix the problem.

Just thought someone should know...

Regards,

Paul


Re: What are the final words on GMP, BigNums and *BooleanArrays ?????????????

2006-10-09 Thread jerry gay

On 10/9/06, Karl Forner <[EMAIL PROTECTED]> wrote:

Hi,

It's not that easy to contribute to parrot development.
I got into that by picking a TODO task about *BooleanArrays, that seemed
appropriate for a Parrot newbie that
knows a bit about algorithmics and Data structures.


thank you for your enthusiasm, and apologies for our lack of prompt
response. we'll work on correcting this (and i'll start now,) as it
would be a shame to lose a valuable contributor due to our inaction.


Answering one of my mail, Bernhard raised the question of using a common
implementation for strings, boolean arrays.
And that maybe this implementation could be borrowed from the Perl5
Bit::Vector library.


yes, a common implementation would be wonderful, but any core
committer would be happy to apply a patch of a working implementation.
there's no need to optimize this prematurely--there will be plenty of
time for that later, when the core of parrot is fully implemented, and
we're closer to release.


It reminded me of something I read on this list, about the GMP library.
So I checked the GMP website, ok looks great.
I've also noted that there are some GMP-based implementations and GMP stuff
in Parrot, and a GMP test.

But a priori not a word in the specifications and the design documents.
So I tried to track all the GMP related threads, and that's not that easy,
for instance there does not seem to be a "search" feature on the nntp
archive. I tried using some news readers then found my happiness with Google
Groups (always Google). But there's also some materials in the blogs for
example.

So what did I found, among other stuff ?


[skip to the point :) ]


SO MY POINT IS:

1) it seems that a decision has been made, but that it not written anywhere,
and at least not on the parrot site.
This decision is,  in my understanding,  to use an internal fall-back poor
man's implementation.

2) Nor could I find the rationale for that decision. I've read some IMHO
good arguments for including or for linking, but not a definitive summary,
because from the last stuff I read, it seems that the Licensing issues are
not blocking


(addressing 1 and 2): parrot's goal of a virtual machine that runs
everywhere perl5 runs makes it difficult to use external libraries,
which are usually not nearly as portable. i don't know specifics of
gmp's portability, so i can't comment on whether it's an appropriate
solution. this decision applies to unicode as well; the current icu
implementation is there to get something working, the final
implementation will likely be homegrown.


3) I spent more time trying to figure out the right thing to do than in my
opinion coding something useful.

WHAT I'D LIKE:

* Some place, in the docs/ part of the parrot website, where that kind of
decision is recorded, along with pointers to relevant information.
A kind of proceedings, or critical review, I'm not sure about the word in
English.


a decision like that is recorded in the parrot design documents.
unfortunately, the document you require is either in draft, or
non-existant. this must be fixed, and *is* on the TODO list.


* The particular details for the GMP decision.


i believe i've outlined the general direction above. to be clear:
external library usage is fine, if there's an external library
available on the system. if not, a fallback implementation is
required. feel free to start your effort either way.


AND YET OTHER QUESTIONS

* What is the intended usage, or in other words, the usefulness of the
*BooleanArrays ?


i see boolean arrays used as bit vectors. using an efficient storage
mechanism, offering useful bit-twiddling operations, and operating on
contained data as quickly as possible. that's waving my hands
somewhat, and i don't know if it helped.


I'm somewhat puzzled, because there is no API for using these boolean arrays
(a la Bit::Vector for example)


the design document for base pmcs is unfinished, and way out of date.
it's on allison's list, but right now she's working on exceptions and
i/o.


* If it's just a kind of storage, I can go on and implement it with a
custom, simple and small implementation, but I've still 2 solutions for
Resizables  :
  - either grow smartly only on the right (push, pop), an alloc/copy when
changes are needed on the left (that saves on INTVAL attribute)
  - allocate a third INTVAL attribute on the heap, and grows smartly in both
directions


my advice: do whatever seems easiest. extend/refactor as needed.
document your decisions to benefit future coders. note: i don't always
follow my own advice :)


Thank you very much for your attention


you're quite welcome.
~jerry


Re: Parrot Configure error

2006-10-09 Thread jerry gay

On 10/9/06, Paul Cochrane <[EMAIL PROTECTED]> wrote:

Hi all,

In r14862, Configure.pl throws an error when processing the Manifest.
The error is:

Checking MANIFEST...No such file: ext/Parrot-Embed/Embed.xs

Ack, some files were missing!  I can't continue running
without everything here.  Please try to find the above
files and then try running Configure again.


step init::manifest failed: no result returned at Configure.pl line 501


After some digging I found that Embed.xs actually resides in
ext/Parrot-Embed/lib/Parrot/.  I don't know which is the correct
location though, so I don't know how to fix the problem.

Just thought someone should know...

Regards,

Paul


whoops, sorry! fixed in r14863.
~jerry


Re: [perl #40482] [PATCH] Perl::Critic policy for perl -w, and unix-specific shebang lines

2006-10-09 Thread Will Coleda


On Oct 9, 2006, at 5:51 AM, Paul Cochrane (via RT) wrote:


# New Ticket Created by  "Paul Cochrane"
# Please include the string:  [perl #40482]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=40482 >


Hi,

This patch adds a new policy for the Parrot Perl::Critic tests, namely
to check that the shebang line doesn't use 'perl -w', rather 'use
warnings;' and that the shebang line doesn't use something unix
specific such as '#!/usr/bin/perl' and rather '#! perl'.  Would it be
a good idea to group all of the code standards-related stuff into a
directory CodeStandards?  As such, should I then make a patch for
CodeLayout::UseParrotCoda to go under CodeStandards::UseParrotCoda
instead?


They're all coding standards. I say leave the Coda where it is, and  
put this in the same grouping as 'use warnings' (i.e.  
'TestingAndDebugging').


Also, instead of checking for "/usr/local" and then reporting a  
violation, switch it. Check for the *allowed* version, and, failing  
that, report a violation. Then you'll catch /sw/bin/perl, /opt/bin/ 
perl, C:\perl\bin\perl.exe, and others.


Modulo that, this is good, and should be applied. (And addresses the  
other end of the "switch from -w to use warnings" ticket that Jerry  
opened.)



I'm also wondering what the policy is on svn Id keywords in
files, and whether or not the svn:keywords property is set to a
particular value.  I don't think there's a standard or anything
defined for this yet.  Should there be?  If so, should I put a request
into RT?



This is already tested in t/distro/file_metadata.t.


TIA

Regards,

Paul





--
Will "Coke" Coleda
[EMAIL PROTECTED]




[svn:perl6-synopsis] r12933 - doc/trunk/design/syn

2006-10-09 Thread larry
Author: larry
Date: Mon Oct  9 08:34:36 2006
New Revision: 12933

Modified:
   doc/trunk/design/syn/S02.pod
   doc/trunk/design/syn/S05.pod

Log:
Quote and regex adverbs may now take only parentheses as brackets.


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podMon Oct  9 08:34:36 2006
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 10 Aug 2004
-  Last Modified: 8 Oct 2006
+  Last Modified: 9 Oct 2006
   Number: 2
-  Version: 75
+  Version: 76
 
 This document summarizes Apocalypse 2, which covers small-scale
 lexical items and typological issues.  (These Synopses also contain
@@ -1476,17 +1476,17 @@
 There is now a generalized adverbial form of Pair notation.  The
 following table shows the correspondence to the "fatarrow" notation:
 
-Fat arrow  Adverbial pair
-=  ==
+Fat arrow  Adverbial pair  Paren form
+=  ==  ==
 a => 1 :a
 a => 0 :!a
 a => 0 :a(0)
 a => $x:a($x)
-a => 'foo' :a
-a =>  :a
-a => «$foo @bar»   :a«$foo @bar»
-a => {...} :a{...}
-a => [...] :a[...]
+a => 'foo' :a :a()
+a =>  :a :a()
+a => «$foo @bar»   :a«$foo @bar»   :a(«$foo @bar»)
+a => {...} :a{...} :a({...})
+a => [...] :a[...] :a([...])
 a => $a:$a
 a => @a:@a
 a => %a:%a
@@ -1518,7 +1518,12 @@
 If that's not intended, you must use whitespace between the adverb and
 the opening bracket.  The syntax of individual adverbs is the same
 everywhere in Perl 6.  There are no exceptions based on whether an
-argument is wanted or not.  Except as noted above, the parser always
+argument is wanted or not.  (There is a minor exception for quote and
+regex adverbs, which accept I parentheses as their bracketing
+operator, and ignore other brackets, which must be placed in parens
+if desired.  See "Paren form" in the table above.)
+
+Except as noted above, the parser always
 looks for the brackets.  Despite not indicating a true subscript,
 the brackets are similarly parsed as postfix operators.  As postfixes
 the brackets may be separated from their initial C<:foo> with either
@@ -1566,7 +1571,7 @@
 
 quote qx = 'qq:x';  # equivalent to P5's qx//
 quote qTO = 'qq:x:w:to';# qq:x:w:to//
-quote circumfix:<❰ ❱> = q:code { .quoteharder };  # or some such...
+quote circumfix:<❰ ❱> = q:code{ .quoteharder };  # or some such...
 
 In particular, all these forms disable the lookahead for an adverbial argument,
 as if there were a space after the keyword.  So although
@@ -1594,10 +1599,8 @@
 
 q:n[stuff]
 
-is not so fine, if the user intended "stuff" to be the string rather
-than an argument to C<:n>.  Basically, you'll be fine if you just
-never use parens for quote delimiters, and always put a space after
-your adverbs.
+also happens to work because quote adverbs only all the paren form of
+bracketed adverbs.
 
 If this is all too much of a hardship, you can define your own quote
 adverbs and operators as standard macros.  The main difference is that,
@@ -1609,8 +1612,8 @@
 
 macro qn { 'q:n' }
 
-does I disable the subsequent search for an argument to C<:n>.  To
-get the equivalent, you need to add a space:
+does I disable the subsequent search for a parenthesized argument
+to C<:n>.  To get the equivalent, you need to add a space:
 
 macro qn { 'q:n ' }
 

Modified: doc/trunk/design/syn/S05.pod
==
--- doc/trunk/design/syn/S05.pod(original)
+++ doc/trunk/design/syn/S05.podMon Oct  9 08:34:36 2006
@@ -14,9 +14,9 @@
Maintainer: Patrick Michaud <[EMAIL PROTECTED]> and
Larry Wall <[EMAIL PROTECTED]>
Date: 24 Jun 2002
-   Last Modified: 8 Oct 2006
+   Last Modified: 9 Oct 2006
Number: 5
-   Version: 36
+   Version: 37
 
 This document summarizes Apocalypse 5, which is about the new regex
 syntax.  We now try to call them I rather than "regular
@@ -108,8 +108,8 @@
 
 Every modifier must start with its own colon.  The delimiter must be
 separated from the final modifier by whitespace if it would otherwise be taken
-as an argument to the preceding modifier (which is true for any
-bracketing character).
+as an argument to the preceding modifier (which is true if and only if
+the next character is a left parenthesis.)
 
 =item *
 
@@ -180,7 +180,7 @@
 
 But in the case of
 
- m:s {(a|\*) (b|\+)}
+ m:s{(a|\*) (b|\+)}
 
 or equivalently,
 
@@ -257,7 +257,7 @@
 which is almost the same as:
 
  $_.pos = 0;
- s:c [ () = (\N+) $$] [$0 => $1] for 1..4;
+ s:c[ () = (\N+) $$] = "$0 =

[svn:perl6-synopsis] r12936 - doc/trunk/design/syn

2006-10-09 Thread larry
Author: larry
Date: Mon Oct  9 08:44:59 2006
New Revision: 12936

Modified:
   doc/trunk/design/syn/S02.pod

Log:
bleah, typo from ENOCAFFEINE


Modified: doc/trunk/design/syn/S02.pod
==
--- doc/trunk/design/syn/S02.pod(original)
+++ doc/trunk/design/syn/S02.podMon Oct  9 08:44:59 2006
@@ -1599,7 +1599,7 @@
 
 q:n[stuff]
 
-also happens to work because quote adverbs only all the paren form of
+also happens to work because quote adverbs only allow the paren form of
 bracketed adverbs.
 
 If this is all too much of a hardship, you can define your own quote


[perl #40483] [PATCH] removal of cuddled else's in C source

2006-10-09 Thread Paul Cochrane
# New Ticket Created by  "Paul Cochrane" 
# Please include the string:  [perl #40483]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40483 >


Hi,

This patch uncuddles the else's in the C source, and makes the
t/codingstd/cuddled_else.t test pass.

Regards,

Paul

files affected:

src/utils.c
src/malloc-trace.c
src/tsq.c
src/resources.c
src/hll.c
src/stm/stm_internal.h
src/stm/backend.c
src/register.c
src/debug.c
src/inter_call.c
src/string.c
src/malloc.c
src/headers.c
src/string_primitives.c
src/objects.c
src/packfile/pf_items.c
src/jit/sun4/jit_emit.h
src/thread.c
src/dynext.c
src/mmd.c
src/packfile.c
src/io/io_buf.c
src/io/io_unix.c
src/sub.c
include/parrot/atomic/fallback.h
include/parrot/atomic/gcc_pcc.h
include/parrot/atomic/gcc_x86.h
include/parrot/atomic.h
compilers/imcc/cfg.c
compilers/imcc/pbc.c
compilers/imcc/optimizer.c
compilers/imcc/imcparser.c
compilers/imcc/imclexer.c
compilers/imcc/reg_alloc_bc.c
config/gen/platform/generic/exec.c
Index: src/utils.c
===
--- src/utils.c	(revision 14862)
+++ src/utils.c	(working copy)
@@ -684,13 +684,15 @@
 
 if ( pred_index < 0 ) { /* pred has no predecessor */
 move_reg(pred, node, c);
-} else { /* pred has a predecessor, so may be processed */
+} 
+else { /* pred has a predecessor, so may be processed */
 src = c->backup[pred_index];
 if (  src < 0 ) { /* not visited */
 move_reg(pred, node, c);
 c->backup[pred_index] = node; /* marks pred*/
 rec_climb_back_and_mark(pred_index, c);
-} else { /* already visited, use backup instead */
+} 
+else { /* already visited, use backup instead */
 move_reg(src, node, c);
 }
 }
Index: src/malloc-trace.c
===
--- src/malloc-trace.c	(revision 14862)
+++ src/malloc-trace.c	(working copy)
@@ -51,7 +51,8 @@
 		while(--s>cmdline && *s!='/');
 		if(*s == '/') s++;
 		sprintf(name, LOG_NAME ".%.12s.%d", s, pid);
-	} else {
+	} 
+else {
 		sprintf(name, LOG_NAME ".%d", pid);
 	}
 #else
Index: src/tsq.c
===
--- src/tsq.c	(revision 14862)
+++ src/tsq.c	(working copy)
@@ -82,7 +82,8 @@
 if (queue->head == queue->tail) {
 queue->head = NULL;
 queue->tail = NULL;
-} else {
+} 
+else {
 queue->head = queue->head->next;
 }
 returnval->next = NULL;
@@ -134,7 +135,8 @@
 if (queue->tail) {
 queue->tail->next = entry;
 queue->tail = entry;
-} else {
+} 
+else {
 queue->head = entry;
 queue->tail = entry;
 }
Index: src/resources.c
===
--- src/resources.c	(revision 14862)
+++ src/resources.c	(working copy)
@@ -841,7 +841,8 @@
 next_block = cur_block->prev;
 if (cur_block->free == cur_block->size) {
 mem_internal_free(cur_block);
-} else {
+} 
+else {
 cur_block->next = NULL;
 cur_block->prev = dest->top_block;
 dest->top_block = cur_block;
Index: src/hll.c
===
--- src/hll.c	(revision 14862)
+++ src/hll.c	(working copy)
@@ -225,7 +225,8 @@
 nelements = VTABLE_elements(interpreter, hll_info);
 if (id < 0 || id >= nelements) {
 ret = NULL;
-} else {
+} 
+else {
 PMC *entry;
 PMC *name_pmc;
 START_READ_HLL_INFO(interpreter, hll_info);
Index: src/stm/stm_internal.h
===
--- src/stm/stm_internal.h	(revision 14862)
+++ src/stm/stm_internal.h	(working copy)
@@ -18,7 +18,8 @@
 struct STM_profile_data *profile = &PROFILE(log); \
 if (cycles == 0) { \
 ++profile->num_non_waits; \
-} else { \
+} \
+else { \
 if (time_bucket >= TIME_BUCKETS) { \
 time_bucket = TIME_BUCKETS - 1; \
 } else if (time_bucket == 0) { \
Index: src/stm/backend.c
===
--- src/stm/backend.c	(revision 14862)
+++ src/stm/backend.c	(working copy)
@@ -328,12 +328,14 @@
 }
 PARROT_ATOMIC_INT_SET(inner->status, STM_STATUS_ABORTED);
 return 0;
-} else if (need_abort) {
+} 
+else if (need_abort) {
 /* leave as merged, abort the outer transaction since it is
  * now invalid */
 PARROT_ATOMIC_INT_SET(outer->status, STM_STATUS_ABORTED);
 return 1;
-} else {
+} 
+else {
 return 1;
 }
 }
@@ -344,7 +346,8 @@
 ret = VTABLE_share_ro(interp, pmc);
 assert(PObj_is_PMC_shared_TEST(ret));
 return ret;
-} else {
+ 

Re: [perl #40482] [PATCH] Perl::Critic policy for perl -w, and unix-specific shebang lines

2006-10-09 Thread Paul Cochrane

Will,


They're all coding standards. I say leave the Coda where it is, and
put this in the same grouping as 'use warnings' (i.e.
'TestingAndDebugging').

Ok, see attached patch.


Also, instead of checking for "/usr/local" and then reporting a
violation, switch it. Check for the *allowed* version, and, failing
that, report a violation. Then you'll catch /sw/bin/perl, /opt/bin/
perl, C:\perl\bin\perl.exe, and others.

Good idea, annoyed with myself for not having seen that earlier...


This is already tested in t/distro/file_metadata.t.

Thanks for the pointer, and the feedback!

Regards,

Paul
Index: lib/Perl/Critic/Policy/TestingAndDebugging/CheckPerlShebang.pm
===
--- lib/Perl/Critic/Policy/TestingAndDebugging/CheckPerlShebang.pm	(revision 0)
+++ lib/Perl/Critic/Policy/TestingAndDebugging/CheckPerlShebang.pm	(revision 0)
@@ -0,0 +1,76 @@
+# $Id#
+package Perl::Critic::Policy::TestingAndDebugging::CheckPerlShebang;
+
+use strict;
+use warnings;
+use Perl::Critic::Utils;
+use Perl::Critic::Violation;
+use base 'Perl::Critic::Policy';
+
+our $VERSION = '0.1';
+$VERSION = eval $VERSION;## no critic
+
+my $minus_w_desc = q{Need to use 'perl -w' instead of 'use warnings;'};
+my $minus_w_expl = q{All perl source in parrot must 'use warnings;' not the older 'perl -w' usage};
+
+my $spec_desc = q{Found platform-specific perl shebang line};
+my $spec_expl = q{Perl source in parrot should use the platform-independent shebang line: #! perl};
+
+#
+
+sub default_severity { return $SEVERITY_LOW }
+sub applies_to   { return 'PPI::Document' }
+
+#
+
+sub violates {
+my ( $self, $elem, $doc ) = @_;
+
+my @elements = $doc->children();
+
+# look for the shebang line, if any
+foreach my $element ( @elements) {
+if ($element =~ m/^\#! .*? perl/xgs) {
+# if the shebang line matches '-w', report the violation
+if ($element =~ m/-w/gs) {
+my $sev = $self->get_severity();
+return Perl::Critic::Violation
+->new( $minus_w_desc, $minus_w_expl, $element, $sev ); 
+}
+elsif ($element !~ m/^\#! \s* perl \s*/xgs) {
+my $sev = $self->get_severity();
+return Perl::Critic::Violation
+->new( $spec_desc, $spec_expl, $element, $sev ); 
+}
+else {
+last;  # shebang line ok; skip to the end of the elements
+}
+}
+}
+
+# we didn't find any dodgy shebang lines, so return with success
+return;
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Perl::Critic::Policy::TestingAndDebugging::CheckPerlShebang
+
+=head1 DESCRIPTION
+
+Check to see if the old 'perl -w' shebang line is used to switch on
+warnings.  Also check to see that the perl shebang line isn't unix-specific 
+i.e. uses something like #!/usr/bin/perl instead of the cross-platform #! perl.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:


Re: [perl #40482] [PATCH] Perl::Critic policy for perl -w, and unix-specific shebang lines

2006-10-09 Thread Chris Dolan

On Oct 9, 2006, at 4:51 AM, Paul Cochrane (via RT) wrote:


# New Ticket Created by  "Paul Cochrane"
# Please include the string:  [perl #40482]
# in the subject line of all future correspondence about this issue.
# http://rt.perl.org/rt3/Ticket/Display.html?id=40482 >


Hi,

This patch adds a new policy for the Parrot Perl::Critic tests, namely
to check that the shebang line doesn't use 'perl -w', rather 'use
warnings;' and that the shebang line doesn't use something unix
specific such as '#!/usr/bin/perl' and rather '#! perl'.  Would it be
a good idea to group all of the code standards-related stuff into a
directory CodeStandards?  As such, should I then make a patch for
CodeLayout::UseParrotCoda to go under CodeStandards::UseParrotCoda
instead?  I'm also wondering what the policy is on svn Id keywords in
files, and whether or not the svn:keywords property is set to a
particular value.  I don't think there's a standard or anything
defined for this yet.  Should there be?  If so, should I put a request
into RT?


Paul,

A few comments:
 * No, this shouldn't go into UseParrotCoda.  Separately enabled  
policies are more flexible.

 * In fact, yours should probably be broken into two policies.  Perhaps
CodeStandards::ProhibitShebangWarningsArg
and
CodeStandards::RequirePortableShebang
 * This would be a nice addition to core Perl::Critic!
 * The -w catcher fails on "#!perl -T -w" or other variations on  
argument lists.  Perhaps forbid any arguments at all?
 * The shebang line is always a PPI::Token::Comment and is always on  
the first line.  Take a look at this utility function from  
Perl::Critic::Utils:


sub is_script {
my $doc = shift;
my $first_comment = $doc->find_first('PPI::Token::Comment');
return if !$first_comment;
return if $first_comment->location()->[0] != 1;
return $first_comment =~ m{ \A \#\! }mx;
}

Now that I'm talking about it, I should write a  
Perl::Critic::Utils::get_shebang() function...


Chris


--
Chris Dolan, Software Developer, http://www.chrisdolan.net/
Public key: http://www.chrisdolan.net/public.key
vCard: http://www.chrisdolan.net/ChrisDolan.vcf





Re: [perl #40482] [PATCH] Perl::Critic policy for perl -w, and unix-specific shebang lines

2006-10-09 Thread Chris Dolan

On Oct 9, 2006, at 11:50 AM, Paul Cochrane wrote:


Will,


They're all coding standards. I say leave the Coda where it is, and
put this in the same grouping as 'use warnings' (i.e.
'TestingAndDebugging').

Ok, see attached patch.


This one is still a false negative on "#!perl -Tw" and is a false  
positive on "package main; #!!! my co-worker provided this non-Perl- 
licensed code to Parrot!!!".  Yes, that's a highly contrived  
example.  :-)  But the false positive would be avoidable by checking  
the line and column number of the element.


Chris

--
Chris Dolan, Software Developer, Clotho Advanced Media Inc.
608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703
vCard: http://www.chrisdolan.net/ChrisDolan.vcf

Clotho Advanced Media, Inc. - Creators of MediaLandscape Software  
(http://www.media-landscape.com/) and partners in the revolutionary  
Croquet project (http://www.opencroquet.org/)





Re: Calling Methods on Class PMCs

2006-10-09 Thread Leopold Toetsch
Am Montag, 9. Oktober 2006 05:12 schrieb chromatic:
> I'm experimenting with better forms of OO in PIR.  I want to add a
> get_parents() method on the Class PMC.  Normally, I'd do something like the
> attached patch, but the attached example file I use for testing shows that
> it doesn't work for me.

You were probably looking for the C opcode. Your get_parents() is 
only returning the immediate parent(s) of that _class_ but not the full 
chain, which is in Cmro>.

See also: perldoc src/ops/pmc.ops

> I dug around a bit and couldn't find a reason for why it shouldn't work.

You are calling it on a ParrotObject, which ought to delegate the call to it's 
class. But as said, you'd get only 'Child' in your case.

> Note that I can't even call name() on a Class PMC either.  Hm.

As a method? You can't call any vtable function with method syntax. 

See also:

http://perlcabal.org/~lt/toreview/Cfunc.pod 

But there is:

inline op typeof (out STR, invar PMC) {
  $1 = VTABLE_name(interpreter, $2);
  goto NEXT();
}

i.e. the C opcode is the interface to the class name.

> -- c

leo


Re: What are the final words on GMP, BigNums and *BooleanArrays ?????????????

2006-10-09 Thread Leopold Toetsch
Am Montag, 9. Oktober 2006 16:26 schrieb Karl Forner:
> AND YET OTHER QUESTIONS
>
> * What is the intended usage, or in other words, the usefulness of the
> *BooleanArrays ?

A *BooleanArray *does* array[1] and it's storage size is one bit per item.

[1] the current array interface isn't much more than:

Fixed:
  ar = 1e9 # fill it with 0
  b = ar[idx]  # get bit
  ar[idx] = b  # set bit 
  delete, exists

Resizable additionally:
  b = {pop,shift} ar
  {push,unshift} ar, b
  splice

To me it doesn't make much sense to provide all possible conversions from/to 
num & string, PMC is debatable.

For usage see e.g.: examples/shootout/nsieve*.pir  

> I'm somewhat puzzled, because there is no API for using these boolean
> arrays (a la Bit::Vector for example)

We don't have an array API yet, nor a pdd. But some methods like sort() are 
implemented for some arrays. fill() aka memset() would be another candidate. 
And of course more on demand.

> * If it's just a kind of storage, I can go on and implement it with a
> custom, simple and small implementation, but I've still 2 solutions for
> Resizables  :
>   - either grow smartly only on the right (push, pop), an alloc/copy when
> changes are needed on the left (that saves on INTVAL attribute)
>   - allocate a third INTVAL attribute on the heap, and grows smartly in
> both directions

You can provide smart growing in both directions with the mentioned strategy 
with just 2 int_val fields.

> Thank you very much for your attention
>
> Karl Forner

leo


Re: Questions about DEPRECATED.pod

2006-10-09 Thread Bernhard Schmalhofer

Paul Cochrane schrieb:

Hi all,

I was having a poke around in DEPRECATED.pod and I've got a couple of
questions about the items therein:

.imc file extension paragraph:

There aren't any .imc files in parrot anymore as far as I can tell.
So, should this paragraph be in DEPRECATED.pod anymore?  If not, I can
supply a patch removing it.  From looking at the parrot-porters thread
associated with the paragraph, there might still be some outstanding
issues, with this change.  Is this still the case?

AFAIK all '*.imc' have been renamed.

Deprecated opcodes paragraph:

To remove the deprecated C opcode does one simply remove
the references to it in src/ops/object.ops (and other .ops files), and
remove the function from src/ops/ops.num?  Does one then move all of
the ops numbers "up" so that there isn't a gap caused by removing the
opcodes?  Is this relabelling of the opcode numbers going to break
anything else?  If not, should I go through and remove references to
C and fix up ops.num and patch?

I think you mostly got it.
For the renumbering of  src/ops/ops.num you can use
  make -f tools/dev/ops_renum.mak
Also see the notes in PBC_COMPAT.

CU, Bernhard


[perl #40490] Flat/Slurpy Named Parameter Passing Errors

2006-10-09 Thread via RT
# New Ticket Created by  chromatic 
# Please include the string:  [perl #40490]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=40490 >


Given this code:

.sub 'main' :main
.local pmc args
args = new .Hash
args['foo'] = 1
args['bar'] = 2

bar_only( args :flat :named )
.end

.sub 'bar_only'
.param string bar  :named( 'bar' )
.param pmcargs :named :slurpy

print "Have bar: "
print bar
print "\n"
.end

I expect bar to be '2' in bar_only().  Somehow the value seems to get lost.  
I'll add this test to t/op/calling.t when I get the ticket number.

-- c


Bytes make no sense on text strings

2006-10-09 Thread Juerd
I don't understand why having :bytes for things like s/// would be a
good thing.

A Str doesn't have bytes, just like how a Buf doesn't have characters.

To get bytes out of a Str, you need an encoding. There will be an
internal encoding, but exposing it in this way is probably just asking
for a lot of trouble: inconsistent (invalid) data that internals rely
on, and the inability to switch the internal encoding later. Or, for
example, to keep things 8bit encoded as an optimization until something
demands more than that. 

As I understand it, a Str is a unicode string, not a UTF-8 string.

I propose that using :bytes on a text string throws an exception.
-- 
korajn salutojn,

  juerd waalboer:  perl hacker  <[EMAIL PROTECTED]>  
  convolution: ict solutions and consultancy <[EMAIL PROTECTED]>

Ik vertrouw stemcomputers niet.
Zie .


Re: Bytes make no sense on text strings

2006-10-09 Thread Larry Wall
On Mon, Oct 09, 2006 at 11:40:09PM +0200, Juerd wrote:
: I don't understand why having :bytes for things like s/// would be a
: good thing.
: 
: A Str doesn't have bytes, just like how a Buf doesn't have characters.
: 
: To get bytes out of a Str, you need an encoding. There will be an
: internal encoding, but exposing it in this way is probably just asking
: for a lot of trouble: inconsistent (invalid) data that internals rely
: on, and the inability to switch the internal encoding later. Or, for
: example, to keep things 8bit encoded as an optimization until something
: demands more than that. 
: 
: As I understand it, a Str is a unicode string, not a UTF-8 string.

A string object is allowed to present multiple interfaces at different
abstraction levels.  If a string object allows multiple abstraction levels
it is part of the object's job in life to keep those abstraction levels
in sync with each other.  This is one of the reasons it's Very Important
that string positions be considered opaque abstractions and not numbers.

: I propose that using :bytes on a text string throws an exception.

It will if the string in question doesn't support the bytes abstraction
level, which might well be most of them.

Larry


Heads up: Dynamic environment now captured in continuations

2006-10-09 Thread Bob Rogers
   From: Bob Rogers <[EMAIL PROTECTED]>
   Date: Mon, 2 Oct 2006 20:54:22 -0400

  This weekend's project (committed as r14830) makes continuations
   capture the dynamic environment so that they can restore it properly on
   invocation.  This makes it possible for multiple continuations to
   coexist that return to different environments in the same context.

  One word of caution, though:  I had also wanted to move the
   control_stack slot from the context to the interpreter, but found that
   doing so breaks coroutines rather severely . . .  So this logical
   next step is on hold for now.

Done as r14876.

   However, I strongly suspect that coroutines are still broken
   in ways that are not detected by the test suite -- therefore, please let
   me know if your favorite app develops a coroutine allergy.

This is still true, but I'm pretty sure I haven't made coroutines any
less functional.

-- Bob


Null PMC access while parsing javascript

2006-10-09 Thread Mehmet Yavuz Selim Soyturk

js.pg in languages/ecmascript/src compiles just fine with pgc. But it
gives a "Null PMC access" error while using the compiled pir file. Is
it a pge bug?

$ cd languages/ecmascript/src

$ cat main.pir
.include 'errors.pasm'

.sub _main :main
   .param pmc args

   .local string source_code, rule_to_match
   source_code = args[1]
   rule_to_match = args[2]

   errorson .PARROT_ERRORS_PARAM_COUNT_FLAG

   load_bytecode 'PGE.pbc'
   load_bytecode 'dumper.pbc'
   load_bytecode 'PGE/Dumper.pbc'
   load_bytecode 'PGE/Text.pbc'
   load_bytecode 'Getopt/Obj.pbc'
   load_bytecode 'js.pir'

   .local pmc start_rule
   start_rule = get_global ['JS'], rule_to_match
   if null start_rule goto e_global_not_found

   .local pmc match
   match = start_rule(source_code)

   _dumper(match)
   branch end

 e_global_not_found:
   say "global not found"
 end:
.end

$ pgc js.pg >js.pir

$ parrot main.pir 'x' 'identifier'
Null PMC access in invoke()
current instr.: 'parrot;JS;identifier' pc 9096 (js.pir:3766)
called from Sub '_main' pc 38 (main.pir:24)

$ tail -n +3766 js.pir | line
 captob = $P0(captob)

$ parrot main.pir '[1]' 'array_literal'
Null PMC access in invoke()
current instr.: 'parrot;JS;array_literal' pc 11560 (js.pir:4711)
called from Sub '_main' pc 38 (main.pir:24)

$ tail -n +4711 js.pir | line
 captob = $P0(captob)

$ parrot main.pir '"test"' 'string_literal'
Null PMC access in invoke()
current instr.: 'parrot;JS;string_literal' pc 7460 (js.pir:3094)
called from Sub '_main' pc 38 (main.pir:24)

$ tail -n +3094 js.pir | line
 captob = $P0(captob, "\"")

$ parrot main.pir '/* test  */' 'multilinecomment'
Null PMC access in invoke()
current instr.: 'parrot;JS;multilinecomment' pc 816 (js.pir:349)
called from Sub '_main' pc 38 (main.pir:24)

$ tail -n +349 js.pir | line
 captob = $P0(captob, "/* */")


--
Mehmet