Hmmm, I would really like to do this in perl:
my $str = "some strory"; $str .= ", an happy ending"; $str =. "A realy exciting begin, "; # instead of: $str = "A realy exciting begin, " . $str;
It won't add any functionality, but it sure will make my scripts better reading material. Would such a operator cause problems for the syntax parsing ?

Also unavailable are '=/' and '=-', which obviously would differ from '/=' and '-=', while '+=' and '=+' would be exactly the same.

But this little itch ain't worth a source filter in my opinion *sigh*
--
Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
>>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<

Replies are listed 'Best First'.
Re: a-symetric operators
by theorbtwo (Prior) on Jan 23, 2003 at 03:15 UTC

    Actualy, I think most of them would be unavaliable.

    Going highest to lowest precidence, and counting only binary ops:

    1. **: available.
    2. *: conflicts with globs.
    3. /: conflicts with regex matches.
    4. %: conflicts with hashes.
    5. x: available, but probably not very useful in reverse.
    6. +: conflicts with unary +.
    7. -: conflicts with unary negation.
    8. .: conflicts with numbers 0<x<1, probably OK to DWIM with.
    9. <<, >>: available.

    I'm out of paticence, but the rest are all mostly symetric.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      Ok -- I was forgetting for a moment the fact that whitespaces are just for the coder's eye, and not for the parser's.
      But still ...
      --
      Jaap Karssenberg || Pardus (Larus)? <pardus@cpan.org>
      >>>> Zoidberg: So many memories, so many strange fluids gushing out of patients' bodies.... <<<<
      Well, ** isn't available.
      $x =** 4;
      is a syntax error, as that parses as:
      $x = ** 4;
      . ** is the glob *.

      Also,

      $str =<<'--'; Foo --

      already has a meaning, so << is out as well.

      x is also not available.

      $x =x 4; # Parses as $x = x(4), if there's a sub 'x'.

      Abigail

        << I considered shortly after I wrote this -- but I was already in bed. ** could probably DWIM. x may or may not be able to DWIM... I'd have to think about it more. In any case, enough of them simply won't work for it to kill the idea, methinks, so it's rather moot.


        Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: a-symetric operators
by integral (Hermit) on Jan 28, 2003 at 07:38 UTC
    This modification would work for binary operators, but the problem arises with unary operators. For example * is the binary operator for multiplication, but the unary operator/sigil for globs, so while $a *= 123, can't mistake the = as a bareword, and so *= is matched, $a =* abc (with no strict, so that barewords are allowed), could parse as either $a *= abc, or $a = *abc (although the first doesn't make much sense). This would probably complicate the parser with unnecessary lookaheads, and backtracking to allow it to DWIM between the cases.