On Mon, 7 Mar 2005 08:22:04 -0800, Palit, Nilanjan
<[EMAIL PROTECTED]> wrote:
> 
> -----Original Message-----
> > From: Greg London [mailto:[EMAIL PROTECTED]
> > Sent: Monday, March 07, 2005 11:17 AM
> >
> > As for the triple-plus operator   ;)
> > I'd think perl would take x, do a "++" on it,
> > get 2, and then do the "+1" on it to get three.
> > But oh well. just won't use that in my code.
> 
> No. In Perl (or C), "$x++" => use & then increment, whereas "++$x" =>
> increment & then use. Thus the expression will use the existing value of
> x (1) to compute the value of y & then increment x itself.
> 
And in C++.  However there note that x++ implies an implicit
cloning operation - you need the original value to increment
and the returned value.  If your constructor is heavyweight, it
can be much better to write ++x, and avoid that clone (which
cannot be optimized away by the compiler because there may
be nontrivial semantic effects).

I consider it very ironical that C++ demonstrates that ++C is
a better way to write that idiom.  (Also I'd prefer a language
that was improved before I used it...)

Cheers,
Ben
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to