Re: [perl #53976] [PATCH] Remove tools/dev/ops_renum.mak

2008-08-10 Thread jerry gay
On Sat, Aug 9, 2008 at 3:50 PM, James Keenan via RT
<[EMAIL PROTECTED]> wrote:
> On Sat Aug 09 10:31:37 2008, [EMAIL PROTECTED] wrote:
>> On Saturday 09 August 2008 06:33:46 James Keenan via RT wrote:
>>
>> > > What purpose remains, then, for either tools/dev/ops_renum.mak or
>> my
>> > > alternative, tools/dev/opsrenumber.pl?  Is such a program only
>> intended
>> > > to provide a number for newly added opcodes?
>>
>>
>>
>> Hm, I missed the question the first time.  The program renumbers
>> opcodes when
>> adding or removing one or more opcodes.  (Removing is less likely as
>> time
>> goes by, but we reserve the right to do so for the forseeable future.)
>>
>
> Hmm ... it appears to me that particle took a harder line earlier in
> this RT against removal:  "in an attempt to keep bytecode compatible
> across versions of parrot, opcodes can never be deleted."
>
> Do we have a disagreement there?  If not, I'd like to know whether my
> replacement script DTRT or needs fixing ('cause I'm more confused than
> when i started).
>
let me clarify: after 1.0, in order to allow bytecode to be work
across parrot releases (where there may be new or deprecated opcodes),
opcode numbers can never be reused. before parrot is production ready
(before 1.0) we have not made any promise of bytecode compatibility
across releases, other than that it'd be great if we can do it (which
means we can reuse opcode numbers if we want to, but i still find it
unlikely as it's counter-cultural.

i don't see any disagreement between myself and chromatic.
~jerry


[perl #57766] Unfruitful interaction between regexp smartmatch and statement-modifying 'while'

2008-08-10 Thread Carl Mäsak
# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #57766]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=57766 >


r30155:
$ ./perl6 -e '"a" ~~ /b/' # works
$  ./perl6 -e 'while "a" ~~ /b/ {}' # works
$ ./perl6 -e '1 while "a" ~~ "b"' # works
$ ./perl6 -e '1 if "a" ~~ /b/' # works

$ ./perl6 -e '1 while "a" ~~ /b/' # strange error
Lexical '$/' not found
[...]


[perl #57768] Negative-smartmatching on a regexp produces a Null PMC access in rakudo

2008-08-10 Thread Carl Mäsak
# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #57768]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=57768 >


r30155:
$ ./perl6 -e '"o" ~~ /o/' # works

$ ./perl6 -e '"o" !~~ /o/' # fails
Null PMC access in set_pmc_keyed()

I added two tests in t/operators/smartmatch.t to exercise the correct behaviour.


Re: [perl #57756] Implementation of .subst for strings in rakudo

2008-08-10 Thread Carl Mäsak
Patrick (>):
> 1.  I suspect this method really belongs in src/builtins/any-str.pir
>instead of the C class, so that we can do replacements on
>the stringification of any invocant (not just C objects).
>
> 2.  The :multi() is likely incorrect, even as a method of C.
>Any object should be usable as a pattern/replacement, not just
>C objects.  For example, I think that these ought to
>be equivalent:
>
>   $foo.subst('3', '4')
>   $foo.subst(<3>, <4>)
>   $foo.subst(3, 4)
>
>I.e., the caller shouldn't have to be concerned about coercing
>the parameters to C objects in order to invoke the builtin
>C method.

I agree. I also like the new, more flexible behaviour much better:

$ ./perl6 -e 'say (2 ** 5).subst(/3/, 4)'
42

New patch attached.


subst-any.patch
Description: Binary data


[perl #57764] docs/art/ppp02-pmc.pod -- example 9 segfault

2008-08-10 Thread Pavlo Korzhyk
# New Ticket Created by  "Pavlo Korzhyk" 
# Please include the string:  [perl #57764]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=57764 >


To reproduce simply copy-paste example 9 from docs/art/ppp02-pmc.pod
and run it:

==
.include "timer.pasm"   # for the timer constants

.sub expired
   print "Timer has expired!\n"
.end

.sub _ :main
   $P0 = new 'Timer'
   $P1 = global "expired"

   $P0[.PARROT_TIMER_HANDLER] = $P1# call sub in $P1 when timer goes off
   $P0[.PARROT_TIMER_SEC] = 2  # trigger every 2 seconds
   $P0[.PARROT_TIMER_REPEAT] = -1  # repeat indefinitely
   $P0[.PARROT_TIMER_RUNNING] = 1  # start timer immediately
   global "timer" = $P0# keep the timer around

   $I0 = 0
  loop:
   print $I0
   print ": running...\n"
   inc $I0
   sleep 1 # wait a second
   goto loop
.end
==

The output under Ubuntu is:
(0.6.4 on Ubuntu and WinXP, 0.6.3 on Ubuntu produce the similar bad result)
==
0: running...
1: running...
maximum recursion depth exceeded
current instr.: 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
... repeated approx 2000 times ...
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub 'expired' pc 0 (timertest.pir:4)
called from Sub '_' pc 41 (timertest.pir:22)
Segmentation fault
==

If "-1"(indefinitely) is replaced with "5" - you'll get 6 messages
"Timer has expired!"
all at once:
==
0: running...
1: running...
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
Timer has expired!
2: running...
3: running...
4: running...
5: running...
(pressed Ctrl+C here)
==

For N repeats you will get N+1 executions of the handler.


[perl #57770] Empty regexp gives unhelpful error message in rakudo

2008-08-10 Thread Carl Mäsak
# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #57770]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=57770 >


r30155:
$ ./perl6 -e '//'
Syntax error at line 1, near "//"

Could be something nicer, in line with "The empty pattern is now
illegal." from S05.


Re: [perl #57770] Empty regexp gives unhelpful error message in rakudo

2008-08-10 Thread Brandon S. Allbery KF8NH


On 2008 Aug 10, at 9:40, Carl MXXsak (via RT) wrote:


r30155:
$ ./perl6 -e '//'
Syntax error at line 1, near "//"

Could be something nicer, in line with "The empty pattern is now
illegal." from S05.



But can that really be easily distinguished from the C operator?

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH




Re: [perl #57770] Empty regexp gives unhelpful error message in rakudo

2008-08-10 Thread Carl Mäsak
Brandon (>), Carl (>>):
>> $ ./perl6 -e '//'
>> Syntax error at line 1, near "//"
>>
>> Could be something nicer, in line with "The empty pattern is now
>> illegal." from S05.
>
> But can that really be easily distinguished from the C operator?

Yes, I believe so. The C operator never occurs where a term is
expected (it being binary), and a regexp term never occurs where a
binary operator is expected.

// Carl


Re: [perl #57770] Empty regexp gives unhelpful error message in rakudo

2008-08-10 Thread Patrick R. Michaud
On Sun, Aug 10, 2008 at 06:40:12AM -0700, Carl Mäsak wrote:
> # New Ticket Created by  "Carl Mäsak" 
> # Please include the string:  [perl #57770]
> # in the subject line of all future correspondence about this issue. 
> # http://rt.perl.org/rt3/Ticket/Display.html?id=57770 >
> 
> 
> r30155:
> $ ./perl6 -e '//'
> Syntax error at line 1, near "//"
> 
> Could be something nicer, in line with "The empty pattern is now
> illegal." from S05.

It would be worthwhile to do whatever STD.pm would generate on
this input.  I don't have STD.pm running on any of my machines
at the moment to be able to check.  But whatever STD.pm generates
for this case, we should match if we can.

Thanks,

Pm


Re: [perl #57770] Empty regexp gives unhelpful error message in rakudo

2008-08-10 Thread Ryan Richter
On Sun, Aug 10, 2008 at 10:51:39AM -0500, Patrick R. Michaud wrote:
> On Sun, Aug 10, 2008 at 06:40:12AM -0700, Carl Mäsak wrote:
> > r30155:
> > $ ./perl6 -e '//'
> > Syntax error at line 1, near "//"
> > 
> > Could be something nicer, in line with "The empty pattern is now
> > illegal." from S05.
> 
> It would be worthwhile to do whatever STD.pm would generate on
> this input.  I don't have STD.pm running on any of my machines
> at the moment to be able to check.  But whatever STD.pm generates
> for this case, we should match if we can.

Can't understand next input--giving up at /tmp/x line 1:
--> //
expecting ws (alt 03)

(the first / is highlighted in green and the second in red)

-ryan


Re: [perl #57768] Negative-smartmatching on a regexp produces a Null PMC access in rakudo

2008-08-10 Thread jerry gay
On Sun, Aug 10, 2008 at 6:38 AM, via RT Carl Mäsak
<[EMAIL PROTECTED]> wrote:
> I added two tests in t/operators/smartmatch.t to exercise the correct 
> behaviour.
>
thanks for the tests, but remember rakudo won't run these until
they're moved to t/spec/.
~jerry


Re: Differential Subscripts

2008-08-10 Thread TSa (Thomas Sandlaß)
On Saturday, 9. August 2008 04:41:46 John M. Dlugosz wrote:
> Is this magic known to the parser at a low level, or is it possible to
> define your own postcircumfix operators that interact with the
> interpretation of the argument?

My interpretation is that there is a Whatever type that
most of the time behaves like Int. So to handle it, you
define postcircumfix:<[ ]>:(Whatever $slice) or so. The
interesting question is what plain * returns because that
is destined to mean the full slice. IMHO, this should be
written ^*, which if the array becomes known becomes
[EMAIL PROTECTED]


> Is it possible to write:
>   @i = (1, 3, *-1);
>   say @data[$i];
> and get the same meaning as
>   say @data[1, 3, *-1]?

I hope so. The type of the slice is Seq[Int,Int,Whatever].


Regards, TSa.
-- 
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Re: Some details of function return captures

2008-08-10 Thread TSa (Thomas Sandlaß)
HaloO,

On Saturday, 9. August 2008 01:32:35 John M. Dlugosz wrote:
> TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:
> > If such a ReturnCapture could also be
> > preliminary of some kind, then lvalue subs could be lazily resumed when
> > the rvalue comes in.
>
> Can you elaborate on that?  I don't follow.

The fundamental problem with lvalue methods is that some
of them want to have control *after* they returned
their value. One ugly way to achieve this is how it is
usually done in C++ or Java: the rvalue is a parameter
of the method. So instead of

$obj.foo(1,2) = 3; #1

one writes

$obj.foo(1,2,3); #2

which doesn't look like an lvalue method at all. And you can't
use it in rvalue context as the former:

my $x = $obj.foo(1,2); #3

Here the ReturnCapture collapses right away. But in #1 it could
be resumed with rvalue 3. That is the invocation of .foo(1,2)
resumes after the statement that produced the ReturnCapture.
In the assignable mutators thread I proposed to call that
statement 'yield'. To the function it behaves like the declaration
of a variable that receives the value that is assigned later.
To the outside it is the preliminary rvalue. If no assignment
takes place no resumption is made. The new thing here is that
one needs to write

my $x = |$obj.foo(1,2); #4

to keep the ReturnCapture, and call it later either explicitly

$x.resume(3);

or implicitly

$x = 3;


Hope that helps, TSa.
-- 
"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan


Re: YAPC::EU 2008

2008-08-10 Thread Nuno 'smash' Carvalho
On Sat, Aug 2, 2008 at 10:17 PM, Ron Blaschke <[EMAIL PROTECTED]> wrote:
> Bernhard Schmalhofer wrote:
>>
>> Jonathan Worthington schrieb:
>>>
>>> Allison Randal wrote:

 Bernhard Schmalhofer wrote:
>>
>> We could always do the 12th AND the 16th, just for fun and bonus
>> productivity (if everyone isn't exhausted from a day of hacking and three
>> days of conference)? ;-)
>>>
>>> Patrick and I will be hacking on the 12th and the 16th. If you've not
>>> seen Copenhagen before, I could forgive you for wanting to spend a day
>>> enjoying the city rather than hacking though - it's nice! :-)
>>>
>> Hi,
>>
>> I've also booked flight and hotel for August 11th to 17th. So I will be
>> around on the 12th and the 16th.
>
> I'll be there 11th to 17th as well.

I'll be arriving on the 12th and leaving on the 17th, but you can
count me in for some hacking.

./smash


Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread John M. Dlugosz

E.g. see  :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print "Haha!\n";
}


Re: Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread Austin Hastings
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


=Austin

John M. Dlugosz wrote:

E.g. see  :

sub bar {
return 100;
}
sub foo { 50;}
sub foo-bar {
  return  rand(50);
  }
if (foo - bar != foo-bar) {
  print "Haha!\n";
}





Re: Some details of function return captures

2008-08-10 Thread John M. Dlugosz

TSa (Thomas Sandlaß) thomas-at-sandlass.de |Perl 6| wrote:

...
my $x = |$obj.foo(1,2); #4

to keep the ReturnCapture, and call it later either explicitly

$x.resume(3);

or implicitly

$x = 3;


Hope that helps, TSa.
  


Interesting idea, as an alternative to get/set methods like Microsoft 
languages.  Do you have a pointer to the thread, or collected notes I 
could read?


Is there anything in Perl 6 as it stands now that really uses 
continuations like this?


I don't like the default lvalue subs as the exist now because I might 
want to do more than assign to the value located with the access.  Even 
if that's fine now, how do I add an "clear_cache; tell_subscribers;" 
after the value is changed?  It means adding the ugly C++ form and then 
changing all existing uses. 

But, I realized that the ability to return a tied scalar as a proxy 
object gives us this.  You can specify an accessor that returns an 
object that has the getter/setter installed in the FETCH/STORE 
routines.  A class can be written for the purpose, that takes blocks 
(anonomous methods) in the constructor, and a macro gives reasonable 
syntactic sugar for writing separate get/set methods right by the attribute.


I'm not sure about returning things other than a scalar.

But the point is, since it _can_ be done in a module, I'm punting on 
that and not lobbying for it for 6.0 when there is so much else that 
needs doing.


--John



Re: Allowing '-' in identifiers: what's the motivation?

2008-08-10 Thread John M. Dlugosz

Austin Hastings Austin_Hastings-at-Yahoo.com |Perl 6| wrote:
At a minimum, there are more multi-word identifiers than there are 
statements involving subtraction. Further, '-' is basic, while all of 
[_A-Z] are not.


Ergo, a multi-word-identifier is easier to type than a 
multi_word_identifier or a multiWordIdentifier.


The older I get, the more I like Cobol, and now *ML, for getting this 
stuff right.


I do agree that it may be better for multi-word identifiers than camel 
case or underscores, as seen in many other languages that the great 
unwashed masses have never heard of.  I tried it in my writings the same 
day.


--John


Class attribute declaration question : our $!var

2008-08-10 Thread John M. Dlugosz

our $.var — class attribute, accessor, inheritable.
our $!var — class attribute, no accessor, inheritable.



If the second form has no accessor, how can it be inheritable?


class member declaration catalog

2008-08-10 Thread John M. Dlugosz
I just put together  as 
part of my analysis and documentation effort.  I'll link the "meanings" to more 
extensive treatments.


Did I miss any *possible* combination?

--John