Recent

Author Topic: function and result  (Read 12794 times)

creaothceann

  • Full Member
  • ***
  • Posts: 117
Re: function and result
« Reply #45 on: October 31, 2018, 08:49:38 pm »
Exit() in FreePascal was first. (Not Exit without parameters) Delphi added it later. E.g. D7 doesn't even know that syntax.
It would help if some people have at least a minute grasp of such things. Probably too young.

We were talking about exit in finally.

Thaddy

  • Hero Member
  • *****
  • Posts: 16928
  • Ceterum censeo Trump esse delendam
Re: function and result
« Reply #46 on: November 01, 2018, 04:26:16 pm »
Yes? that applies here too.... ? See https://www.freepascal.org/docs-html/rtl/system/exit.html

Confused with Halt()?

Here's proof:
Code: Pascal  [Select][+][-]
  1. {$ifdef fpc}{$mode objfpc}{$H+}{$endif}
  2. uses sysutils;
  3.  
  4. function somefunction:boolean;
  5. begin
  6.   try
  7.     exit(100+4 = 104); //true!
  8.   finally
  9.     Result := false;
  10.   end;
  11. end;
  12. begin  
  13.   writeln(somefunction); // what does that say?
  14. end.
Btw wp already spotted his errant ways. He is forgiven  8)
« Last Edit: November 01, 2018, 04:47:13 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018