summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-10-19 00:24:01 +0000
committerPaul Buetow <paul@buetow.org>2008-10-19 00:24:01 +0000
commitd4657a5d7029ea66d19a5d238a9dd6bf75fe5bb0 (patch)
treebb9201b68004fd5957a2e2dead3e1038fc23cfd1 /examples
parent982e35bd0bd9bc9b55c0f898556c3e1831141258 (diff)
jo
Diffstat (limited to 'examples')
-rw-r--r--examples/all-examples.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/all-examples.txt b/examples/all-examples.txt
index bdf199f..b438de3 100644
--- a/examples/all-examples.txt
+++ b/examples/all-examples.txt
@@ -297,6 +297,39 @@ assert 0 == (say defined bar);
#*
+ * Examples of how to use synonyms
+ *#
+
+# Create a variable foo, and bar is a synonym for foo
+my foo = "foo";
+my bar = \foo;
+
+# Reset the value of foo
+foo = "bar";
+
+# The synonym variable should now also set to "bar"
+assert "bar" == say bar;
+
+# Create a new procedure baz
+proc baz {
+ say "I am baz";
+}
+
+# Make a synonym baz, and undefine baz
+my bay = \baz;
+undef baz;
+
+# bay still has a reference of the original procedure baz
+bay; # this prints aut "I am baz"
+
+assert 0 == defined baz;
+assert 1 == defined bay;
+
+# This removes the procedure from memory
+undef bay;
+
+
+#*
* Examples how to convert types
*#