Click here to Skip to main content
15,905,875 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
OriginalGriff27-Sep-16 1:24
mveOriginalGriff27-Sep-16 1:24 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:01
kalberts27-Sep-16 3:01 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PeejayAdams27-Sep-16 1:42
PeejayAdams27-Sep-16 1:42 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
OriginalGriff27-Sep-16 1:53
mveOriginalGriff27-Sep-16 1:53 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PeejayAdams27-Sep-16 2:28
PeejayAdams27-Sep-16 2:28 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:28
kalberts27-Sep-16 3:28 
JokeRe: Another C# syntax to wish for (or any C class language) Pin
Daniel Pfeffer27-Sep-16 3:58
professionalDaniel Pfeffer27-Sep-16 3:58 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 2:35
kalberts27-Sep-16 2:35 
In Pascal, a statement is a block. Anywhere a block is required, a statement will do, because it is a block.

In C, a statement is not a block. Several productions require a block (e.g. a catch() {}), so you have to create a block out of a single statement by enclosing it in {}.

You may argue: Well, there's the explanation for those {} requirements - they are there to create a block! They are not superfluous.

Yes, if you without any question accept the way C grammar was defined, of course you find it obvious that the {} should be there. So the problem is not in the {} themselves, but in that a statement was not defined as a block, the way it in Pascal. But the end result is the same: In C, you several places need to add {} around a single statement, where Pascal does not require any bracketing constructs.

This holds for several other languages as well - I refer to Pascal because it is the most well known of those.

That bracketing constructs in Pascal are more voluminous (BEGIN - END) than {} is just a small detail related to the parsing of tokens; it is irrelevant to the syntax productions.

Most non-C algorithmic languages don't even need any () bracketing of the condition in 'if' and loop constructs - yet they allow for just as general logical expressions as C does.

The try-catch is another silly bracketing mechanism. Pascal's origins are older than the exception concept, but in other language like CHILL, any block (including a statement, which is a block) is an implict try-block: Between the block and the terminating semicolon, an ON clause may be put (ON corresponds to 'catch'). You need no pre-announcement like 'try', you need no braces just to identify what is being tried - the handler implicitly applies to the block to which it is attached.

The C language was not created by people who were experts on language design, but by programmers who did it as a left hand job inbetween lots of other work. C is that way because... well... that's just how it was done, take it or leave it... On the other hand, Pascal was Designed by a qualified Language Designer, according to a plan and with a well defined goal.

That being said: There are several cases of language designs so academic and theoretically perfect, and without any pragmatic adaptations whatsoever, that they are almost impossible to work with. It is certainly possible to overdo design! You need a teaspoonfull of pragmatism in any design. But C is not a teaspoonfull of pragmatism in a design, it is huge showels of pragmatism without any design at all. That pragmatism overload does not make it useful, it makes a mess. Well, since K&R C, the language has been tightened up in several aspects. C# is the better of the C crowd, and can be tolerated. But it never got rid of those "superfluous" {}, the parenthesising of logical expressions and that super-ugly exception syntax, which is a pity.
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Richard Deeming27-Sep-16 3:15
mveRichard Deeming27-Sep-16 3:15 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:41
kalberts27-Sep-16 3:41 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
raddevus27-Sep-16 3:21
mvaraddevus27-Sep-16 3:21 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:58
kalberts27-Sep-16 3:58 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
jsc4227-Sep-16 3:23
professionaljsc4227-Sep-16 3:23 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 3:35
kalberts27-Sep-16 3:35 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton27-Sep-16 4:20
mvaMarc Clifton27-Sep-16 4:20 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts27-Sep-16 4:31
kalberts27-Sep-16 4:31 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Marc Clifton28-Sep-16 15:33
mvaMarc Clifton28-Sep-16 15:33 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
Ryan Peden27-Sep-16 5:25
professionalRyan Peden27-Sep-16 5:25 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
BillWoodruff27-Sep-16 17:05
professionalBillWoodruff27-Sep-16 17:05 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
PIEBALDconsult28-Sep-16 11:05
mvePIEBALDconsult28-Sep-16 11:05 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
lopatir28-Sep-16 19:49
lopatir28-Sep-16 19:49 
GeneralRe: Another C# syntax to wish for (or any C class language) Pin
kalberts29-Sep-16 0:49
kalberts29-Sep-16 0:49 
GeneralHmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:09
professionalglennPattonWork327-Sep-16 0:09 
PraiseRe: Hmm, I am starting to wonder about recruitment... Pin
Duncan Edwards Jones27-Sep-16 0:17
professionalDuncan Edwards Jones27-Sep-16 0:17 
GeneralRe: Hmm, I am starting to wonder about recruitment... Pin
glennPattonWork327-Sep-16 0:25
professionalglennPattonWork327-Sep-16 0:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.