He didn't list many arguments
He mentions there are arguments for both ways ("I don't find it hard to imagine cases where either result would be preferred."), but they're not listed.
So your POW is that the standard behavior is wrong
My POV is:
- There is currently no standard. (See Re^11: ref to read-only alias ... why? (notabug).)
- Many people are currently modifying values from literals where it is possible to do so, and they are very unwilling to give up that feature.
- Perl is about enabling people to do what they want to do.
- The two downsides are addressable.
- Inefficiency of creating a new scalar every time a const op is evaluated. (Use a COW mechanism.)
- Creation of useless code is possible, e.g. 123++; (Emit warnings when appropriate.)
Without really understanding the opcode-level I'm wondering why you say that either behaviors are difficult to implement if both already exist.
There's no denying the current implementation isn't sane.
- Inconsistent. (For example, for (1) { ++$_; say $_; } is different than for (1) { $r = \$_; ++$$r; say $$r; }.)
- Buggy. (For example, for (1..2) { for (1..3) { ++$_; say; } }.)
Hash key vivification has similar problems.
sub {}->( $h{x} ) # Doesn't vivify
sub {}->( @h{x} ) # vivifies
for ( $h{x} ) { } # vivifies
for ( @h{x} ) { } # vivifies
\$h{x} # vivifies
\@h{x} # vivifies
In both case, it's more a question of time than difficulty.
IMHO there should always be a configurable (i.e. switchable) warning because different people expect different behavior.
I don't see a point to a switch whose sole purpose is to break working code.
No argument or example was given to indicate there is another purpose. There probably are some, and I would love to hear them. Until then, the switch makes no sense.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|