1
0
Fork 0
forked from fun/fun

Added nested functions to the Fun parser. (0.40.0)

This commit is contained in:
Johannes Findeisen 2026-04-02 02:23:42 +02:00
commit be75ee47f8
7 changed files with 130 additions and 15 deletions

View file

@ -0,0 +1,22 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Demonstrates nested functions that are only visible inside the
* outer function where they are defined. This example avoids
* capturing outer variables (closures) and instead passes values
* explicitly, which works with the current implementation.
*
* Added: 2026-04-02
*/
fun outer(x)
fun inner(y)
return y * 2
end
return inner(x) + inner(3)
end
print(outer(5))

View file

@ -1,12 +0,0 @@
#!/usr/bin/env fun
#include <net/cgi.fun>
cgi = CGI()
pairs = cgi._parse_urlencoded("a=1&b=2&c=3")
i = 0
n = len(pairs)
while (i < n)
p = pairs[i]
print(to_string(p[0]) + "=" + to_string(p[1]))
i = i + 1

View file

@ -1,5 +1,17 @@
#!/usr/bin/env fun
/*
* This file is part of the Fun programming language.
* https://fun-lang.xyz/
*
* Demonstrates nested functions that are only visible inside the
* outer function where they are defined. This example avoids
* capturing outer variables (closures) and instead passes values
* explicitly, which works with the current implementation.
*
* Added: 2026-04-02
*/
#include <net/cgi.fun>
cgi = CGI()