tranleduy2000 / pascalnide

Pascal Compiler for Android
92 stars 25 forks source link

[lang] Optional parameters doesn't work #7

Open pakLebah opened 7 years ago

pakLebah commented 7 years ago

Today's Pascal —as being used by FPC and Delphi since ages ago— has default or optional parameter in function/procedure declaration. This kind of parameter can be omitted when calling the function. This doesn't work in Pascal N-IDE.

Example:

program test;

uses SysUtils;

// function f with p as optional parameter (has default value)
function f(p: integer = 0): string;
begin
  if p = 0 then
    f := 'zero'
  else
    f := intToStr(p);
end;

begin
  f;    // print 'zero'
  f(2); // print '2'
end.

Reference: https://www.freepascal.org/docs-html/current/ref/refsu64.html#x176-19800014.4.1