On Tue, Nov 03, 2009 at 07:15:43PM +0800, Majian wrote:
> Hi ,all:

Hello,

>  When I test the increment operator in Perl and  find   a question :
> 
> The question is :
> #!/usr/bin/perl
> use warnings;
> 
> my $i = 1;
> print  ++$i  + ++$i, "\n";
> 
> The above code prints  out  the answer 6 .
> But in the other language  the anser is 5 ,

*The* other language?

> So  I don't understand the reason why it is
> 
> Would someone give me some  options ?

You should probably start out by typing "sequence point" into your
favourite search engine.

Although perl doesn't have sequence points as such, you'll probably be
much happier if you assume it does.

The reason the answer is six rather than five is pretty much an artifact
of the implementation and is not something you should rely upon.

> Thanks ~~~

You're welcome.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to