[fpc-pascal] The reason why linus torvalds hate-pascal

mm m2 at ellipsa.net
Thu Apr 17 17:53:59 CEST 2008


Rodrigo Palhano a écrit :
> On Tue, 15 Apr 2008 19:39:37 -0300, Zaher Dirkey <parmaja at gmail.com> wrote:
> 
>> I use GO TO when teaching pascal, but after all i ask them to not use 
>> it, it
>> just a bridge to learning the logic of programming language.
>>
>> There is another word i hate to use it it is EXIT.
> 
> I also understand EXIT as a bad programming practice, it makes life 
> harder for code readers.

I don't ;-) Even Ada has an "Exit" instruction which one is better than
the Pascal one because, with Ada, "Exit" is a keyword.

Using "Exit" is not of a bad programming practice. Suppose one has to
write a big procedure, say 150 lines of code. Suppose now that, instead
of writing

   if X = 0 then Exit;

at the beginning of the procedure, one writes

   if X <> 0 then
   begin
     ...

Does a reader immediately see that, when X = 0, the procedure does
nothing? No. They have to read all the code, to search for the "end"
that closes the "begin" in order to get sure there are no instructions
after this "end". In such a case, with the "Exit" instruction the
procedure is much easier to read.

mm
----
http://www.ellipsa.net/




More information about the fpc-pascal mailing list