Re: hotplug regexes, other misc regex questions

2002-09-19 Thread Damian Conway

Josh Jore wrote:

Would it be correct for this to print 0? Would it be correct for this
to print 2?

  my $n = 0;
  aargh =~ /a* { $n++ } aargh/;
  print $n;

Yes. ;-)
 
 Wouldn't that print 2 if $n is lexical 

Err. It *is* lexical in this example.

 and 0 if it's localized? 

No. Without the Cmy it would still print either 0 or 2, depending
on the implementation/optimization.


  Or are lexicals localized now?

They can be. But this example C$n isn't.
(Just because it's used in a nested closure doesn't mean it's
localized within the pattern).


What possible outputs are legal for this:

  aaa =~ /( a { print 1 } | a { print 2 })* { print \n } x/

 
 I take it that what I've learned from _Mastering_Regular_Expressions_
 doesn't quite apply here?  From that interpretation I'd think it'd print
 111\n since the second part of the alternation wouldn't be tried.

No. It would fail to match the final Cx in the pattern and start
backtracking.

Damian




RE: Hyperoperators and dimensional extension

2002-09-19 Thread Brent Dax

Dan Sugalski:
# Sort of, yes.
# 
# Basically the behaviour of hyper-operated operators is delegated via 
^
Spending time in England lately?  ;^)

# multimethod dispatch to the hyper-operator functions. By default the 

Well, yeah.  But that doesn't really answer my question.  :^)  What's
the *language-level* behavior?

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
--Albert Einstein (explaining radio)




RE: Hyperoperators and dimensional extension

2002-09-19 Thread Dan Sugalski

At 8:27 AM -0700 9/19/02, Brent Dax wrote:
Dan Sugalski:
# Sort of, yes.
#
# Basically the behaviour of hyper-operated operators is delegated via
 ^
Spending time in England lately?  ;^)

Why, yes, actually. :-P But I've been using Pompous English Spelling for years.

# multimethod dispatch to the hyper-operator functions. By default the

Well, yeah.  But that doesn't really answer my question.  :^)  What's
the *language-level* behavior?

Well, it does, though. Saying it's delegated to the variables and 
they have a default behavior's different than saying this is the 
behaviour.
-- 
 Dan

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



Re: Perl 6 Summary for week ending 2002-09-15

2002-09-19 Thread Kay Röpke


On Wednesday, Sep 18, 2002, at 17:42 Europe/Berlin, Piers Cawley wrote:

 IMCC / Mac OS X problem
 Leon Brocard (yay! Still batting 100% on this one...) has been 
 having
 problems building IMCC under Mac OS X. The individual .c files all
 compile, but bad things happen at link time. Leo, Kevin Falcone, 
 and
 Andy Dougherty all pitched in and, after a flurry of patches, IMCC 
 is
 now building and working correctly under Mac OS X.

 http://makeashorterlink.com/?R591215D1


Have those patches committed, yet? I tried last night (instead of 
sleeping...;-)) but failed utterly.


Regards,

Kay




Re: hotplug regexes, other misc regex questions

2002-09-19 Thread Josh Jore

On Wed, 18 Sep 2002, Luke Palmer wrote:
 On Wed, 18 Sep 2002, Josh Jore wrote:
  On Wed, 18 Sep 2002, Damian Conway wrote:
What possible outputs are legal for this:
   
  aaa =~ /( a { print 1 } | a { print 2 })* { print \n } x/
 
  I take it that what I've learned from _Mastering_Regular_Expressions_
  doesn't quite apply here? From that interpretation I'd think it'd print
  111\n since the second part of the alternation wouldn't be tried.

 The first time through, yes.  But then it tries to match the x, and says
 oops, that's not what I have and backtracks.  That tries the second of
 the alternation, which doesn't work either.  So it backtracks so the * is
 only getting two of the first one, et cetera...

 Or are you talking about something else from Mastering Regular
 Expressions?  Like some kind of optimization that happens?

I missed the trailing 'x/' since my perl5 eyes read that as '/x'. My bad.

Joshua b. Jore -{ weird geeky madness }- http://www.greentechnologist.org





Re: Perl 6 Summary for week ending 2002-09-15

2002-09-19 Thread Leopold Toetsch

Kay Röpke wrote:

 
 On Wednesday, Sep 18, 2002, at 17:42 Europe/Berlin, Piers Cawley wrote:
 
 IMCC / Mac OS X problem

 Have those patches committed, yet? I tried last night (instead of 
 sleeping...;-)) but failed utterly.


No, sorry. I'm still waiting for my imcc 0.0.9 patch to be checked in, 
where these fixes are included. If urgent you could follow the mentioned 
thread. There were all the pieces to get it running.


 Regards,
 
 Kay


leo







Re: Passing arguments

2002-09-19 Thread Aaron Sherman

On Sat, 2002-09-14 at 04:16, Luke Palmer wrote:

 When a bare closure is defined, it behaves the same as a signatureless 
 sub. That is, it topicalizes the first argument, and hands them all over 
 in @_.  So your topic passing is just, well, passing the topic, like 
 any ol' argument.

Ok, thanks. I was getting lost in the noise there, but this finally
makes sense.

Just to make 100% sure though, let me get these definitions clear:

topicalize: To default to C$_ in a prototype (thus acquiring the
caller's current topic).

signatureless sub: A sub that does not specify a prototype, and thus has
a default prototype of:

sub($_//=$_){};

ne?

-- 
Aaron Sherman [EMAIL PROTECTED]
http://www.ajs.com/~ajs




RE: Passing arguments

2002-09-19 Thread Brent Dax

Aaron Sherman:
# topicalize: To default to C$_ in a prototype (thus 
# acquiring the caller's current topic).

Well, to topicalize a region of code is actually to specify a different
topic, that is, a different value for $_.  For example:

$foo = new X;
$bar = new Y;

given $foo {
print $_.type, \n;#prints X

given $bar {
#XXX we're using 'given' for this too, right?
print $_.type, \n;#prints Y
}
}

(An aside: it strikes me that you could use Cgiven as a scoped lexical
alias, i.e.

my $foo=foo;
my $bar=bar;

print $foo;

given $bar - $foo {
print $foo;
}

print $foo;

#prints foobarfoo

Hmm...)

# signatureless sub: A sub that does not specify a prototype, 
# and thus has a default prototype of:
# 
#   sub($_//=$_){};
# 
# ne?

More like:

a sub that was created with the arrow (-) or a bare block and 
does not specify a prototype, and thus has a default prototype
of:

- ($_ //= $OUTER::_) { };

Or some such.  (Maybe C$_ //= $_ will work, but I have reservations
about that--especially about the possibility of that picking up $_
dynamically instead of lexically.  In some cases you want $_
dynamically, in others lexically.  Perhaps C$_ is topic('lexical') and
C$_ is topic('dynamic')?)

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
--Albert Einstein (explaining radio)





Re: Perl 6 Summary for week ending 2002-09-15

2002-09-19 Thread Leopold Toetsch

Piers Cawley wrote:

 
 Happy birthday to me!


Congratulations.

 ... by my turning 35 on the 15th 


44 on 16th - yes Sept.

and thanks for the kudos,
leo







Regex query

2002-09-19 Thread Simon Cozens


Well, I've started my Perl 6 programming career already and I've got
stuck. :)

I'm trying to parse a Linux RAID table (/etc/raidtab), which looks a
bit like this:

raiddev /dev/md0
raid-level  5
option  value
option  value
...

device  /dev/sde1
raid-disk   0
device  /dev/sdf1
raid-disk   1
device  /dev/sdg1
raid-disk   2
...

raiddev /dev/md1
...

Here's the grammar I have so far:

grammar Raidtab;

rule raidtab { raiddev+ };
rule comment { sp* \# .* |
   # Or a blank line
   ^^ \n };

rule comm_eol { sp* comment? sp* \n };

rule raiddev { comment*
   sp* raiddev sp+ $name := (/dev/md\d+) comm_eol
(devicelayout | option | comment)+ };

rule option  { sp* $key := ([a-z]-+) sp* $value := (\w+) comm_eol };

rule devicelayout { sp* device sp+ $name := (/dev/\w+) comm_eol
sp* $type := (raid|spare|parity) -disk sp*
$index := (\d+) comm_eol
  };

What I can't figure out is how to drill down into the returned match
object and get at individual devices. I'd expect to be able to say
something like

$matchobject{raiddev}[0]{devicelayout}[1]{name}

and get /dev/sdf1. Is that how it works, with multiply-matched rules
being put into arrays, or is it stored differently somehow?

-- 
3rd Law of Computing:
Anything that can go wr
fortune: Segmentation violation -- Core dumped



Re: Perl 6 Summary for week ending 2002-09-15

2002-09-19 Thread Piers Cawley

Leopold Toetsch [EMAIL PROTECTED] writes:

 Piers Cawley wrote:

 Happy birthday to me!


 Congratulations.

 ... by my turning 35 on the 15th


 44 on 16th - yes Sept.

Congrats to you too. So, should I start maintaining a birthday
database for the summaries? Probably not.

-- 
Piers

   It is a truth universally acknowledged that a language in
possession of a rich syntax must be in need of a rewrite.
 -- Jane Austen?