On Thu, 24 Oct 2002, Michael Lazzaro wrote:
:    $str1 ~ $str2                # $str1 =~ m/$str2/

That would be a smart match, not m/$str2/.

:    $str ~ /foo/                 # $str1 =~ m/foo/

That would work.

:    $str2 = ($str ~ /foo/bar/);  # perform subst, assign result to $str2
: 
:    $str ~= /foo/bar/;           # perform subst, assign result to $str

That can't work without the "s".  The lexer can't tell if "bar" is a string
or an operator.

But the ~= is a cute trick.  Not sure if it's more than that though.
Gotta worry about s/// in a boolean context, for instance.  And the
current idiom

    ($str2 = $str1) =~ s/foo/bar;

is not much longer than yours, though your parens are, I think, optional,
while mine aren't.

But we also have to balance it against the desirability of using ~ for
concatenation.  Requiring whitespace around _ is a bit of a rationalization
after the fact, and ~ escapes that problem in most cases.

Plus, smart matching is such a heavyweight, notionally speaking,
that it really deserves a larger operator.  Since there's no such
thing as a "logical concat", we might get away with using ~~, and
then people wouldn't have to wonder whether it was ~= or =~.

Or we could make it ===.  That would pretty much rule out having the
corresponding assignment operator though...

Or we could leave it =~ for old times sake, and make people learn
the difference from ~=.

Or go with something new:

    $a :~ $b
    $a =~= $b
    $a =? $b
    $a <?> $b
    $a <~> $b
    $a >< $b
    $a ::: $b
    $a match $b
    $a like $b
    $a vs $b
    $a v $b

If it is, in fact, a topicalizer, then the Japanese would very
naturally parse a postpositional particle:

    $a wa $b

Or we could go with Valspeak:

    $a is like $b and stuff

At the moment I like "like" the best, actually...

Larry

Reply via email to