On Sun, Nov 24, 2013 at 1:53 PM, Martin Schreiber <[email protected]> wrote:
> On Sunday 24 November 2013 14:48:05 Marcos Douglas wrote:
>> You can not protect the programmers using this. Think. Even if you use
>> 'return', 'result', whatever... if the programmer put a Exit on your
>> code the same error will happen! Bad programmers do it. They forget to
>> create some object, don't destroy them, etc. Who cares! No language
>> can protect all source.
>
> OK, I'll remove 'return' from MSElang, one source less (MSElang has
> no 'exit'). ;-)
> The argument is, it should be possible to program without 'return' if one
> wants a safe coding style therefore the assignment at function end.

I disagree that a program without 'return' or 'exit' uses a more safe
coding style.
IMO the 'exit' is indispensable for write a more simpler code.
"
function test(a: int32, b: int32, c: int32): int32;
begin
 result:= 0;     //initilization
 if (a=0) and (b=0) and (c=0) then
  exit;  // doesn't matter anymore, args are wrong!

 if a=-1 then
  result:= 123;
 else
 begin
  if (b=0) or (c=0) then
  begin
   result:= -100;
  else
   result:= 88;
 end;
"

>> Pardon me but your algorithm -- I know this is just an example -- is
>> wrong. You do not need to use GOTO.
>> Using the real Pascal:
>> "
>> begin
>>   result:= 0;     //initilization
>>   if a then       //long deeply nested processing
>>     result:= 123
>>   else
>>   begin
>>     if b and c then
>>       result:= -100
>>     else
>>     begin
>>       if not (a or b) then
>>       begin
>>         result := 1000;
>>         globflag:= true;
>>         exit;
>>       end
>>       else
>>         result:= 88;
>>     end;
>>   end;
>>   globflag:= result > 0;
>> end;
>> "
> The two things every Delphi expert writes:
> - *never* use 'goto', it is dirty!
> - do *not* use 'with', it is evil!

I use 'goto' (rare cases) and use 'with' a lot (but we know problems exist).

> Because I am no Delphi expert I think both statements are wrong. ;-)
> The 'exit' (or return) statement actually is a "goto end".

I just guess the 'exit' is wrong because should be a keyword not a
function -- like 'return' -- but it must exists.

> A 'goto' has a 'label' definition in header and a left aligned label, much
> better than 'exit' which easy can be overlooked.

Maybe 'goto' can be more explicit than 'exit' but more problems could
exists using 'goto' instead 'exit'.
Using 'exit' there is no error unless the programmer has not
initialized the return.
Using 'goto' you will can write a algorithm that never will exit from
de function, poor algorithm, etc.

--
Marcos Douglas

------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
mseide-msegui-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk

Reply via email to