On Sat, Oct 18, 2008 at 11:22 AM, David Hamill <[EMAIL PROTECTED]> wrote:
> BTW, can anyone explain why the 'for' syntax has only two
> semicolons, not three?

Because there are only three things needed there, and to separate 3
things, you only need 2 separators?

> (I think this might have been the
> intention of the original question.) In C the semicolon is a
> statement terminator,

Among other things. The comma is also 'overloaded'. As are the & and |
characters.

> not a statement separator (as in
> Pascal). It would seem more intuitive to write
>
>  for (i = 0; i < n; i++;)

The last ; is superfluous. The closing parens terminates the
expression, why the extra ;?

> If an expression separator were needed a colon could have
> been used, as with the '?' operator:
>
>  for (i = 0 : i < n : i++)
>
> Just wondering.

'It just is.' or if you want a 'real' answer, 'it's in The Standard'

Probably no reason in particular, but the things in the parens are
separate things, so separate them with ;. The things in ?: are more
tightly bound so ; was probably chosen over :.

Most of the stuff in The Standard were written bearing in mind that a
lot of stuff had been written and they didn't want to break too much
stuff, so they adopted 'the most common practice.'


-- 
PJH

http://shabbleland.myminicity.com/ind

Reply via email to