for( my $i=0; $i< $#ARGV; $i++ )
{
next unless $ARGV[$i] eq "-f";
$i++;
$ARGV[$i] = absolute_filename $ARGV[$i];
}
chdir "foo";
exec "bar", @ARGV;
I'm trying to work out if there's a clever perl6 way to write this using
pattern matching:
for @*ARGV -> "-f", $filename {
$filename .= absolute_filename;
}
Would this actually work, or would it stop at the first elem that
doesn't match ("-f", ::Item)?
Is there some way to associate alternate codeblocks for different
patterns (i.e. local anonymous MMD)?
Dave.
(ps. if anyone on this list is looking for a $perl_job in Santa Clara,
CA, please contact me by email: dwhipp at nvidia -- no promises, but we
might even pay you to work on p6)
> Today I wrote some perl5 code for the umpteenth time. Basically:
>
> for( my $i=0; $i< $#ARGV; $i++ )
> {
> next unless $ARGV[$i] eq "-f";
> $i++;
> $ARGV[$i] = absolute_filename $ARGV[$i];
> }
> chdir "foo";
> exec "bar", @ARGV;
>
> I'm trying to work out if there's a clever perl6 way to write this
> using pattern matching:
>
> for @*ARGV -> "-f", $filename {
> $filename .= absolute_filename;
> }
>
> Would this actually work, or would it stop at the first elem that
> doesn't match ("-f", ::Item)?
>
> Is there some way to associate alternate codeblocks for different
> patterns (i.e. local anonymous MMD)?
>
>
That's given/when. I seem to recall that C<given> and C<for> do not
topicalize the same way, by design, but my recollection may be dated.
If I'm wrong, then:
for ... { when "-f" { ... }}
If I'm right, then there is probably an argument for a standalone "when"
that uses the default topic, or for some sort of shorthand to coerce a
unified topicalization.
=Austin
Is it possible to have an anonymous multi sub?
This would seem to require new syntax for combining two anonymous
definitions.
Of course we want everything to be first class, at least for feature
bragging rights.
Lexically scoped multi subs wouldn't require more syntax but I'm
not sure how two multis of different scope types are combined.
What counts as a fully redefinition, as partial redefinition and
as an extension?
It's 2am so ignore all gibberish,
Brad
--
In the words of the ancients, one should make his decisions within the
space of seven breaths. Lord Takanobu said, "If discrimination is long,
it will spoil." -- Hagakure