-- On Fri, 7 Feb 2003 16:28:43 gpurdy wrote: >All -- > >A4 gives this example of C<for>: > > for @foo -> $a, $b { ... } # "for @foo into $a and $b..." > >but, this seems more natural to me (and, it turns out, closer to the P5 >syntax for ill or good): > > for $a, $b <- @foo { ... } # "for $a and $b from @foo..."
All else aside, I think that a <- will not fly. It's too easily read as greater-than-unary-minus -Erik > >(heck, that even looks like shifting -- "shifty aliasing". The A4 syntax >looks like popping until you realize it is really shoving the left N >thingees into the containers on the right -- Syntactical Action at a >Distance). > > > >Then, A4 gives this example of C<grep>: > > grep -> $x { $x eq 3 } @list # "grep into $x, $ eq 3 from @list" > # NOTE: String comparison to a number... > >But, this would match the C<for> example better, IMO (and puts the >alias name near the source of the things it will be aliasing): > > grep { $x eq 3 } @list -> $x # "grep $x eq 3 where @list into $x" > >My guess is that Larry wanted $x to appear before the block it >will be used in, and that C<grep>'s swapping of block and list >(when compared to C<for>) makes doing so ugly (IMO). > > > >But, this would be more natural overall (again, IMO), following my >suggestion for C<for>, above: > > grep { $x eq 3 } $x <- @list # "grep $x eq 3 where $x from @list" > >Whether what I suggest makes sense to anyone else or not, I do >think the disparity between C<for> and C<grep> in A4 should be >dealt with... > >------------------------------------------ > >Oh, and A4 also says "Standard Perl declarations will be plainly >marked with C<my> or C<our>." The C<< -> >> or C<< <- >> notation >for what amounts to a C<my> should be mentioned nearby, IMO. > >------------------------------------------ > >On another note, this would seem to be a handy statement modifier >form for greppage: > > my @threes = @list when $_ eq 3; # NOTE "where" sounds better > >although appropriate aliasing syntax for this eludes me at the moment... > > my @threes = $x <- @list when $x eq 3; > >feels weird with the $x near the '='. And neither of these feels right >either: > > my @threes = @list when -> $x { $x eq 3 }; # Close to A4 C<grep> >ayntax > my @threes = @list -> $x when $x eq 3; # Close to A4 C<for> syntax > > >Regards, > >-- Gregor > ____________________________________________________________ Get 25MB of email storage with Lycos Mail Plus! Sign up today -- http://www.mail.lycos.com/brandPage.shtml?pageId=plus