On Sun, Aug 27, 2000 at 07:29:33PM -0000, Perl6 RFC Librarian wrote:
> This RFC proposes that C<m//> and C<s///> be dropped from the language
> altogether, and instead be replaced with new C<match> and C<subst>
> builtins, with the following syntaxes:
> 
>    $res = match /pattern/flags, $string
>    $new = subst /pattern/newpattern/flags, $string

I think that C<subst> is too syntactically close yet semantically far
from C<substr> that the evil demons of confusion will rear their ugly
heads.

>    match;                  # all defaults (pattern is /\w+/?)

Er, why?  I usually check for the inverse:

        while (<>) {                    while (<>) {
            next if /^\s*$/;                next unless match; 
        }                               }

Hmm, now that I write it, it doesn't seem so bad.  *Except* that
"match" isn't a good description of what's going on.

>    subst;                  # like s///, pretty useless :-)

Given the above, why not make a bare C<subst> do something equally
useful?  Here are some ideas:

        subst;          # removes leading whitespace
        subst;          # removes trailing whitespace
        subst;          # removes leading and trailing whitespace
        subst;          # synonym for chomp  (Okay, it's a stretch :-)

>    next if /\s+/ || /\w+/;          next if match /\s+/ or match /\w+/;

Gosh this is annoying.  I *really* don't want to have to type "match"
all the time.  And now I have to use C<or> rather than C<||>, which is
already ingrained in my head  (I rarely use "or" or "and")

> Finally, it requires a little too much typing still for my tastes.

Indeed.

> Perhaps we should make "m" and "s" at least shortcuts to the names,
> possibly allowing users to bind them to the front of the pattern
> (similar to some of RFC 138's suggestions). Maybe these two could be
> equivalent:
> 
>     $new = subst /old/new/i, $old;   ==    $new = s/old/new/i, $old;
> 
> And then it doesn't look that radical anymore. This is similar to RFC
> 138, only C<$old> is not modified.

I wonder what happens when people start typing 

        $new = subst s/old/new/i, $old;

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to