[mythtv] C++ style

Daniel Thor Kristjansson danielk at cat.nyu.edu
Wed Feb 11 21:36:18 EST 2004


I just saw Ken Thompson yesterday, he invented the ++/-- on the PDP-7 in
B. The PDP-7 did not have the PDP-11 auto-increment and auto-decrement
address modes, the PDP-11 also did not exist yet. pcc may have
implemented x++ as a post-increment, but there were many compilers that
didn't do this. Only ++x was defined well until the 80's when ANSI
standardization had to deal with the common assumption that x++ was a
post-increment. I have used some of these annoying non-ansi compilers
working with embedded systems, it ain't fun. If I hadn't lost my copy
of the K&R 1st edition I'd look it up.

Not that this matters, with ANSI C++ or C89 post-increment is only ill
advised for classes where you might accidentally get an expensive class
copy with a compiler such as gcc.

-- Daniel
  << When truth is outlawed; only outlaws will tell the truth. >> - RLiegh

On Thu, 12 Feb 2004, Simon Kenyon wrote:

]On Wednesday 11 February 2004 20:03, Daniel Thor Kristjansson wrote:
]> Classes are the real reason to prefer pre-increment over post-increment,
]> with integers the compiler will figure it out. There is also a backward
]> compatibility reason for it. In old school C ++i is defined as a
]> pre-increment and i++ is defined as "whatever is fastest" so there is
]> no actual post-increment in C. Many compilers including gcc support it
]> as a post-increment because that's less surprising, but you might not
]> want to depend on that.
]in any-school C i++ is post-increment
]has been for 20 years or more
]these operators derive from the pre and post increment and decrement
]instructions in the pdp-11
]--
]simon
]_______________________________________________
]mythtv-dev mailing list
]mythtv-dev at mythtv.org
]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev
]


More information about the mythtv-dev mailing list