On Tue, Apr 24, 2001 at 11:53:49AM -0700, Mark Koopman wrote:
: > Perl 5 Perl 6
: > ----------------------------- ----------------------------
: > print "Next is " . $i + 1; print "Next is " + $i + 1;
:
:
: this is the root of the problem....Perl 5 version is easy to
: understand, Perl 6 version is still ambiguous
It is important to explain that if either side of the '+' operator is
in string context, it is interpreted as concat.
These would all have string context:
Perl5 Perl6
--------------------------- ---------------------------
print "Next is " . $i + 1; print "Next is " + $i + 1;
print 1 . $two; print 1 . "$two";
print 1 + 2 . $three; print 1 + 2 + "$three";
I think that another area of confusion might be the precidence model,
which was not detailed. For example:
[cwest@stupid cwest]$ perl -le'$i=2;print "Next is " . $i + 2'
2
[cwest@stupid cwest]$ perl -le'$i=2;print "Next is " . ( $i + 2 )'
Next is 4
I would prescribe it to be the following, just like Perl5 is now:
Perl5 Perl6
--------------------------- ---------------------------
print "Next is " . ($i + 1); print "Next is " + ($i + 1);
print 1 . $two; print 1 . "$two";
print (1 + 2) . $three; print (1 + 2) + "$three";
Numeric context wins.
I am not opposed to this idea, I see it to be quite easy to
understand, even without explicit parens, though they help.
--
Casey West