:: Re: [DNG] "Common knowledge?"-quest…
Etusivu
Poista viesti
Vastaa
Lähettäjä: Didier Kryn
Päiväys:  
Vastaanottaja: dng
Aihe: Re: [DNG] "Common knowledge?"-question
Le 25/01/2016 11:34, KatolaZ a écrit :
> I would say that having embedded subprograms in a function is not the
> best thing one can do in C


     Every block is a subprogram. The block in a do loop, the 
conditional block in an if or while statement. The subprogram blocks are 
everywhere in C; they're a basic construct of the language. I don't see 
why plain blocks woud be bad, ie neither conditional, nor loop. And I 
also consider a sane practice to restrict the scope of variables as much 
as it makes sense.


     It's just that there are two features that most C programmers never 
learn or quickly forget:


     1) blocks don't need to be conditional or loop,
     2) they can contain declarations.


     On the contrary, the ability to declare variables outside of a 
block, in the middle of instructions, like in C++ is a nonsense; it is 
an incitation to loose programming.


     I personnally re-discovered this very nice features a few years ago 
after having used the equivalent in Ada.


     Didier