[fpc-pascal] The reason why linus torvalds hate-pascal
Rodrigo Palhano
rodrigo at speedcase.com.br
Thu Apr 17 19:15:25 CEST 2008
>> if X = 0 then Exit;
>>
>> at the beginning of the procedure, one writes
>>
>> if X <> 0 then
>> begin
When you use it at the begining it may be arguably ok. But when it is used
in the
middle of procedure code it may be hard to notice.
On Thu, 17 Apr 2008 13:07:45 -0300, ik <idokan at gmail.com> wrote:
> On Thu, Apr 17, 2008 at 6:53 PM, mm <m2 at ellipsa.net> wrote:
>> 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
>
> 150 lines of code in procedure, should be move into smaller parts of
> code imho.
>
> But I believe in the motto of "die fast". As soon as you know that
> your code should not handle something, go away, don't continue your
> code, so exit have it uses. I think that every part of programming
> tools, have their use, the problem is the abusing of such tool, and
> using them even where there is no real use for it.
>
>
>>
>> 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/
>>
>>
>>
>> _______________________________________________
>> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>>
>
>
>
--
Rodrigo Palhano
---------------------------------
Equipe SpeedCASE
http://www.speedcase.com.br
More information about the fpc-pascal
mailing list