summaryrefslogtreecommitdiff
path: root/examples/procedures.fy
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2009-10-30 14:54:34 +0000
committerPaul Buetow <paul@buetow.org>2009-10-30 14:54:34 +0000
commit1542ff3a3927916c23dabffff9533b58f63f4b54 (patch)
tree4a34357fc9723d4f65daa3b5a5de4099bcfd7424 /examples/procedures.fy
parent9eb12638e152d981492382cb534edb89a8625990 (diff)
parent1bc73e78278b630768723869d277d05404feae03 (diff)
Diffstat (limited to 'examples/procedures.fy')
-rw-r--r--examples/procedures.fy30
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/procedures.fy b/examples/procedures.fy
new file mode 100644
index 0000000..cbe2121
--- /dev/null
+++ b/examples/procedures.fy
@@ -0,0 +1,30 @@
+#*
+ * Examples of how to use procedures
+ *#
+
+proc foo {
+ say 1 + a * 3 + b;
+ my c = 6;
+}
+
+my a = 2, b = 4;
+
+foo; # Run the procedure. Print out "11\n"
+say c; # Print out "6\n";
+
+proc bar {
+ say "I am bar";
+
+ undef baz;
+
+ proc baz {
+ say "I am baz";
+ }
+}
+
+# Here bar would produce an error because the proc is not yet defined!
+# bar;
+
+bar; # Here the procedure bar will define the procedure baz!
+baz; # Now the procedure baz is defined!
+bar; # Here the procedure bar will redefine baz again!