Free Pascal => Beginners => Topic started by: OldProNew on July 31, 2021, 10:53:23 pm
Title: Default valued procedure / function parameters
Post by: OldProNew on July 31, 2021, 10:53:23 pm
Why do neither of the following functions - with a default valued parameter - compile? The compiler says "illegal expression" after the symbol "kMAX". Probably something very trivial... but what? (No, don't tell me the functions are silly. I know that! Just simple examples of the problem I'm having with default valued parameters using named, typed constants as the default value. Replacing "kMAX" with "12345" makes the compiler happy, but not me https://forum.lazarus.freepascal.org/Smileys/ExcellentSmileys1/cool.gif
const kMAX: integer = 12345 ;
function TEST1(A: integer; const B: integer = kMAX): boolean ; begin TEST1 := (A <= B) end; function TEST2(A: integer; B: integer = kMAX): boolean ; begin TEST2 := (A <= B) end;
Title: Re: Default valued procedure / function parameters
Post by: FTurtle on August 01, 2021, 12:16:59 am