Error calling bless in non-default constructor

2007-05-15 Thread Matthew Keene
I'm trying to use a non-default constructor for a class under Pugs 6.2.13, like 
so

class MattTest {

  sub new (Class $class : Str $string) {
say Passed $string to the constructor for $class ;
return $class.bless ;
  }
  
}

my $test = MattTest.new('abc') ;

This is failing with the following output:

D:\Apps\Perl6pugs ConstructorTest.p6
Passed abc to the constructor for MattTest
*** No such method in class MattTest: bless
at ConstructorTest.p6 line 5, column 12-25

Am I doing something wrong, or is bless currently unimplemented in Pugs, or is 
something else wrong.  I have more or less copied the code for the constructor 
from the test in oo/construction.t.

  
-
How would you spend $50,000 to create a more sustainable environment in 
Australia?  Go to Yahoo!7 Answers and share your idea.

Re: Error calling bless in non-default constructor

2007-05-15 Thread David Brunton
Is this what you're looking for?

class MattTest {
has Str $.string;
submethod BUILD (:$string) {  ## submethod BUILD is the constructor
## :$string is a named argument 
string
say passed $string;
}
}

my $test = MattTest(:string('abc'));

# Check to see the class is the right kind of thing:

say $test.WHAT

# Output the class as a readable string

say $test.perl;




- Original Message 
From: Matthew Keene [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 15, 2007 5:02:56 AM
Subject: Error calling bless in non-default constructor

I'm trying to use a non-default constructor for a class under Pugs 6.2.13, like 
so

class MattTest {

  sub new (Class $class : Str $string) {
say Passed $string to the constructor for $class ;
return $class.bless ;
  }
  
}

my $test = MattTest.new('abc') ;

This is failing with the following output:

D:\Apps\Perl6pugs ConstructorTest.p6
Passed abc to the constructor for MattTest
*** No such method in class MattTest: bless
at ConstructorTest.p6 line 5, column 12-25

Am I doing something wrong, or is bless currently unimplemented in Pugs, or is 
something else wrong.  I have more or less copied the code for the constructor 
from the test in oo/construction.t.

   
-
How would you spend $50,000 to create a more sustainable environment in 
Australia?  Go to Yahoo!7 Answers and share your idea.




   
Get
 the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php


Re: [perl #42947] [PATCH] revise Parrot_get_runtime_prefix API for safety and usablility

2007-05-15 Thread Paul Cochrane

On 14/05/07, via RT Mike Mattie [EMAIL PROTECTED] wrote:

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


Hello,

This patch changes the Parrot_get_runtime_prefix API from

char* Parrot_get_runtime_prefix(Interp *interp, STRING **prefix_str)

to

STRING* Parrot_get_runtime_prefix (Interp *interp ) {

This is done to make the routine safer, it no longer can leak memory. Also the useless 
. paths
are removed from src/library.c. some minor changes to 
Parrot_locate_runtime_file_str are present
to sync and correct that function.

other callers in src/inter_misc.c , and compilers/imcc/main.c are fixed as well.

also a case of a bare free() being used instead of the proper mem_sys_free is 
fixed.

This relies on #42944 to apply.

Cheers,
Mike Mattie - [EMAIL PROTECTED]




Mike,

It seems the patch didn't come through with the email, could you send it again?

Paul


Re: Error calling bless in non-default constructor

2007-05-15 Thread David Brunton
I think so (after fixing a couple of minor typos).

Does this mean that you can only pass defined attributes to a constructor ?  
What if you want to pass parameters that are used during build but don't 
actually need to be stored in the object ?

Hopefully you don't mind my cc'ing  the list- that way someone searching the 
archives doesn't get stung by my typos ;)

Creating an object should have been:

my MattTest $test .= new(:stringabc); # TIMTOADY and all that ;)

You can pass objects to BUILD that you don't store in the object:

class MattTest {
submethod BUILD (:$foo) {
say $foo;
}
}

hth,
-db.

my $test = MattTest(:string('abc'));

# Check to see the class is the right kind of thing:

say $test.WHAT

# Output the class as a readable string

say $test.perl;




- Original Message 
From:
 Matthew Keene 
To: [EMAIL PROTECTED]
Sent: Tuesday, May 15, 2007 5:02:56 AM
Subject: Error calling bless in non-default constructor

I'm trying to use a non-default constructor for a class under Pugs 6.2.13, like 
so

class MattTest {

  sub new (Class $class : Str $string) {
say Passed $string to the constructor for $class ;
return $class.bless ;
  }
  
}

my $test = MattTest.new('abc') ;

This is failing with the following output:

D:\Apps\Perl6pugs ConstructorTest.p6
Passed abc to the constructor for MattTest
*** No such method in class MattTest: bless
at ConstructorTest.p6 line 5, column 12-25

Am I doing something wrong, or is bless currently unimplemented in Pugs, or is 
something else wrong.  I have more or less copied the code for the constructor 
from the test in oo/construction.t.

  
 
-
How would you spend $50,000 to create a more sustainable environment in 
Australia?  Go to Yahoo!7 Answers and share your idea.




   
Get
 the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

 






  
Switch to Yahoo!7 Mail: Transfer all your contacts and emails from Hotmail and 
other providers to Yahoo!7 Mail. Switch now





   
Need
 a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/

[perl #42954] [CAGE] remove compilers/imcc/rebuild.pl

2007-05-15 Thread via RT
# New Ticket Created by  Jerry Gay 
# Please include the string:  [perl #42954]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42954 


it seems Fcompilers/imcc/rebuild.pl isn't used anymore, and can be
removed. from the pod:

=head1 TITLE

rebuild.pl

=head1 SYNOPSIS

Run a command to rebuild a set of files only if the inputs have
changed, as judged by their checksums.

=head1 USAGE

  rebuild.pl [-v] command input outputs...

=head1 DISCUSSION

This script works by appending the line

  /* CHECKSUM: checksum */

to the end of all generated output files, and checking for that line
before rerunning the build script.

=head1 EXAMPLE

See parrot/config/gen/makefiles/imcc.in for an example usage.

=cut


imcc.in doesn't exist anymore, so i suspect rebuild.pl isn't needed.
please do a proper analysis to determine if this file can go, and
provide a patch which removes it if appropriate.

~jerry


Re: Error calling bless in non-default constructor

2007-05-15 Thread Matthew Keene

Thanks for all your help.  Interestingly enough the .perl method reports that 
the parameter passed to the new method is stored in the object whether it's 
defined as an attribute or not:

class MattTest {
has Str $.bar ;
submethod BUILD (:$foo) {  
say passed $foo;
$.bar = 'def' ;
}

}

my $test = MattTest.new(:foo('abc'));

# Check to see the class is the right kind of thing:

say $test.WHAT ;

# Output the class as a readable string

say $test.perl;

D:\Apps\Perl6pugs ConstructorTest2.p6
passed abc
MattTest
\MattTest.new((bar = def), (foo = abc))

David Brunton [EMAIL PROTECTED] wrote: I think so (after fixing a couple of 
minor typos).

Does this mean that you can only pass defined attributes to a constructor ?  
What if you want to pass parameters that are used during build but don't 
actually need to be stored in the object ?

Hopefully you don't mind my cc'ing  the list- that way someone searching the 
archives doesn't get stung by my typos ;)

Creating an object should have been:

my MattTest $test .= new(:stringabc); # TIMTOADY and all that ;)

You can pass objects to BUILD that you don't store in the object:

class MattTest {
submethod BUILD  (:$foo) {
say $foo;
}
}

hth,
-db.

my $test = MattTest(:string('abc'));

# Check to see the class is the right kind of thing:

say $test.WHAT

# Output the class as a readable string

say $test.perl;




- Original Message 
From:  Matthew Keene 
To: [EMAIL PROTECTED]
Sent: Tuesday, May 15, 2007 5:02:56 AM
Subject: Error calling bless in non-default constructor

I'm trying to use a non-default constructor for a class under Pugs 6.2.13, like 
so

class MattTest {

  sub new (Class $class : Str $string) {
say Passed $string to the constructor for $class ;
return $class.bless ;
  }
  
}

my $test = MattTest.new('abc') ;

This is failing with the following output:

D:\Apps\Perl6pugs ConstructorTest.p6
Passed abc to the constructor for MattTest
*** No such method in class MattTest: bless
at ConstructorTest.p6 line 5, column 12-25

Am I doing something wrong, or is bless currently unimplemented in Pugs, or is 
something else wrong.  I have more or less copied the code for the constructor 
from the test in oo/construction.t.


-
How would you spend $50,000 to create a more sustainable environment in 
Australia?  Go to Yahoo!7 Answers and share your idea.




   
Get
 the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php

  

-
Switch to Yahoo!7 Mail: Transfer all your contacts and emails from Hotmail and 
other providers to Yahoo!7 Mail. Switch now




   
-
Get the free Yahoo! toolbar and rest assured with the added security of spyware 
protection.  

   
-
How would you spend $50,000 to create a more sustainable environment in 
Australia?  Go to Yahoo!7 Answers and share your idea.

Re: [perl #42947] [PATCH] revise Parrot_get_runtime_prefix API for safety and usablility

2007-05-15 Thread Mike Mattie
On Tue, 15 May 2007 05:24:06 -0700
Paul Cochrane via RT [EMAIL PROTECTED] wrote:

 On 14/05/07, via RT Mike Mattie [EMAIL PROTECTED]
 wrote:
  # New Ticket Created by  Mike Mattie
  # Please include the string:  [perl #42947]
  # in the subject line of all future correspondence about this issue.
  # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42947 
 
 
  Hello,
 
  This patch changes the Parrot_get_runtime_prefix API from
 
  char* Parrot_get_runtime_prefix(Interp *interp, STRING **prefix_str)
 
  to
 
  STRING* Parrot_get_runtime_prefix (Interp *interp ) {
 
  This is done to make the routine safer, it no longer can leak
  memory. Also the useless . paths are removed from src/library.c.
  some minor changes to Parrot_locate_runtime_file_str are present to
  sync and correct that function.
 
  other callers in src/inter_misc.c , and compilers/imcc/main.c are
  fixed as well.
 
  also a case of a bare free() being used instead of the proper
  mem_sys_free is fixed.
 
  This relies on #42944 to apply.
 
  Cheers,
  Mike Mattie - [EMAIL PROTECTED]
 
 
 
 Mike,

my mistake. this should go through now that I have attached it :)

 It seems the patch didn't come through with the email, could you send
 it again?
 
 Paul
 
 
--- HEAD/src/library.c	2007-05-14 07:00:17.0 -0700
+++ path-api/src/library.c	2007-05-14 06:14:04.0 -0700
@@ -76,8 +76,6 @@
 VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, runtime/parrot/);
 VTABLE_push_string(interp, paths, entry);
-entry = CONST_STRING(interp, ./);
-VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, lib/parrot/include/);
 VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, lib/parrot/);
@@ -91,8 +89,6 @@
 VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, runtime/parrot/);
 VTABLE_push_string(interp, paths, entry);
-entry = CONST_STRING(interp, ./);
-VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, lib/parrot/library/);
 VTABLE_push_string(interp, paths, entry);
 entry = CONST_STRING(interp, lib/parrot/);
@@ -260,12 +256,14 @@
 else
 paths = get_search_paths(interp, PARROT_LIB_PATH_INCLUDE);
 
-Parrot_get_runtime_prefix(interp, prefix);
+prefix = Parrot_get_runtime_prefix(interp);
+
 n = VTABLE_elements(interp, paths);
 for (i = 0; i  n; ++i) {
 path = VTABLE_get_string_keyed_int(interp, paths, i);
-if (string_length(interp, prefix) 
-   !parrot_path_is_abs(interp,path)) {
+if (prefix
+ string_length(interp,prefix)
+ !parrot_path_is_abs(interp,path)) {
 full_name = parrot_path_concat(interp, prefix , path);
 }
 else
@@ -281,7 +279,22 @@
 return full_name;
 }
 
- full_name = ( type  PARROT_RUNTIME_FT_DYNEXT )
+if (prefix  string_length(interp,prefix)) {
+/* try this after the built-in paths to avoid security
+   issues with the default . being used before builtin
+   paths */
+
+full_name = parrot_path_concat(interp, prefix , file);
+
+full_name = ( type  PARROT_RUNTIME_FT_DYNEXT )
+? try_load_path(interp, full_name)
+: try_bytecode_extensions(interp, full_name);
+
+if ( full_name )
+return full_name;
+}
+
+full_name = ( type  PARROT_RUNTIME_FT_DYNEXT )
 ? try_load_path(interp, file)
 : try_bytecode_extensions(interp, file);
 
@@ -308,60 +321,76 @@
  */
 return string_to_cstring(interp, result);
 }
-/*
-
-=item Cchar* Parrot_get_runtime_prefix(Interp *, STRING **prefix_str)
 
-If Cprefix_str is not NULL, set it to the prefix, else return a malloced
-c-string for the runtime prefix.  Remember to free the string with
-Cstring_cstring_free().
-
-=cut
+static STRING*
+query_runtime_prefix ( Interp* interp ) {
 
-*/
+STRING* prefix;
 
-char*
-Parrot_get_runtime_prefix(Interp *interp, STRING **prefix_str)
-{
-STRING *s, *key;
-PMC *config_hash;
 int free_it;
 char *env;
 
 env = Parrot_getenv(PARROT_RUNTIME, free_it);
+
 if (env) {
-if (prefix_str) {
-*prefix_str = string_from_cstring(interp, env, 0);
-if (free_it)
-free(env);
-return NULL;
-}
-if (!free_it)
-env = strdup(env);
-return env;
+prefix = string_from_cstring(interp, env, 0);
+if (free_it)
+mem_sys_free(env);
+
+return prefix;
 }
 
+return NULL;
+}
+
+/*
+
+=item CSTRING* Parrot_get_runtime_prefix(Interp * )
+
+return the runtime prefix in the PMC string Cprefix. The
+config hash is consulted first, then the environment variable
+PARROT_RUNTIME. If neither are found NULL is returned.
+=cut
+
+*/
+
+STRING*
+Parrot_get_runtime_prefix (Interp *interp ) {
+
+PMC *config_hash;
+
+STRING *key, *can_fail; /* 

Re: [PATCH] Add a few clarifying comments about res_lea.c

2007-05-15 Thread Allison Randal

Andy Dougherty wrote:
This patch adds a few clarifications to comments.  And I'm afraid this is 
how I'll have to leave it for now.


Applied in r18549, and many thanks!

Allison


Re: Is Perl 6 too late?

2007-05-15 Thread Larry Wall
On Mon, May 14, 2007 at 10:48:34PM -0700, Garrett Cooper wrote:
: No one mentioned that if it wasn't for sigils, many strings would be 
: increased, length-wise, to do operator concatentation. If it wasn't for 
: that then simple string insertions couldn't be used.

Well, except you can interpolate in Perl 6 with bare closures, so

say answer = {foo}

wouldn't be so bad.

: The only thing I hate about Perl with required formatting is the silly 
: braces. If it's one line and separated by visible whitespace, why is the 
: only option available to me the
: 
:   statement_1 if(statement_2);
: 
: or
: 
:   statement_1 unless(statement_2);
: 
: syntax? Seems less readable than:
: 
:   if(statement_2)
:   statement_1
: 
: or
: 
:   unless(statement_2)
:   statement_1

That has been a not-infrequent complaint about Perl from people coming
from a C-ish background.  However, what we discovered with the Perl 6
design was that it was not, in fact, the braces that were silly, but
the parentheses.  The braces consistently represent a closure in Perl 6,
even in control constructs, which are not special-cased as in C and Perl 5.
But by taking that approach we can get rid of the parens that are doing
only syntactic work without carrying any semantic weight.  So Perl 6 ends
up with the one-liner:

if statement_2 { statement_1 }

and that's no more characters than your parentesized version.

Now you might think that the curlies are still useless there, but the
fact that it's a closure means you can capture the value of the control
condition if you like.  This would be rare with an if, but with other
control flow structures it's quite common.  In particular this very
common construct:

for 1..100 - $i { say $i }

Since - is just a built-in way of writing an anonymous sub with
arguments, there's no need to invent special syntax for loop variables!

And when you say

for 1..100 { say $_ }

you're still logically calling an anonymous sub with a single parameter
called $_.  I freely admit that the use of braces in C and Perl 5 is
silly, but the braces in Perl 6 are about as far from silly as you
can get.

: The only legitimacy for the first set of formats would be if in fact you 
: were reading off the logic statement in a left-to-right language. But 
: then again many languages don't follow that convention (Japanese, 
: Korean, etc etc for instance).

Oddly, the statement modifier is borrowed directly from English.

: The same opinion goes for all loops, except the
: 
:   do { statement } ( { while, until } );
: 
: variety.

That particular construct comprises several additional cans of worms.  :)

Larry


Re: [svn:parrot] r18547 - in trunk/src: . io pmc

2007-05-15 Thread chromatic
On Tuesday 15 May 2007 09:08:47 [EMAIL PROTECTED] wrote:

 Log:
 eliminate some compiler warnings
 ~ all tests pass

 Modified: trunk/src/debug.c
 ===
=== --- trunk/src/debug.c   (original)
 +++ trunk/src/debug.c   Tue May 15 09:08:45 2007
 @@ -1983,8 +1983,10 @@
  PDB_eval(Interp *interp, const char *command)
  {
      opcode_t *run;
 +#if 0
      PackFile *eval_pf;
      PackFile_ByteCode *old_cs;
 +#endif

The UNUSED() macro seems to be slightly more descriptive.  If you have an 
update soon that'll use those variables, this is fine for now, but I hate to 
have more #if 0 ... #endif pairs in the source without explanation why 
they're there.

-- c


Re: [svn:parrot] r18547 - in trunk/src: . io pmc

2007-05-15 Thread chromatic
On Tuesday 15 May 2007 11:22:25 jerry gay wrote:

 just below this code in that file, there's an #if 0 block i'm not
 responsible for. there vars were used only in that block. i wrapped
 them in #if 0 simply to remove the warning, while keeping the intent
 of the code the same.

 i agree that #if 0 is bad practice in general. i didn't have tuits at
 the time to perform a code review on this block--i just corrected an
 oversight by the original coder. i've forwarded this to rt, so
 somebody can clean up this code properly.

That's very reasonable.  I think we've found our FOTW.

-- c


Re: explicit line termination with ;: why?

2007-05-15 Thread Dave Whipp

Jonathan Lang wrote:


Close.  I'm thinking added functionality for semicolon alternatives
rather than the replace the semicolon stunt that Semi::Semicolons
pulls.  In particular, as long as there's no ambiguity between
prefix:? and postfix:?, I think that it would be quite useful for
postfix:? to act as a semicolon that additionally sets $_ equal to
the expression's value, allowing for a pseudo-Prolog style of syntax
(i.e., the code could include questions as well as declarations and
instructions).


A slightly tangental thought: is the behavior of Cgiven with no block 
defined? I.e. is


given $foo { when 1 {...} };

equivalent to

given $foo;
when 1 {...};


[perl #42960] Re: [svn:parrot] r18547 - in trunk/src: . io pmc

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


On Tuesday 15 May 2007 11:22:25 jerry gay wrote:

 just below this code in that file, there's an #if 0 block i'm not
 responsible for. there vars were used only in that block. i wrapped
 them in #if 0 simply to remove the warning, while keeping the intent
 of the code the same.

 i agree that #if 0 is bad practice in general. i didn't have tuits at
 the time to perform a code review on this block--i just corrected an
 oversight by the original coder. i've forwarded this to rt, so
 somebody can clean up this code properly.

That's very reasonable.  I think we've found our FOTW.

-- c


Re: Feeling Slushy

2007-05-15 Thread Leopold Toetsch
Am Dienstag, 15. Mai 2007 01:17 schrieb chromatic:
 Hi everyone,

 I'm handling the release tomorrow, so please hold off on changes to the
 core code until after the release.  Documentation and typo fixes are fine.
 Language changes are fine too.  Not-too-invasive bug fixes are good.

 In the meantime, I'd like to collect platform status results, smoke test
 results, and any information you think should be in the new features list.

Statically built parrot on SuSE 10.1 AMD X2, gcc 4.1.0
2.6.16.27-0.9-smp #1 SMP Tue Feb 13 09:35:18 UTC 2007 x86_64 x86_64 x86_64 
GNU/Linux

All tests successful, 9 tests and 548 subtests skipped.

Same compiled as 32-bit parrot ( ./Configure.pl  --m=32 ... )

Failed Test  Stat Wstat Total Fail  Failed  List of Failed
---
t/examples/library.t1   256 41  25.00%  3
t/library/pcre.t1   256 11 100.00%  1
10 tests and 546 subtests skipped.
 
$ make testj # on above 32-bit version

Failed Test  Stat Wstat Total Fail  Failed  List of Failed
---
t/dynoplibs/myops.t 1   256 81  12.50%  4
t/examples/japh.t   1   256171   5.88%  4
t/examples/library.t1   256 41  25.00%  3
t/library/pcre.t1   256 11 100.00%  1
t/pmc/threads.t 1   256201   5.00%  16
9 tests and 170 subtests skipped.
Failed 5/224 test scripts, 97.77% okay. 5/4435 subtests failed, 99.89% okay.

 -- c

HTH
leo


[perl #42959] Re: [svn:parrot] r18547 - in trunk/src: . io pmc

2007-05-15 Thread via RT
# New Ticket Created by  Jerry Gay 
# Please include the string:  [perl #42959]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42959 


On 5/15/07, chromatic [EMAIL PROTECTED] wrote:
 On Tuesday 15 May 2007 09:08:47 [EMAIL PROTECTED] wrote:

  Log:
  eliminate some compiler warnings
  ~ all tests pass
 
  Modified: trunk/src/debug.c
  ===
 === --- trunk/src/debug.c(original)
  +++ trunk/src/debug.cTue May 15 09:08:45 2007
  @@ -1983,8 +1983,10 @@
  PDB_eval(Interp *interp, const char *command)
  {
  opcode_t *run;
  +#if 0
  PackFile *eval_pf;
  PackFile_ByteCode *old_cs;
  +#endif

 The UNUSED() macro seems to be slightly more descriptive.  If you have an
 update soon that'll use those variables, this is fine for now, but I hate to
 have more #if 0 ... #endif pairs in the source without explanation why
 they're there.

 -- c

just below this code in that file, there's an #if 0 block i'm not
responsible for. there vars were used only in that block. i wrapped
them in #if 0 simply to remove the warning, while keeping the intent
of the code the same.

i agree that #if 0 is bad practice in general. i didn't have tuits at
the time to perform a code review on this block--i just corrected an
oversight by the original coder. i've forwarded this to rt, so
somebody can clean up this code properly.

~jerry


Re: explicit line termination with ;: why?

2007-05-15 Thread Luke Palmer

On 5/15/07, Dave Whipp [EMAIL PROTECTED] wrote:

A slightly tangental thought: is the behavior of Cgiven with no block
defined? I.e. is

given $foo { when 1 {...} };

equivalent to

given $foo;
when 1 {...};


Doubtful.

However, I do think that it's useful to be able to treat the rest of
the current scope as a block (usually with a parameter), for certain
kinds of closure-heavy code.  For example, instead of saying:

 {
   foo - $x {
 bar;
 baz - $y {
   quux;
   bizzle;
 }
   }
 }

Writing that as, say:

 {
   foo - $x;
   bar;
   baz - $y;
   quux;
   bizzle;
 }

Can really help readability in situations when the control flow wants
to look linear.  That's not to say that the - $x; syntax makes any
sense.

Luke


Re: [perl #42961] [PATCH] add const qualifiers to free signature

2007-05-15 Thread Nicholas Clark
On Tue, May 15, 2007 at 12:10:09PM -0700, Mike Mattie wrote:

 If someone remembers the magic to muzzle the compiler around free( from )
 in memory.c please feel free to amend the patch.

I remember being told that there's a trick involving a union. Something like

union {
  void *out;
  const void *in;
} launder;

You assign to in, then read from out. Et voila, you launder the const away.

Nicholas Clark


Re: explicit line termination with ;: why?

2007-05-15 Thread Larry Wall
On Tue, May 15, 2007 at 11:59:35AM -0700, Dave Whipp wrote:
: Jonathan Lang wrote:
: 
: Close.  I'm thinking added functionality for semicolon alternatives
: rather than the replace the semicolon stunt that Semi::Semicolons
: pulls.  In particular, as long as there's no ambiguity between
: prefix:? and postfix:?, I think that it would be quite useful for
: postfix:? to act as a semicolon that additionally sets $_ equal to
: the expression's value, allowing for a pseudo-Prolog style of syntax
: (i.e., the code could include questions as well as declarations and
: instructions).
: 
: A slightly tangental thought: is the behavior of Cgiven with no block 
: defined? I.e. is

It would be illegal syntax currently.

: given $foo { when 1 {...} };
: 
: equivalent to
: 
: given $foo;
: when 1 {...};

Both of these suggestions would seem to duplicate the existing construct:

$_ = $foo;

:-)

Of course, now someone will argue that unary:= should assign to $_ by
default, in which case we'd have to find a new interation operator...

Larry


[perl #42961] [PATCH] add const qualifiers to free signature

2007-05-15 Thread via RT
# New Ticket Created by  Mike Mattie 
# Please include the string:  [perl #42961]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42961 


This patch adds const qualifiers to string_cstring_free , and mem_sys_free.
In reviewing other commits to the parrot tree I noticed that authors were
dropping const qualifiers because it was generating warnings when they
passed their pointer to mem_sys_free.

const qualifiers are one of the most powerful optimization and debugging
tools available in the C language and should be preserved and used
thoroughly.

This patch changes the signature of the mem_sys_free , and string_cstring_free
functions to const type const which is the most const qualified form.

types that are not already const qualified are automatically promoted to
the qualified form.

This generates one new warning in memory.c about free discarding qualifiers.
The intent has been expressed with a (void*) cast , but the compiler is still
warning. This is harmless. I would rather have this one warning , than a tree
stripped of const.

If someone remembers the magic to muzzle the compiler around free( from )
in memory.c please feel free to amend the patch.

--- HEAD/src/string.c	2007-05-14 08:08:31.0 -0700
+++ mine/src/string.c	2007-05-15 11:18:05.0 -0700
@@ -1880,7 +1880,7 @@
 */
 
 void
-string_cstring_free(char *p)
+string_cstring_free(const char * const p)
 {
 mem_sys_free(p);
 }
--- HEAD/include/parrot/string_funcs.h	2007-05-14 08:08:45.0 -0700
+++ mine/include/parrot/string_funcs.h	2007-05-15 11:22:52.0 -0700
@@ -83,7 +83,7 @@
 PARROT_API STRING *const_string(Interp *, const char *buffer)
 __attribute__nonnull__(2);
 PARROT_API char *string_to_cstring(Interp *, STRING *);
-PARROT_API void string_cstring_free(char *);
+PARROT_API void string_cstring_free(const char * const);
 PARROT_API void string_pin(Interp *, STRING *);
 PARROT_API void string_unpin(Interp *, STRING *);
 PARROT_API STRING *string_bitwise_and(Interp *interp, STRING *s1,
--- HEAD/src/gc/memory.c	2007-05-14 08:08:20.0 -0700
+++ mine/src/gc/memory.c	2007-05-15 11:46:42.0 -0700
@@ -153,13 +153,13 @@
 */
 
 void
-mem_sys_free(void *from)
+mem_sys_free(const void * const from)
 {
 #ifdef DETAIL_MEMORY_DEBUG
 fprintf(stderr, Freed %p\n, from);
 #endif
 if (from)
-free(from);
+free((void*)from);
 }
 
 void
--- HEAD/include/parrot/memory.h	2007-05-14 08:08:45.0 -0700
+++ mine/include/parrot/memory.h	2007-05-15 11:51:29.0 -0700
@@ -19,7 +19,7 @@
 
 PARROT_API void *mem__sys_realloc(void *, size_t);
 #define mem_sys_realloc(x,y) (assert(x!=NULL), mem__sys_realloc(x,y))
-PARROT_API void mem_sys_free(void *);
+PARROT_API void mem_sys_free(const void * const);
 
 void *mem__internal_allocate(size_t, const char *, int);
 #define mem_internal_allocate(x) mem__internal_allocate(x, __FILE__, __LINE__)


signature.asc
Description: PGP signature


Re: explicit line termination with ;: why?

2007-05-15 Thread Daniel Hulme
On Tue, May 15, 2007 at 01:14:44PM -0600, Luke Palmer wrote:
 However, I do think that it's useful to be able to treat the rest of
 the current scope as a block (usually with a parameter), for certain
 kinds of closure-heavy code.
Maybe this is a case for one of Mr. Lang's custom semicolons with added
functionality: you could have something that worked a bit like the
lambda-calculus .. It would slurp up as much of the RHS as possible,
which would almost always[1] be until the end of the enclosing block,
and 'return' it (in a syntactic way) to whatever on the LHS wants a
block.  So, like Mr. Palmer's example, you would get something like

sub do_stuff() {
  my @foo = get_me_a_list;
  for @foo :-
  .subst(/bar/,'baz').say;
}

[1] By almost always I mean I can't think of a reason for it to
sometimes not be that, but one or more may exist. Anywhere you would
want it to stop before the end of the enclosing block you should
probably use curlies anyway to stop it being confusing.

I'm not sure whether I would use these magic brace-opening semicolons
even if they were in. It seems to be to be less readable, but maybe
that's just because I haven't seen a compelling enough example. In the
worst case they would lead to code that looks like the old-style TeX
idiom of normal {\bf bold} normal, where you open braces around the
whole block and do a state-change-like thing inside rather than a
functional thing that takes the thing you want operated on as an
argument. That doesn't mean we shouldn't allow custom semicolons with
added functionality; just that maybe this is not the best use for them
after all.

-- 
Mary had a little sprout,From week to week, from month to month,
Its fleece was green as grass,   She kept the sprout in tow,
She hitched it to a bit of string,And everywhere that Mary went,
The silly little ass. The sprout was sure to go.


signature.asc
Description: Digital signature


[perl #42962] [Ops] sprintf.t Fails on x86-64 Linux

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


From pmichaud:

[EMAIL PROTECTED]:~/parrot/trunk prove -v t/op/sprintf.t
t/op/sprintf1..308
ok 1 - [%6. 6s] (See use of $w in code above)
ok 2 - [%6 .6s]
ok 3 - [%6.6 s]
ok 4 - [%A]
ok 5 #skip parrot extension (%B)
ok 6 - [%C]
ok 7 #skip perl5-specific extension (%D)
ok 8 - [%E] Like %e, but using upper-case E
ok 9 #skip perl5-specific extension (%F)
ok 10 - [%G] Like %g, but using upper-case E
ok 11 - [%G]
ok 12 - [%G]
ok 13 - [%G]
ok 14 - [%G] exponent too big skip: os390
ok 15 - [%G] exponent too small skip: os390
ok 16 #skip parrot extension (%H)
ok 17 - [%I]
ok 18 - [%J]
ok 19 - [%K]
ok 20 #skip parrot extension (%L)
ok 21 - [%M]
ok 22 - [%N]
ok 23 #skip perl5-specific extension (%O)
ok 24 #skip parrot extension (%P)
ok 25 - [%Q]
ok 26 - [%R]
ok 27 #skip parrot extension (%S)
ok 28 - [%T]
ok 29 #skip perl5-specific extension (%U)
ok 30 - [%V]
ok 31 - [%W]
ok 32 - [%X] Like %x, but with u/c letters
ok 33 - [%#X]
ok 34 - [%Y]
ok 35 - [%Z]
parrot: src/string.c:727: string_str_index: Assertion `s-encoding  
s-charset  !(((s)-obj.flags)  b_PObj_on_free_list_FLAG)' failed.
dubious
Test returned status 0 (wstat 6, 0x6)


Re: [perl #42962] [Ops] sprintf.t Fails on x86-64 Linux

2007-05-15 Thread chromatic
On Tuesday 15 May 2007 12:31:08 chromatic wrote:

 From pmichaud:

 [EMAIL PROTECTED]:~/parrot/trunk prove -v t/op/sprintf.t
 t/op/sprintf1..308
 parrot: src/string.c:727: string_str_index: Assertion `s-encoding 
 s-charset  !(((s)-obj.flags)  b_PObj_on_free_list_FLAG)' failed.
 dubious
 Test returned status 0 (wstat 6, 0x6)

The attached patch works around the problem on 32-bit and 64-bit x86 Linux.  
How are other platforms?

-- c

--- src/string.c	(revision 3496)
+++ src/string.c	(local)
@@ -724,9 +724,7 @@
 if (!string_length(interp, s2))
 return -1;
 
-saneify_string(s);
-saneify_string(s2);
-src = (STRING *)const_cast(s);
+src= (STRING *)const_cast(s);
 search = (STRING *)const_cast(s2);
 
 return CHARSET_INDEX(interp, src, search, start);


Re: [svn:parrot] r18547 - in trunk/src: . io pmc

2007-05-15 Thread jerry gay

On 5/15/07, chromatic [EMAIL PROTECTED] wrote:

On Tuesday 15 May 2007 09:08:47 [EMAIL PROTECTED] wrote:

 Log:
 eliminate some compiler warnings
 ~ all tests pass

 Modified: trunk/src/debug.c
 ===
=== --- trunk/src/debug.c(original)
 +++ trunk/src/debug.cTue May 15 09:08:45 2007
 @@ -1983,8 +1983,10 @@
 PDB_eval(Interp *interp, const char *command)
 {
 opcode_t *run;
 +#if 0
 PackFile *eval_pf;
 PackFile_ByteCode *old_cs;
 +#endif

The UNUSED() macro seems to be slightly more descriptive.  If you have an
update soon that'll use those variables, this is fine for now, but I hate to
have more #if 0 ... #endif pairs in the source without explanation why
they're there.

-- c


just below this code in that file, there's an #if 0 block i'm not
responsible for. there vars were used only in that block. i wrapped
them in #if 0 simply to remove the warning, while keeping the intent
of the code the same.

i agree that #if 0 is bad practice in general. i didn't have tuits at
the time to perform a code review on this block--i just corrected an
oversight by the original coder. i've forwarded this to rt, so
somebody can clean up this code properly.

~jerry


Re: [perl #42919] [BUG] and [PATCH] overriding 'invoke' requires current object to be explicitly passed

2007-05-15 Thread Alek Storm

On 5/14/07, Mehmet Yavuz Selim Soyturk [EMAIL PROTECTED] 
wrote:


Should we not be able to use an object that implements 'invoke' as a
method of another object? There is some strange behaviour when I try
to.



I see what you're saying, and it looks like you want a functor.  We can't do
exactly what you want in that syntax, because methods are loosely tied to
objects in Parrot.  Parrot sees 'Func' as a sub, so it wouldn't make any
sense to tell the sub it's called by itself.  Regardless of what
'find_method' returns, the invocant is $P2 when you use PIR syntax.  Here's
how to get the effect you want:

.sub main :main
 $P0 = newclass 'Func'
 $P1 = newclass 'Obj'
 $P2 = new 'Obj'
 $P3 = find_method $P2, 'some_method'
 $P3.$P3()
.end

The patch has been reverted, though, so that won't work until it's fixed and
reapplied.

--
Alek Storm


Re: [perl #42919] [BUG] and [PATCH] overriding 'invoke' requires current object to be explicitly passed

2007-05-15 Thread Alek Storm

On 5/15/07, Allison Randal via RT [EMAIL PROTECTED] wrote:


And reverted in r18541. The patch is fragile. Broken on Windows, and
fixing it for Windows breaks it for OSX and Linux.



Whoops, I had no idea it didn't work on Windows.  I have no way to test on
that platform.  What was the problem?  The patch was kind of a hack, so I'm
not surprised it exploded in a different environment.  I'll try a completely
different approach, and get back to you.  Thanks.

--
Alek Storm


Re: [perl #42961] [PATCH] add const qualifiers to free signature

2007-05-15 Thread Leopold Toetsch
Am Dienstag, 15. Mai 2007 21:28 schrieb Nicholas Clark:
 On Tue, May 15, 2007 at 12:10:09PM -0700, Mike Mattie wrote:
  If someone remembers the magic to muzzle the compiler around free( from )
  in memory.c please feel free to amend the patch.

 I remember being told that there's a trick involving a union. Something
 like

 union {
   void *out;
   const void *in;
 } launder;

 You assign to in, then read from out. Et voila, you launder the const away.

Well, there is of course ;) such a macro already:

include/parrot/parrot.h:#define const_cast(b) (__ptr_u.__c_ptr = (b), 
__ptr_u.__ptr)

See usage in e.g.

$ grep const_cast src/string.c

 Nicholas Clark

leo


Re: [perl #42954] [CAGE] remove compilers/imcc/rebuild.pl

2007-05-15 Thread chromatic
On Tuesday 15 May 2007 06:20:05 Jerry Gay wrote:

 it seems Fcompilers/imcc/rebuild.pl isn't used anymore, and can be
 removed.

Yeah, that's way old.  Removed in r18559.

-- c


Re: explicit line termination with ;: why?

2007-05-15 Thread Jonathan Lang

Larry Wall wrote:

Dave Whipp wrote:
: A slightly tangental thought: is the behavior of Cgiven with no block
: defined? I.e. is

It would be illegal syntax currently.


As I understand it, the proposal is to say that if the parser finds a
';' where it was expecting to find a control block, it treats the rest
of the current block as the expected control block - or something to
that effect.  Eh... messy, and with no substantial gain.


: given $foo { when 1 {...} };
:
: equivalent to
:
: given $foo;
: when 1 {...};

Both of these suggestions would seem to duplicate the existing construct:

$_ = $foo;

:-)


Agreed.  But I think that postfix:? is rather clean:

   $foo?
   when 1 {...}

Two catches:

1. I could easily define postfix:? myself, save for one thing: what
would I put as the parameter for the 'is equiv' trait, so that it has
terminator precedence?

2. 'when' implicitly leaves its current block after successfully being
executed (as per 'last'), since it's designed primarily for use as one
of a set of mutually-exclusive options.  I'm not sure how wise of a
decision that is, since it's easier to add a last to a block that
implicitly lacks one than it is to remove a last from a block that
implicitly includes one.  Part of me would strongly prefer that when
$x { ... } be exactly equivalent to if $_ ~~ $x { ... }, except for
the inability to append an else block to the former.


Of course, now someone will argue that unary:= should assign to $_ by
default, in which case we'd have to find a new iteration operator...


Horrors, no!  '=$filehandle' works just fine for reading an iterator,
thank you...

I _might_ flirt with the idea of postfix:= being equivalent to a
filehandle's '.say' method (i.e., writing to an iterator) - or not.
Given the mandatory whitespace that a postfix operator imposes on an
equivalent infix operator, I'd strongly suggest that good practice for
Perl 6 would be to avoid defining both forms if at all reasonable; and
infix:= definitely has the edge here.  (Rule of thumb: if you can
avoid doing something that will mandate or forbid whitespace, avoid
it.)

--
Jonathan Dataweaver Lang


Re: [perl #42918] [PATCH] src/library.c use mem_sys_free instead of free()

2007-05-15 Thread chromatic
On Thursday 10 May 2007 17:15:52 Mike Mattie wrote:

 I noticed that I dropped it. I went into the RT system immediately after
 sending and attached the file. It's a really trivial change but the
 patch is there, just two instances of free converted to mem_sys_free.

 btw passed harness on i686-pc-gnu-linux

This change is indeed trivial (unless someone has a completely broken C 
compiler, in which case we have bigger problems).  Thanks, applied as r18561.

-- c


Re: [PATCH] Re: [perl #37819] Sun4 builds fail linking against jit.o

2007-05-15 Thread chromatic
On Wednesday 09 May 2007 07:21:44 Andy Dougherty wrote:

 [appending to an old ticket, since if anyone wants to ever get this
 working again, they'll probably have to fix up the blind guesses I made in
 that old patch too.]

Thanks, applied as r18562 (er, oops -- r18561, due to an excruciatingly slow 
commit).

-- c


Re: [perl #42950] [PATCH] mswin32 (msvc) builds don't need -lodbc32

2007-05-15 Thread chromatic
On Monday 14 May 2007 12:47:59 Mark Glines wrote:

 I removed it from the linker line, did a configure, build, and smoke.
 I detected no ill effects.  (other than an intermittant three alarms
 thing in t/dynoplibs/myops.t that was there before the change.)  So,
 how about removing it?

Applied in r18560.  Thanks!

-- c


[svn:parrot-pdd] r18563 - in trunk: . compilers/json compilers/tge compilers/tge/TGE config/auto config/auto/cpu/i386 config/auto/cpu/ppc config/auto/cpu/sun4 config/auto/cpu/x86_64 config/gen config/

2007-05-15 Thread chromatic
Author: chromatic
Date: Tue May 15 17:53:55 2007
New Revision: 18563

Modified:
   trunk/docs/pdds/draft/pdd04_datatypes.pod
   trunk/docs/pdds/draft/pdd05_opfunc.pod
   trunk/docs/pdds/draft/pdd06_pasm.pod
   trunk/docs/pdds/draft/pdd11_extending.pod
   trunk/docs/pdds/draft/pdd16_native_call.pod
   trunk/docs/pdds/draft/pdd24_events.pod
   trunk/docs/pdds/draft/pdd25_concurrency.pod
   trunk/docs/pdds/draft/pddXX_pmc.pod
   trunk/docs/pdds/pdd07_codingstd.pod
   trunk/docs/pdds/pdd21_namespaces.pod
   trunk/docs/pdds/pdd22_io.pod
   trunk/docs/pdds/pdd23_exceptions.pod

Changes in other areas also in this revision:
Modified:
   trunk/Configure.pl
   trunk/compilers/json/JSON.pir
   trunk/compilers/json/postalcodes.pir
   trunk/compilers/tge/TGE.pir
   trunk/compilers/tge/TGE/Compiler.pir
   trunk/compilers/tge/TGE/Grammar.pir
   trunk/compilers/tge/TGE/Rule.pir
   trunk/compilers/tge/TGE/Tree.pir
   trunk/config/auto/cpu.pm
   trunk/config/auto/cpu/i386/auto.pm
   trunk/config/auto/cpu/ppc/auto.pm
   trunk/config/auto/cpu/sun4/auto.pm
   trunk/config/auto/cpu/x86_64/auto.pm
   trunk/config/auto/gc.pm
   trunk/config/auto/gcc.pm
   trunk/config/auto/m4.pm
   trunk/config/auto/msvc.pm
   trunk/config/auto/readline.pm
   trunk/config/auto/socklen_t.pm
   trunk/config/auto/va_ptr.pm
   trunk/config/gen/PodText.pm
   trunk/config/gen/config_h.pm
   trunk/config/gen/core_pmcs.pm
   trunk/config/gen/languages.pm
   trunk/config/gen/makefiles.pm
   trunk/config/gen/makefiles/dynoplibs_pl.in
   trunk/config/gen/makefiles/root.in
   trunk/config/gen/platform.pm
   trunk/config/gen/revision.pm
   trunk/config/init/defaults.pm
   trunk/config/init/hints/linux.pm
   trunk/config/init/hints/mswin32.pm
   trunk/config/init/hints/msys.pm
   trunk/config/init/hints/netbsd.pm
   trunk/config/init/install.pm
   trunk/config/inter/lex.pm
   trunk/config/inter/libparrot.pm
   trunk/config/inter/make.pm
   trunk/config/inter/pmc.pm
   trunk/config/inter/progs.pm
   trunk/config/inter/shlibs.pm
   trunk/config/inter/yacc.pm
   trunk/docs/compiler_faq.pod
   trunk/docs/configuration.pod
   trunk/docs/dev/fhs.pod
   trunk/docs/dev/optimizer.pod
   trunk/docs/dev/wranglers.pod
   trunk/docs/extend.pod
   trunk/docs/imcc/calling_conventions.pod
   trunk/docs/optable.pod
   trunk/docs/req/model_users.pod
   trunk/docs/running.pod
   trunk/docs/stm/atomic.pod
   trunk/docs/stm/stm_frontend.pod
   trunk/docs/vtables.pod
   trunk/examples/benchmarks/addit.pir
   trunk/examples/benchmarks/addit2.pir
   trunk/examples/benchmarks/array_access.pir
   trunk/examples/benchmarks/arriter.pir
   trunk/examples/benchmarks/arriter_o1.pir
   trunk/examples/benchmarks/fib.pir
   trunk/examples/benchmarks/mops.pl
   trunk/examples/benchmarks/stress.pl
   trunk/examples/benchmarks/stress1.pl
   trunk/examples/benchmarks/stress2.pl
   trunk/examples/io/async_select.pir
   trunk/examples/io/echo_client.pir
   trunk/examples/io/http.pir
   trunk/examples/io/httpd.pir
   trunk/examples/io/httpd2.pir
   trunk/examples/library/getopt_demo.pir
   trunk/examples/library/ncurses_life.pir
   trunk/examples/library/pcre.pir
   trunk/examples/mops/mops.pl
   trunk/examples/nci/ls.pir
   trunk/examples/nci/win32api.pir
   trunk/examples/pir/circle.pir
   trunk/examples/pir/euclid.pir
   trunk/examples/pir/hanoi.pir
   trunk/examples/pir/hello-dwim.pir
   trunk/examples/pir/io.pir
   trunk/examples/pir/life.pir
   trunk/examples/pir/local_label.pir
   trunk/examples/pir/mandel.pir
   trunk/examples/pir/readline.pir
   trunk/examples/pir/substr.pir
   trunk/examples/pir/thr-primes.pir
   trunk/examples/pir/uniq.pir
   trunk/examples/sdl/mandel.pir
   trunk/examples/subs/multi_retvals.pir
   trunk/examples/subs/no_retval.pir
   trunk/examples/subs/single_retval.pir
   trunk/ext/Parrot-Embed/lib/Parrot/Embed.pm
   trunk/ext/Parrot-Embed/lib/Parrot/Interpreter.pm
   trunk/ext/Parrot-Embed/lib/Parrot/PMC.pm
   trunk/languages/HQ9plus/HQ9plus.pir
   trunk/languages/HQ9plus/t/basic.t
   trunk/languages/WMLScript/runtime/wmlsconsole.pir
   trunk/languages/WMLScript/runtime/wmlsfloat.pir
   trunk/languages/WMLScript/runtime/wmlslang.pir
   trunk/languages/WMLScript/runtime/wmlsstring.pir
   trunk/languages/WMLScript/src/WMLScript.pir
   trunk/languages/WMLScript/t/Parrot/Test/WMLScript.pm
   trunk/languages/WMLScript/t/boolean.t
   trunk/languages/WMLScript/t/examples.t
   trunk/languages/WMLScript/t/expr.t
   trunk/languages/WMLScript/t/float.t
   trunk/languages/WMLScript/t/functions.t
   trunk/languages/WMLScript/t/harness
   trunk/languages/WMLScript/t/integer.t
   trunk/languages/WMLScript/t/invalid.t
   trunk/languages/WMLScript/t/lang.t
   trunk/languages/WMLScript/t/libfloat.t
   trunk/languages/WMLScript/t/libstring.t
   trunk/languages/WMLScript/t/literals.t
   trunk/languages/WMLScript/t/logical.t
   trunk/languages/WMLScript/t/pmc/boolean.t
   trunk/languages/WMLScript/t/pmc/float.t
   trunk/languages/WMLScript/t/pmc/integer.t
   

Preliminary NEWS Update for 0.4.12

2007-05-15 Thread chromatic
Hi all,

Here's what the NEWS will say for Parrot 0.4.12.  Additions and corrections 
welcome.

-- c

Refactored configuration system
- improved tests
- improved documentation

Better object support (PDD 15)

Language updates:
- abc
- Plumhead
- Lua
- Tcl
- Lisp (reclaimed from the ghetto of uncompilation)

Core updates:
- many bug fixes
- minor garbage collector and memory management improvements
- more memory leaks resolved
- C++ cleanups
- many refactorings
- header guard improvements
- structs and types improved to match coding standards
- several tests ported from Perl to PIR


Re: [RFC] extension guessing, functionally better loader behavior - working install target

2007-05-15 Thread Mike Mattie
On Sun, 13 May 2007 22:46:15 -0700
Mike Mattie [EMAIL PROTECTED] wrote:

 Hello,
 
[snip RFC]

Here is a revised and cleaned up specification of the search algorithm taken 
from my current description
of the Parrot_locate_runtime_str function.


/*

=item Cchar* Parrot_locate_runtime_file(Interp *,
 const char *object_name,
 STRING *hll
 enum_runtime_ft *loader
 STRING* trace)

Parrot_locate_runtime_str searches the filesystem for object files
containing code of some sort. This functionality is shared by several
opcodes/components and is designed with parrot's unusual flexiblity in
mind.

object_name : the name of the object to load. It can be simply a name,
  path, or absolute path.

hll : The hll argument is the key to the HLL name-space. The
  default namespace is used if the namespace does not exist
  or is null.

  The default name-space is parrot.

loader  : a bit-mask selecting loaders to be included in the search.
  This arguement is passed by reference. When a matching file
  is found the value of loader is reset to the flag for the
  loader under which it was found.

  loader is not modified unless a matching file is found.

trace   : given non-null string a trace of the search will be appended.
  This allows higher level API's to capture detailed diagnostics
  when the search fails. This is useful for all parties.

The return value is:

  *  a string containing the path to the objects preferred form, or NULL if not 
found.

  * localized with parrot_platform_path_localize

  *  all path seperators are coverted to the platform's value (ie Win32)

  *  a hidden 0 char is appended making it suitable for direct use in C API 
calls,
 an artifact of the previous implementation.

Search behavior:

code objects can have several formats, some of which will be stored on
disk. This routine searches for the preferred format of an object.
Preferred is either lowest form (compiled), or highest form (source).

The given search rules apply at each step in the search order. The
search order is executed per loader. The loader mask is also traversed
in preferred the order.

rule 1: parrot will always try the object_name as given before adding
extensions. The set of extensions tried is loader specific.

Search order:

 1. Absolute paths (return or fail)

 2. Search the paths joined with get_runtime_prefix

 3. joined with get_runtime_prefix

 4. as given

 Exception 1. absolute paths in the path list are not prefixed

 Exception 2. If the loader mask is zero: step two of the search order
  will be skipped. extensions are skipped since there
  is no loader information available.

The two modals for the search are the runtime_prefix and preferred
order.

SEE ALSO: Parrot_get_runtime_prefix, query_load_prefer , 
Finclude/parrot/library.h

current parrot behavior can be achieved by passing NULL as the hll
argument, and a loader mask of:

  PARROT_RUNTIME_FT_BYTECODE 
  PARROT_RUNTIME_FT_INCLUDE 
  PARROT_RUNTIME_FT_SOURCE

for parrot bytecode, and PARROT_RUNTIME_FT_ARCH for platform shared
objects.

Implementation Notes:

The implementation of the search behavior is tagged in this file.
rules:  grep search-rule x
search order :  grep search-order x
search exception :  grep search-rule x

The search lists for both paths and extensions are dynamic arrays. In
the extension search space it is assumed that the lowest index
corresponds to the lowest form, and that the array is sorted
accordingly.

TODO: the extension , which is actually the stage of interpretation contained
  by the format is returned in the extension of the file. This should be
  returned as a optimization hint to heuristics that do the real
  determination of what's in a file , ( example: use v6; or shebang 
invocations )

TODO: instead of a string that is checked by stat() , a handle should be
  returned instead to close the classic access() race. Additional
  flags are needed for that such as NO_TTY and other basic cross-platform
  security open() masks. -- huge warning.

  (This should be relative to a loader , higher level forms may
   have looser security constraints)

TODO: OS IO/VM hinting. some loaders could benefit from IO hinting such as
  mapped/streamed, use-once etc. depends on returning a handle and open
  flags.


=cut

*/

 
 Cheers,
 Mike Mattie - [EMAIL PROTECTED]
 
 
 
 


signature.asc
Description: PGP signature


Re: [perl #42919] [BUG] and [PATCH] overriding 'invoke' requires current object to be explicitly passed

2007-05-15 Thread Mehmet Yavuz Selim Soyturk

On 5/15/07, Alek Storm [EMAIL PROTECTED] wrote:

On 5/14/07, Mehmet Yavuz Selim Soyturk [EMAIL PROTECTED] 
wrote:
 Should we not be able to use an object that implements 'invoke' as a
 method of another object? There is some strange behaviour when I try
 to.

I see what you're saying, and it looks like you want a functor.  We can't do
exactly what you want in that syntax, because methods are loosely tied to
objects in Parrot.  Parrot sees 'Func' as a sub, so it wouldn't make any
sense to tell the sub it's called by itself.  Regardless of what
'find_method' returns, the invocant is $P2 when you use PIR syntax.  Here's
how to get the effect you want:

.sub main :main
  $P0 = newclass 'Func'
  $P1 = newclass 'Obj'
  $P2 = new 'Obj'
  $P3 = find_method $P2, 'some_method'
  $P3.$P3()
.end

The patch has been reverted, though, so that won't work until it's fixed and
reapplied.


What I really meant is $P2.$P3() . With Allison's patch both

  (*)   $P2.'some_method'()
and
  (**)  $P3 = find_method $P2, 'some_method'
$P2.$P3()

caused the same strange behaviour. I applied your patch, and (**)
worked as I expected. But (*) caused an error:

   too many arguments passed (3) - 2 params expected


I think that I found the problem. callmethodcc calls
VTABLE_find_method, which invokes the find_method override, which is a
PIR sub. That causes that interp-current_args gets overwritten.

I have a patch which tries to solve that problem:

--- src/ops/object.ops  (revision 18542)
+++ src/ops/object.ops  (working copy)
@@ -50,11 +50,20 @@
  PMC *method_pmc, *object;
  opcode_t *next;
  STRING *meth;
+  opcode_t *current_args;

  object = $1;
  meth = $2;
  next = expr NEXT();
+
+  /* If VTABLE_find_method calls a find_method override (which
+ is another PIR sub), interp-current_args gets overwritten.
+ We have to remember it.
+  */
+  current_args = interp-current_args;
  method_pmc = VTABLE_find_method(interp, object, meth);
+  interp-current_args = current_args;
+
  if (!method_pmc) {
real_exception(interp, next, METH_NOT_FOUND,
Method '%Ss' not found, meth);


I only did it for the callmethodcc_p_sc opcode though, because I don't
know if it's the right solution. A possible problem: could
current_args get GC'd in the meantime?

--
Mehmet


[perl #42964] Parrot 0.4.13 Release

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


This ticket is a placeholder for the 0.4.13 release on 19 June 2007.


Re: [RFC] extension guessing, functionally better loader behavior - working install target

2007-05-15 Thread Mike Mattie
On Sun, 13 May 2007 22:46:15 -0700
Mike Mattie [EMAIL PROTECTED] wrote:

 Hello,
 

I figured anyone who actually makes it from top to bottom of the RFC might want 
to see what it
looks like in C code. Since I will be gone for a bit I am attaching my 
in-progress copy of
src/library.c . It is not even compiling AFAIK , but it is fairly close, and 
has the design
fully sketched out.

I am also attaching foo.pl. It is a hack in the derogatory sense of the word, 
but if anyone
wants to play with the ideas in the RFC it will help. I use it to generate 
builtin-library-paths.c

library.paths is the input file for foo.pl

happy parrot hacking,

 Cheers,
 Mike Mattie - [EMAIL PROTECTED]
 
 
 
 
/*
Copyright (C) 2004-2007, The Perl Foundation.
$Id: library.c 18482 2007-05-09 11:16:10Z paultcochrane $

=head1 NAME

src/library.c - Interface to Parrot's bytecode library

=head1 DESCRIPTION

This file contains a C function to access parrot's bytecode library functions.

=head2 Functions

=over 4

=cut

*/

#include stdarg.h

#include parrot/parrot.h
#include parrot/library.h

#include library.str


/* used internally by diagnostics , ASCII text string names for the loader.
 * TODO: internationalization. */
static const char* const loader_names[] = {
'ARCH',
'BYTECODE',
'INCLUDE',
'SRC'
};

/* create a loader table , indexed by the three loader paths enumerated
 * by enum_runtime_ft in parrot/include/library.h. Each namespace has
 * a path/extension search table for a shared object loader, a byte-code
 * loader, and a source-code loader.
 *
 * for a shared object loader this is a little wastefull, but the tables
 * are not duplicated. If a namespace does not define a path/extension
 * search table, the parrot table will be used. */

static PMC*
create_loader_table(Interp* interp)
{
PMC *table;

table = pmc_new(interp, enum_class_FixedPMCArray);
VTABLE_set_integer_native(interp, table,
  PARROT_RUNTIME_FT_SIZE );

return table;
}

/* return an existing load-table , or create one and attach it
 * to the namespace. */
static PMC*
get_load_table_for_populate(Interp* interp,
PMC* lib_paths, STRING* ns)
{
PMC *table;

if ( VTABLE_exists_keyed_str(interp, lib_paths, ns) )
return VTABLE_get_pmc_keyed_str(interp, lib_paths, ns );

table = create_loader_table(interp);

VTABLE_set_pmc_keyed_str(interp, lib_paths,
 ns,
 table);
return table;
}

/* create a search space. Loaders will want to iterate through a
 * path space, and an extension space. These are enumerated
 * in enum_search_space. */

typedef enum {
SEARCH_TABLE_PATH = 0,
SEARCH_TABLE_EXT,
SEARCH_TABLE_SIZE
} enum_search_space;

static PMC*
create_search_table(Interp* interp)
{
PMC *table;

table = pmc_new(interp, enum_class_FixedPMCArray);
VTABLE_set_integer_native(interp, table, SEARCH_TABLE_SIZE);

return table;
}

static PMC*
get_search_table_for_populate(Interp* interp,
  PMC* load_table, int loader )
{
PMC *table;

if ( VTABLE_exists_keyed_int( interp, load_table, loader ) )
return VTABLE_get_pmc_keyed_int(interp, load_table, loader );

table = create_search_table(interp);
VTABLE_set_pmc_keyed_int(interp, load_table,
 loader,
 table);

return table;
}

/* A search space is a simple dynamic array, or list of
 * name varaiations (path or extension) to try. */

static PMC*
create_search_space(Interp* interp) {
return pmc_new(interp, enum_class_ResizableStringArray);
}

static PMC*
get_search_space_for_populate(Interp* interp,
  PMC* search_table , enum_search_space search_space)
{
PMC *new_table;

if ( VTABLE_exists_keyed_int( interp, search_table , search_space ) )
return VTABLE_get_pmc_keyed_int(interp, search_table, search_space );

new_table = create_search_space(interp);
VTABLE_set_pmc_keyed_int(interp,
 search_table, search_space , new_table );

return new_table;
}

static void
populate_search_space(Interp* interp,
  /* the loader table for the namespace */
  PMC* load_table,
  enum_runtime_ft loader,

  /* search space index */
  enum_search_space search_space,

  /* the entry to add */
  STRING* entry)
{
PMC *search_table, *search_list;

search_list = get_search_space_for_populate(interp,
get_search_table_for_populate(interp,
  load_table,loader),
search_space);

VTABLE_push_string(interp, search_list, entry);
}

/* load_prefer is a toggle to 

Parrot 0.4.12 Of the Caribbean Released

2007-05-15 Thread chromatic
As I sailed into Shadow, a white bird of my desire came and sat upon my
right shoulder, and I wrote a note and tied it to its leg and sent it on
its way.  The note said, I am coming, and it was signed by me.

...

The sun hung low on my left and the winds bellied the sails and propelled
me onward.  I cursed once and then laughed.

I was free and I was running, but I had made it this far.  I now had the
chance I'd wanted all along.

A black bird of my desire came and sat on my left shoulder, and I wrote a
note and tied it to its leg and sent it off into the west.

It said, Eric--I'll be back, and it was signed: Corwin, Lord of Amber.

A demon wind propelled me east of the sun.

-- Nine Princes in Amber, Roger Zelazny

On behalf of the Parrot team, I'm proud to announce Parrot 0.4.12 Of the
Caribbean. Parrot (http://parrotcode.org/) is a virtual machine aimed at
running all dynamic languages.

Parrot 0.4.12 can be obtained via CPAN (soon), or follow the
download instructions at http://parrotcode.org/source.html.
For those who would like to develop on Parrot, or help develop
Parrot itself, we recommend using Subversion or SVK on the
source code repository to get the latest and best Parrot code.

The next release will take place on 19 June 2007.

Parrot 0.4.12 News:
- Build:
 + even more refactorings and improvements in configuration system
 + improved tests and documentation for configuration system
- Languages:
 + Updated abc, PHP (Plumhead), Lua, Tcl
 + Reclaimed Lisp
- Design:
 + new PMC PDD draft partially completed
- Implementation:
 + continued implementation of PDD 15 (Objects)
 + minor garbage collector and memory management improvements
 + several memory leaks resolved
 + extended support for compilers other than GCC
 + improved C++ compiler compatibility
 + enhanced support for Solaris, non-MSVC Win32, and other platforms

Thanks to all our contributors for making this possible, and our
sponsors for supporting this project.

Enjoy!


Re: [RFC] extension guessing, functionally better loader behavior - working install target

2007-05-15 Thread Mike Mattie
On Sun, 13 May 2007 22:46:15 -0700
Mike Mattie [EMAIL PROTECTED] wrote:

 Hello,
 

I figured anyone who actually makes it from top to bottom of the RFC might want 
to see what it
looks like in C code. Since I will be gone for a bit I am attaching my 
in-progress copy of
src/library.c . It is not even compiling AFAIK , but it is fairly close, and 
has the design
fully sketched out.

I am also attaching gen-paths. It is a hack in the derogatory sense of the 
word, but if anyone
wants to play with the ideas in the RFC it will help. I use it to generate 
builtin-library-paths.c

library.paths is the input file for gen-paths

happy parrot hacking,

 Cheers,
 Mike Mattie - [EMAIL PROTECTED]
 
 
 
 
/*
Copyright (C) 2004-2007, The Perl Foundation.
$Id: library.c 18482 2007-05-09 11:16:10Z paultcochrane $

=head1 NAME

src/library.c - Interface to Parrot's bytecode library

=head1 DESCRIPTION

This file contains a C function to access parrot's bytecode library functions.

=head2 Functions

=over 4

=cut

*/

#include stdarg.h

#include parrot/parrot.h
#include parrot/library.h

#include library.str


/* used internally by diagnostics , ASCII text string names for the loader.
 * TODO: internationalization. */
static const char* const loader_names[] = {
'ARCH',
'BYTECODE',
'INCLUDE',
'SRC'
};

/* create a loader table , indexed by the three loader paths enumerated
 * by enum_runtime_ft in parrot/include/library.h. Each namespace has
 * a path/extension search table for a shared object loader, a byte-code
 * loader, and a source-code loader.
 *
 * for a shared object loader this is a little wastefull, but the tables
 * are not duplicated. If a namespace does not define a path/extension
 * search table, the parrot table will be used. */

static PMC*
create_loader_table(Interp* interp)
{
PMC *table;

table = pmc_new(interp, enum_class_FixedPMCArray);
VTABLE_set_integer_native(interp, table,
  PARROT_RUNTIME_FT_SIZE );

return table;
}

/* return an existing load-table , or create one and attach it
 * to the namespace. */
static PMC*
get_load_table_for_populate(Interp* interp,
PMC* lib_paths, STRING* ns)
{
PMC *table;

if ( VTABLE_exists_keyed_str(interp, lib_paths, ns) )
return VTABLE_get_pmc_keyed_str(interp, lib_paths, ns );

table = create_loader_table(interp);

VTABLE_set_pmc_keyed_str(interp, lib_paths,
 ns,
 table);
return table;
}

/* create a search space. Loaders will want to iterate through a
 * path space, and an extension space. These are enumerated
 * in enum_search_space. */

typedef enum {
SEARCH_TABLE_PATH = 0,
SEARCH_TABLE_EXT,
SEARCH_TABLE_SIZE
} enum_search_space;

static PMC*
create_search_table(Interp* interp)
{
PMC *table;

table = pmc_new(interp, enum_class_FixedPMCArray);
VTABLE_set_integer_native(interp, table, SEARCH_TABLE_SIZE);

return table;
}

static PMC*
get_search_table_for_populate(Interp* interp,
  PMC* load_table, int loader )
{
PMC *table;

if ( VTABLE_exists_keyed_int( interp, load_table, loader ) )
return VTABLE_get_pmc_keyed_int(interp, load_table, loader );

table = create_search_table(interp);
VTABLE_set_pmc_keyed_int(interp, load_table,
 loader,
 table);

return table;
}

/* A search space is a simple dynamic array, or list of
 * name varaiations (path or extension) to try. */

static PMC*
create_search_space(Interp* interp) {
return pmc_new(interp, enum_class_ResizableStringArray);
}

static PMC*
get_search_space_for_populate(Interp* interp,
  PMC* search_table , enum_search_space search_space)
{
PMC *new_table;

if ( VTABLE_exists_keyed_int( interp, search_table , search_space ) )
return VTABLE_get_pmc_keyed_int(interp, search_table, search_space );

new_table = create_search_space(interp);
VTABLE_set_pmc_keyed_int(interp,
 search_table, search_space , new_table );

return new_table;
}

static void
populate_search_space(Interp* interp,
  /* the loader table for the namespace */
  PMC* load_table,
  enum_runtime_ft loader,

  /* search space index */
  enum_search_space search_space,

  /* the entry to add */
  STRING* entry)
{
PMC *search_table, *search_list;

search_list = get_search_space_for_populate(interp,
get_search_table_for_populate(interp,
  load_table,loader),
search_space);

VTABLE_push_string(interp, search_list, entry);
}

/* load_prefer is a toggle