Re: Light ideas
On Sat, 3 Aug 2002, Damian Conway wrote: > > don't know exactly what the syntax for adding /* */ will be > > Something like this: > > grammar Perl::With::Ugly::C::Comments is Perl { > > rule ws { | } > > rule ugly_c_comment { > /\* [ .*? ? ]*? \*/ > { let $0 := " " } > } > } > > caller{MY}.parser(Perl::With::Ugly::C::Comments); I'm still having trouble getting my head around the new grammar-construction rules. Three questions: 1) Am I right that anything inside a "rule" block is considered to be inside a regex? If not, why didn't you have to write: rule ugly_c_comment { / \/ \* [ .*? ? ]*? \* \/ { let $0 := " " } / } 2) As written, I believe that the ugly_c_comment rule would permit nested comments (that is, /* /**/ */), but would break if the comments were improperly nested (e.g., /* /* */). Is that correct? 3) The rule will replace the comment with a single, literal space. Why is this replacement necessary...isn't it sufficient to simply define it as whitespace, as was done above? Dave Storrs
Re: perl6-language@perl.org
According to Damian Conway: > { > temp sub false() {0} > # etc. > } I'm a bit concerned about what that would do to subroutines in other modules called during the block's execution. Perhaps "my sub" instead? PS: I wonder if the names would be &FALSE and &TRUE to avoid polluting the non-all-caps namespace ... ? -- Chip Salzenberg - a.k.a. -<[EMAIL PROTECTED]> "It furthers one to have somewhere to go."
Re: Light ideas
Miko O'Sullivan wrote: > OK, would that notation ( @arr[] = $var ) be something that could be added > by a module, in the same way that operators and /* */ will be addable? I > don't know exactly what the syntax for adding /* */ will be Something like this: grammar Perl::With::Ugly::C::Comments is Perl { rule ws { | } rule ugly_c_comment { /\* [ .*? ? ]*? \*/ { let $0 := " " } } } caller{MY}.parser(Perl::With::Ugly::C::Comments); > but if you can > say to the preprocessor something like s#/*#=comment#g then perhaps you can > also say something like s#\[\s*\]\s*=#binpush#g and then also define binpush > as an operator. You could rebuild the lexical parser grammar as above (to allow the lamentable C<@arr[] = $scalar> syntax), or you could just create a new operator with something like: module BinaryPush; my sub operator:<-- is exported (@array is rw, $scalar) { push @array, $scalar; } # and elsewhere... use BinaryPush; @arr <-- $val; Damian
Re: Light ideas
At 8:53 AM -0400 8/2/02, Trey Harris wrote: >(With the possible exception of modules that disobey the laws of physics, >but I'm not putting anything past Larry... no strict 'physics' ;) Yeek! Hopefully Larry'll forbear--while he may be able to pull that one off, I'm afraid I'm not up to the task... :) -- Dan --"it's like this"--- Dan Sugalski even samurai [EMAIL PROTECTED] have teddy bears and even teddy bears get drunk
Re: Light ideas
On Fri, 2 Aug 2002, Nicholas Clark wrote: : On Fri, Aug 02, 2002 at 08:53:51AM -0400, Trey Harris wrote: : > (With the possible exception of modules that disobey the laws of physics, : > but I'm not putting anything past Larry... no strict 'physics' ;) : : Yay! : : $ cat infinite_compression.pl : #!/usr/local/bin/perl6 : use strict; # Hopefully this triggers the p5 to p6 convertor. : use warnings; : no strict 'physics'; : use Compress::SnakeOil; : : while my $infile (@ARGV) { : my $outfile = "$infile.inf"; : compress_file (infile => $infile, outfile => $outfile, level => "Infinite"); : die "Problem compressing $infile to $outfile" unless -z $outfile; : } : __END__ : : : I do hope that works. :-) Infinite compression works great. Unfortunately, it's lossy. And done right, it requires infinite time. Larry
Re: Light ideas
On Fri, Aug 02, 2002 at 08:53:51AM -0400, Trey Harris wrote: > You've often asked this list, "will doing X in a module be possible?" > Consider the things that Damian's already done with modules in Perl 5. I > think Damian's involvement in Perl 6 if nothing else will insure that, no > matter what X stands for, the answer will be "yes." :-) > > Trey > > (With the possible exception of modules that disobey the laws of physics, > but I'm not putting anything past Larry... no strict 'physics' ;) Yay! $ cat infinite_compression.pl #!/usr/local/bin/perl6 use strict; # Hopefully this triggers the p5 to p6 convertor. use warnings; no strict 'physics'; use Compress::SnakeOil; while my $infile (@ARGV) { my $outfile = "$infile.inf"; compress_file (infile => $infile, outfile => $outfile, level => "Infinite"); die "Problem compressing $infile to $outfile" unless -z $outfile; } __END__ I do hope that works. :-) Nicholas Clark
Re: Light ideas
In a message dated Fri, 2 Aug 2002, Miko O'Sullivan writes: > OK, would that notation ( @arr[] = $var ) be something that could be added > by a module, in the same way that operators and /* */ will be addable? I don't think we've seen too much about how Larry plans to do Perl-munging-Perl except that we know it will be much more easily possible, and it will be based upon the grammars we saw in A5. That said, you could add this syntax fairly easily in Perl 5 with source filters (well, as easily as source filters ever are). I'd be highly surprised if that ability went away in Perl 6. You've often asked this list, "will doing X in a module be possible?" Consider the things that Damian's already done with modules in Perl 5. I think Damian's involvement in Perl 6 if nothing else will insure that, no matter what X stands for, the answer will be "yes." :-) Trey (With the possible exception of modules that disobey the laws of physics, but I'm not putting anything past Larry... no strict 'physics' ;)
Re: Light ideas
> > - There's already a huge population of programmers out there who already use > > this notation. I frankly admit that I think of PHP as a great idea that > > wasn't done quite right. > > I agree. Including that notation! ;-) Touche. Darn it's difficult disagreeing with pithy people. :-) OK, would that notation ( @arr[] = $var ) be something that could be added by a module, in the same way that operators and /* */ will be addable? I don't know exactly what the syntax for adding /* */ will be, but if you can say to the preprocessor something like s#/*#=comment#g then perhaps you can also say something like s#\[\s*\]\s*=#binpush#g and then also define binpush as an operator. -Miko
split suggestion
perl 5 already does that: print "'$_' " foreach split /(=)/, "rank=?"; print "\n"; print "'$_' " foreach split /\s*(=)\s*/, "rank = ?"; print "\n"; # Output: # 'rank' '=' '?' # 'rank' '=' '?' Greetings, Christian -- [EMAIL PROTECTED] - http://www.web42.com/crenz/ - http://www.web42.com/ "Faith (...) is the art of holding onto things your reason has once accepted, in spite of your changing moods." -- C.S. Lewis, Mere Christianity