Just curiosity about some constructs



Hi again!

I have still curiosity about the reason of some C constructs/keywords...

The first is about static functions. What was the reason of restricting a function to be visible just in a specific source file? Wasn't it sufficient not to be given a prototype (for visibility)?

What about register and volatile variables? Was at that time a compiler not smart enough to optimize with in-register variables? And why would someone suggest the compiler not to optimze by making a variable volatile?

Last question! This is about the switch statement. The statement seems to me to be completely different from others. Let me explain with an example. A while(condition) will execute the statement after the while(), and if someone wants to have more instructions to be executed in the loop, then { } should be used. This is true also for if/else, do/loop, but not with the switch. A case does not require any { } to execute more than one instruction, moreover, a brake must be given to make a single case being executed, otherwise all the following non-brake case statements will be executed. Why wasn't the switch like the others with { } and automatic brake?

It's probably useless, but not for curiosity...

--
Sensei <senseiwa@xxxxxxx>

Part of the inhumanity of the computer is that, once it is competently programmed and working smoothly, it is completely honest. (Isaac Asimov)

.



Relevant Pages

  • Re: per cpun+ spin locks coexistence?
    ... You cannot switch to another processor in schedule_work, ... structures to be freed and then have to protect it by a global lock. ... Two CPUs doing fdtable free operations simultaneously will ... schedule_workis guaranteed to execute the work queue at least once, ...
    (Linux-Kernel)
  • Re: Just curiosity about some constructs
    ... > I have still curiosity about the reason of some C constructs/keywords... ... Was at that time a compiler ... This is about the switch statement. ... A whilewill execute the statement after the ...
    (comp.lang.c)
  • Re: Just curiosity about some constructs
    ... and sometimes people wanted to give the compiler hints ... This is about the switch statement. ... A whilewill execute the statement after the ... with labels and goto (although case labels are a little different ...
    (comp.lang.c)
  • Re: Switch isset and $_get
    ... several expressions here that could be true, ... that case is closed by 'break;', it will then terminate the switch, if the case is closed by 'continue;' it will continue to evaluate the other options too. ... I would have expected it to execute both in the order it came across them, but then again, thinking it over, the default in php by definition should be the last case, so it only executing the last one shouldn't surprise me. ...
    (comp.lang.php)
  • Unnecessary builds in VS2005 when build configuration is switched
    ... Switch to Release configuration then immediately switch back to Debug ... Execute build -- Attention: project A will be unnecessary recompiled! ... When this file exists build command executed from visual studio recompiles ...
    (microsoft.public.vsnet.general)