[fpc-devel] pure function feedback

Marģers . margers.roked at inbox.lv
Fri Jun 28 10:35:16 CEST 2024


1. pure function value to constants function foo(i:longword):longword; pure; begin   foo:=9; end; const bar = foo( 8 );  //-- not allowed.. but i expect this to work!          jar : longword = foo( 7 ); //-- and this as well 2. this does not end grasefully function foo (i:longword):shortstring; pure; var s : shortstring;       n : longword; begin   s:=''';   for n:=1 to i do s:=s +'a';   //-- not assing return value end; begin writeln(foo(9)); end. 3. function foo (i:longword):ansistring; pure; var s : shortstring;       n : longword; begin   s:=''';   for n:=1 to i do s:=s +'a';   foo:=s; //-- this makes function not pure, but why whould it! end; begin writeln(foo(9)); end.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20240628/da761d2a/attachment.htm>


More information about the fpc-devel mailing list