Forum > Free Pascal
Feature announcement: Function References and Anonymous Functions
Peter H:
Hi, I noticed this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure(const aArg: String) begin Writeln(aArg); end('Hello World');
is not supported by codetools.
It says:
project1.lpr(26,5) Error: unexpected keyword "procedure"
Also this compiles, but is not accepted by codetools:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---p:= function foo:integer begin foo:= 4711; end;
It does accept this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---i:= function:integer begin Result:= 4711; end();
Just for the records, it is not an important problem.
Edit:
Compilable and runnable example attached.
PascalDragon:
Best report it as an issue for Lazarus then.
Peter H:
I have done this now, was a lot of work create account.
GitLab is not for beginners and casual programmers like me.
I put the code in, cleanly formatted as seen here, and when I submitted it formatting was destroyed.
Then you have to read several pages about GitLab Markdown language before you learn how to fix this.
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39871
lazycat2:
Looks like I'm missing something obvious (I'm new to FPC) but where how do I get support for those new features? The FPC 3.2.2 doesn't seem to have it and there's no download for a newer version.
dbannon:
Well, safest and easy to wait for the next release.
But if you want to have it now, build it from source. Your existing 3.2.2 will build it. See https://wiki.freepascal.org/Installing_the_Free_Pascal_Compiler
Down load a zip ball or using git ....
Keep it in a separate directory to your existing install and set PATH accordingly.
Davo
Navigation
[0] Message Index
[#] Next page
[*] Previous page