I'm looking at a programming language design decision that's difficult to make precisely because there seems to be no objective basis for choosing one option over the other. The question is, given that a language doesn't have a ++ operator, would the better choice for an increment operator be as in C:
a += 1
a += b
or as in some versions of Pascal:
inc a
inc a b
(And similarly with -= vs dec of course.)
Considerations I can see for inc:
- Slightly shorter for the typical case where the delta is 1.
- Less familiar to most programmers.
- Eliminates the corresponding
*=etc operators, which are much less commonly used.
Is there anything I'm missing?
procedure inc(x: var Integer); begin x := x + 1 endor something like that). So simplicity at language level may be another point. – delnan Jan 7 '12 at 11:02+=also mean string concatenation and would this cause users to get undesired results like it can in javascript. – WuHoUnited Jan 7 '12 at 14:13