[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: The meaning of 'sugar' [Forked from Re: Why do we have ipairs?]
- From: Daniel Silverstone <dsilvers@...>
- Date: Wed, 11 Jun 2014 16:15:06 +0100
On Wed, Jun 11, 2014 at 16:56:34 +0200, Francisco Olarte wrote:
> > For example, the intent of "i = i +1" could not be clearer.
> > "++i" is shorter and sweeter for the programmer, but it is not clearer and
> > it is not more expressive.
> I do not think you've picked a very good example. Many people, me
> among them, parse '++i' as 'increment i' in one simple pass, and when
> you have something like
> ++a_very_long_variable_name_becuase_it_is_a_global, it's much clearer.
I would have to respectfully disagree here. Since I work with C a lot, I have
to parse "++i" as "read the value of i, increment it, store it back to i, and
evaluate to the new value of i" since that is subtly, but importantly,
different to "i++" which evaluates to the original value of i.
I find mutation operators to generally be unpleasant except as assignments (i
+= 1) for example.
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 3CCE BABE 206C 3B69