[net.lang.c] `if` `

steven@qubix.UUCP (Steven Maurer) (05/22/84)

References:
[forth love if honk then]


	Anyone who is a serious student of programming linguistics,
    should realize that a delimiter is neccessary to separate the
    expression from the statement in all conditional language-constucts
    -- if you want to keep your grammer LALR(1) (almost a given).

	With this in mind, it becomes only a matter of style as to
    which type(s) of delimiter you prefer.    I prefer the '(' ')'
    of C, to the 'if' 'then' of Pascal, because:  [1] It is shorter
    to type, [2] Is symmetrical, and [3] Does not disguise the true
    purpose of the construct.

    No doubt Pascal-o-philes have other opinions on the matter.

    Steven Maurer

    p.s.   I discount the return (expr)  vs return expr, argument
	as being patently silly; it is simply a matter of style,
	nothing else.  No C programmer I have EVER met, believes that
	return (expr) is actually a function call.

    p.p.s. Symmetry is very important as a programming tool, since
	it allows the programmer to develop a habit of writing each
	construct in a particular manner  (sort of a construct template
	in his mind), WITHOUT having to anaylize the surrounding program
	to see if the syntax is correct.  NON-symmetry is the most
	aggrivating part of programming Pascal, as anyone who has been
	bitten by the: <if> <stmt> <NO-SEMICOLON> <else> <stmt> <semicolon>
	can tell you.    Symmetry is a very important aspect of
	programming ergonomics.

steven@mcvax.UUCP (Steven Pemberton) (05/24/84)

>	Anyone who is a serious student of programming linguistics,
>    should realize that a delimiter is necessary to separate the
>    expression from the statement in all conditional language-constucts
>    -- if you want to keep your grammer LALR(1) (almost a given).
Nonsense. You can even define an LL1 grammar with no delimiter.

>    I prefer the '(' ')' of C, to the 'if' 'then' of Pascal, because:
>    [1] It is shorter to type, [2] Is symmetrical, and
>    [3] Does not disguise the true purpose of the construct.
Isn't <keyword> <expression> <keyword> also symmetrical? How is the true
purpose of the construct disguised by the absence of brackets,
and the presence of 'then'?

>    NON-symmetry is the most aggravating part of programming Pascal,
>    as anyone who has been bitten by the:
>       <if> <stmt> <NO-SEMICOLON> <else> <stmt> <semicolon>
>    can tell you.
Semicolons are separators in Pascal and not terminators, just as commas are
in C. Your mistake is thinking that the semicolon has anything to do with
the statement. It doesn't; the correct view is
        <if> <stmt> <NO-SEMICOLON> <else> <stmt> <ALSO-NO-SEMICOLON>
You wouldn't expect to see a function call like f(a,b,c,); semicolons play
the same role as commas in Algol-like languages.

I expect that having trouble with Pascal semicolons is a product of one's
previous experience. My first languages were Fortran followed by Algol 68,
and I've never experienced the separator vs. terminator problem.
However, I expect that if my first language had been C, I would have had.
When I first learnt C, I kept missing semicolons out, such as
    if (a>b) {a=0; b=0}
But that was my fault, not the language's.

Actually, semicolons are completely unnecessary. You can define a language
without statement terminators or separators, and also without things like
Fortran's continuation lines. See for instance "Keyword Grammars" by Geurts
and Meertens, in Proc. 5th Annual III conference, 1977, published by INRIA,
Le Chesnay, France.

steven@mcvax.UUCP (Steven Pemberton) (05/24/84)

>	Anyone who is a serious student of programming linguistics,
>    should realize that a delimiter is necessary to separate the
>    expression from the statement in all conditional language-constucts
>    -- if you want to keep your grammer LALR(1) (almost a given).
Nonsense. You can even define an LL1 grammar with no delimiter.

>    I prefer the '(' ')' of C, to the 'if' 'then' of Pascal, because:
>    [1] It is shorter to type, [2] Is symmetrical, and
>    [3] Does not disguise the true purpose of the construct.
Isn't <keyword> <expression> <keyword> also symmetrical? How is the true
purpose of the construct disguised by the absence of brackets,
and the presence of 'then'?

>    NON-symmetry is the most aggravating part of programming Pascal,
>    as anyone who has been bitten by the:
>       <if> <stmt> <NO-SEMICOLON> <else> <stmt> <semicolon>
>    can tell you.
Semicolons are separators in Pascal and not terminators, just as commas are
in C. Your mistake is thinking that the semicolon has anything to do with
the statement. It doesn't; the correct view is
        <if> <stmt> <NO-SEMICOLON> <else> <stmt> <ALSO-NO-SEMICOLON>
You wouldn't expect to see a function call like f(a,b,c,); semicolons play
the same role as commas in Algol-like languages.

I expect that having trouble with Pascal semicolons is a product of one's
previous experience. My first languages were Fortran followed by Algol 68,
and I've never experienced the separator vs. terminator problem.
However, I expect that if my first language had been C, I would have had.
When I first learnt C, I kept missing semicolons out, such as
    if (a>b) {a=0; b=0}
But that was my fault, not the language's.

Actually, semicolons are completely unnecessary. You can define a language
without statement terminators or separators, and also without things like
Fortran's continuation lines. See for instance "Keyword Grammars" by Geurts
and Meertens, in Proc. 5th Annual III conference, 1977, published by INRIA,
Le Chesnay, France.

Steven Pemberton, CWI, Amsterdam. steven@mcvax