From 982e35bd0bd9bc9b55c0f898556c3e1831141258 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 19 Oct 2008 00:12:57 +0000 Subject: synonyms work --- examples/synonyms.fy | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 examples/synonyms.fy (limited to 'examples') diff --git a/examples/synonyms.fy b/examples/synonyms.fy new file mode 100644 index 0000000..3ffb105 --- /dev/null +++ b/examples/synonyms.fy @@ -0,0 +1,32 @@ +#* + * 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; + -- cgit v1.2.3