You are just talking about "Syntax Sugar". Don't think that what you write is exactly what happens behind scenes.

Just because you write the variable once, this doesn't means that it will be called once in the interpreter. For example:

$x = $x * $y ; ## With the Syntax Suger: $x *= $y ;
But note that internally it works like the first! It get the value of $x, multiply by $y, than save the result in $x.

But this are different:

$var = $var . 'xyz' ; $var .= 'xyz' ;
The 1st rewrite all the variable, with the extra of 'xyz'. the 2nd just append 'xyz' to $var.

So, how do you think that the interpreter will work with this 2 ways?:

$latest = $latest > time() ? $latest : time(); ## With your Syntax Suger: $latest ?>:= time() ;
The only good thing in the 2nd is to avoid the rewrite for it self ($latest = $latest ;) of the 1st option. But why not just write:
## Probably what should be made internally: my $tmp = time() ; $latest = $tmp if $latest > $tmp ;
Personally I don't like to use much Syntax Sugar, unless the basic (.= += .... $x++). I don't like them for conditional blocks, since I think that this part need to be explicity, since other programers need to know how to read your code (and generally they don't know much about Syntax Sugar). But of course that your idea is valid, since is original. ;-P

Graciliano M. P.
"The creativity is the expression of the liberty".


In reply to Re: A set of new operators. In keeping with the design of Perl? by gmpassos
in thread A set of new operators. In keeping with the design of Perl? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.