summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-19 10:20:11 +0200
committerPaul Buetow <paul@buetow.org>2026-02-19 10:20:11 +0200
commit03b874818315e7dc9fb2ccf26716a0fb65242a57 (patch)
treecc375998c809ded77d920f6a2a2a50241018f016
parent2e81f599a0323e2025883bc1375bf438d1406733 (diff)
Rename func keyword to fun
Replace the `func` language keyword with `fun` throughout: update the scanner's string-to-token mapping, all .fy example scripts, and all documentation files (.txt, .pod, .tex, .man, .html). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--README.txt8
-rw-r--r--docs/pod/fype.html8
-rw-r--r--docs/pod/fype.man6
-rw-r--r--docs/pod/fype.pod8
-rw-r--r--docs/pod/fype.tex8
-rw-r--r--docs/pod/fype.txt8
-rw-r--r--examples/all-examples.txt18
-rw-r--r--examples/func_args_ret.fy12
-rw-r--r--examples/functions.fy6
-rwxr-xr-xfypebin270384 -> 278432 bytes
-rw-r--r--src/build.h2
-rw-r--r--src/core/token.c2
12 files changed, 43 insertions, 43 deletions
diff --git a/README.txt b/README.txt
index d8424a0..2bbd47a 100644
--- a/README.txt
+++ b/README.txt
@@ -391,14 +391,14 @@ SELF DEFINING PROCEDURES AND FUNCTIONS
foo; # Here the procedure foo will redefine bar again!
Functions
- A function should be defined with the func keyword and deleted with the
+ A function should be defined with the fun keyword and deleted with the
undef keyword. Function not yet return values (will be changed in future
versions) and supports not yet parameter passing (will be changed in
future versions). It's using local (lexical scoped) variables. If a
certain variable does not exist It's using already defined variables
(e.g. one scope above).
- func foo {
+ fun foo {
say 1 + a * 3 + b;
my c = 6;
}
@@ -413,8 +413,8 @@ SELF DEFINING PROCEDURES AND FUNCTIONS
exception that nested functions will not be available any more after the
function has been left!
- func foo {
- func bar {
+ fun foo {
+ fun bar {
say "Hello i am nested";
}
diff --git a/docs/pod/fype.html b/docs/pod/fype.html
index e6f14b2..dab05c2 100644
--- a/docs/pod/fype.html
+++ b/docs/pod/fype.html
@@ -545,9 +545,9 @@ keyword in order to check if a procedure has been defined or not.</p>
<p>
</p>
<h2><a name="functions">Functions</a></h2>
-<p>A function should be defined with the <strong>func</strong> keyword and deleted with the <strong>undef</strong> keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).</p>
+<p>A function should be defined with the <strong>fun</strong> keyword and deleted with the <strong>undef</strong> keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).</p>
<pre>
- func foo {
+ fun foo {
say 1 + a * 3 + b;
my c = 6;
}</pre>
@@ -561,8 +561,8 @@ keyword in order to check if a procedure has been defined or not.</p>
<h2><a name="nested_functions">Nested functions</a></h2>
<p>Nested functions work the same way the nested procedures work, with the exception that nested functions will not be available any more after the function has been left!</p>
<pre>
- func foo {
- func bar {
+ fun foo {
+ fun bar {
say &quot;Hello i am nested&quot;;
}</pre>
<pre>
diff --git a/docs/pod/fype.man b/docs/pod/fype.man
index 886cc70..81c73f2 100644
--- a/docs/pod/fype.man
+++ b/docs/pod/fype.man
@@ -533,7 +533,7 @@ keyword in order to check if a procedure has been defined or not.
A function should be defined with the \fBfunc\fR keyword and deleted with the \fBundef\fR keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).
.PP
.Vb 4
-\& func foo {
+\& fun foo {
\& say 1 + a * 3 + b;
\& my c = 6;
\& }
@@ -548,8 +548,8 @@ A function should be defined with the \fBfunc\fR keyword and deleted with the \f
Nested functions work the same way the nested procedures work, with the exception that nested functions will not be available any more after the function has been left!
.PP
.Vb 4
-\& func foo {
-\& func bar {
+\& fun foo {
+\& fun bar {
\& say "Hello i am nested";
\& }
\&
diff --git a/docs/pod/fype.pod b/docs/pod/fype.pod
index 9282136..98c58ba 100644
--- a/docs/pod/fype.pod
+++ b/docs/pod/fype.pod
@@ -454,9 +454,9 @@ keyword in order to check if a procedure has been defined or not.
=head2 Functions
-A function should be defined with the B<func> keyword and deleted with the B<undef> keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).
+A function should be defined with the B<fun> keyword and deleted with the B<undef> keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).
- func foo {
+ fun foo {
say 1 + a * 3 + b;
my c = 6;
}
@@ -470,8 +470,8 @@ A function should be defined with the B<func> keyword and deleted with the B<und
Nested functions work the same way the nested procedures work, with the exception that nested functions will not be available any more after the function has been left!
- func foo {
- func bar {
+ fun foo {
+ fun bar {
say "Hello i am nested";
}
diff --git a/docs/pod/fype.tex b/docs/pod/fype.tex
index 4dd7f2f..adebf54 100644
--- a/docs/pod/fype.tex
+++ b/docs/pod/fype.tex
@@ -518,10 +518,10 @@ keyword in order to check if a procedure has been defined or not.
\subsection*{Functions\label{Functions}\index{Functions}}
-A function should be defined with the \textbf{func} keyword and deleted with the \textbf{undef} keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).
+A function should be defined with the \textbf{fun} keyword and deleted with the \textbf{undef} keyword. Function not yet return values (will be changed in future versions) and supports not yet parameter passing (will be changed in future versions). It's using local (lexical scoped) variables. If a certain variable does not exist It's using already defined variables (e.g. one scope above).
\begin{verbatim}
- func foo {
+ fun foo {
say 1 + a * 3 + b;
my c = 6;
}
@@ -539,8 +539,8 @@ A function should be defined with the \textbf{func} keyword and deleted with the
Nested functions work the same way the nested procedures work, with the exception that nested functions will not be available any more after the function has been left!
\begin{verbatim}
- func foo {
- func bar {
+ fun foo {
+ fun bar {
say "Hello i am nested";
}
\end{verbatim}
diff --git a/docs/pod/fype.txt b/docs/pod/fype.txt
index d8424a0..2bbd47a 100644
--- a/docs/pod/fype.txt
+++ b/docs/pod/fype.txt
@@ -391,14 +391,14 @@ SELF DEFINING PROCEDURES AND FUNCTIONS
foo; # Here the procedure foo will redefine bar again!
Functions
- A function should be defined with the func keyword and deleted with the
+ A function should be defined with the fun keyword and deleted with the
undef keyword. Function not yet return values (will be changed in future
versions) and supports not yet parameter passing (will be changed in
future versions). It's using local (lexical scoped) variables. If a
certain variable does not exist It's using already defined variables
(e.g. one scope above).
- func foo {
+ fun foo {
say 1 + a * 3 + b;
my c = 6;
}
@@ -413,8 +413,8 @@ SELF DEFINING PROCEDURES AND FUNCTIONS
exception that nested functions will not be available any more after the
function has been left!
- func foo {
- func bar {
+ fun foo {
+ fun bar {
say "Hello i am nested";
}
diff --git a/examples/all-examples.txt b/examples/all-examples.txt
index 6e02967..f1a81b8 100644
--- a/examples/all-examples.txt
+++ b/examples/all-examples.txt
@@ -205,13 +205,13 @@ ifnot pid {
# Test: function named arguments, explicit ret, and multiple return values
# zero-arg function with explicit return
-func answer() {
+fun answer() {
ret 42;
}
assert 42 == say answer();
# single-arg function — factorial with a while loop and ret
-func factorial(n) {
+fun factorial(n) {
my result = 1;
while n > 1 {
result = result * n;
@@ -222,13 +222,13 @@ func factorial(n) {
assert 120 == say factorial(5);
# two-arg function
-func add(a, b) {
+fun add(a, b) {
ret a + b;
}
assert 8 == say add(3, 5);
# conditional return inside if
-func absval(n) {
+fun absval(n) {
if n < 0 { ret neg n; }
ret n;
}
@@ -236,14 +236,14 @@ assert 5 == say absval(5);
assert 5 == say absval(neg 5);
# multiple return values — both land on the caller's stack
-func minmax(a, b) {
+fun minmax(a, b) {
if a < b { ret a, b; }
ret b, a;
}
say minmax(3, 7);
# old-style zero-arg function without parens still works
-func greet {
+fun greet {
say "hello";
}
greet;
@@ -252,10 +252,10 @@ greet;
* Examples of how to use functions
*#
-func foo {
+fun foo {
say 1 + a * 3 + b;
- func bar {
+ fun bar {
say "Hello i am nested";
}
@@ -266,7 +266,7 @@ my a = 2, b = 4; # Create global variables
foo;
assert 0 == (defined bar); # bar is not available anymore
-func baz {
+fun baz {
say "I am baz";
undef baz;
}
diff --git a/examples/func_args_ret.fy b/examples/func_args_ret.fy
index 54088e8..2039501 100644
--- a/examples/func_args_ret.fy
+++ b/examples/func_args_ret.fy
@@ -1,13 +1,13 @@
# Test: function named arguments, explicit ret, and multiple return values
# zero-arg function with explicit return
-func answer() {
+fun answer() {
ret 42;
}
assert 42 == say answer();
# single-arg function — factorial with a while loop and ret
-func factorial(n) {
+fun factorial(n) {
my result = 1;
while n > 1 {
result = result * n;
@@ -18,13 +18,13 @@ func factorial(n) {
assert 120 == say factorial(5);
# two-arg function
-func add(a, b) {
+fun add(a, b) {
ret a + b;
}
assert 8 == say add(3, 5);
# conditional return inside if
-func absval(n) {
+fun absval(n) {
if n < 0 { ret neg n; }
ret n;
}
@@ -32,14 +32,14 @@ assert 5 == say absval(5);
assert 5 == say absval(neg 5);
# multiple return values — both land on the caller's stack
-func minmax(a, b) {
+fun minmax(a, b) {
if a < b { ret a, b; }
ret b, a;
}
say minmax(3, 7);
# old-style zero-arg function without parens still works
-func greet {
+fun greet {
say "hello";
}
greet;
diff --git a/examples/functions.fy b/examples/functions.fy
index 15856a0..c5e51e2 100644
--- a/examples/functions.fy
+++ b/examples/functions.fy
@@ -2,10 +2,10 @@
* Examples of how to use functions
*#
-func foo {
+fun foo {
say 1 + a * 3 + b;
- func bar {
+ fun bar {
say "Hello i am nested";
}
@@ -16,7 +16,7 @@ my a = 2, b = 4; # Create global variables
foo;
assert 0 == (defined bar); # bar is not available anymore
-func baz {
+fun baz {
say "I am baz";
undef baz;
}
diff --git a/fype b/fype
index f63e84b..3f518c5 100755
--- a/fype
+++ b/fype
Binary files differ
diff --git a/src/build.h b/src/build.h
index 9125e92..5029024 100644
--- a/src/build.h
+++ b/src/build.h
@@ -36,7 +36,7 @@
#ifndef BUILD_H
#define BUILD_H
-#define BUILDNR 9680
+#define BUILDNR 9682
#define OS_LINUX
#endif
diff --git a/src/core/token.c b/src/core/token.c
index ea72a82..17f98b2 100644
--- a/src/core/token.c
+++ b/src/core/token.c
@@ -59,7 +59,7 @@ get_tt(char *c_token) {
CHECK("ret") TT_RET;
CHECK("const") TT_CONST;
CHECK("proc") TT_PROC;
- CHECK("func") TT_FUNC;
+ CHECK("fun") TT_FUNC;
CHECK("my") TT_MY;
CHECK("arr") TT_ARR;
CHECK("!") TT_NOT;