Tomas Hajny wrote:
On Tue, July 30, 2013 17:03, Timothy Groves wrote:
FPC offers the +=, -=, etc., statements swiped from C. Is there any
reason why ++ and -- are not similarly supported? I know that we have
inc() and dec(), but I'd say that ++ and -- are easier to type.
General side note with no intention to start discussion about superiority
of one language to another: A lot of C constructs is easier to type than
their Pascal equivalents but not necessarily even equally easy to read.
Seconded.
Now specifically to your question - I believe that one of the reasons may
be the fact that Pascal does not support unary arithmetic operators in
postfix notation. The fact that C allows using them with both prefix and
postfix notation makes them even more difficult from my point of view
because potentially allowing them only in one of the notations known from
other languages would immediately trigger users to ask why only one of
possible notations (common elsewhere) is supported and the other not.
I've got a vague recollection that some of the ++ and -- semantics are
particularly unpleasant, and that one of the C inventors did his best to
disown them. At least += etc. are fairly unambiguous: they're almost
macro expansions and as such they don't mandate any extra overloadable
operators etc.
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal