summaryrefslogtreecommitdiff
path: root/docs/pod/fype.pod
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-10-19 17:48:21 +0000
committerPaul Buetow <paul@buetow.org>2008-10-19 17:48:21 +0000
commit3d7b35bb37c066489546751e100c2c2b823ccba3 (patch)
treea507be11afc3c55807e254ce5b24c5412367aa46 /docs/pod/fype.pod
parentd4657a5d7029ea66d19a5d238a9dd6bf75fe5bb0 (diff)
refs and syms
Diffstat (limited to 'docs/pod/fype.pod')
-rw-r--r--docs/pod/fype.pod26
1 files changed, 25 insertions, 1 deletions
diff --git a/docs/pod/fype.pod b/docs/pod/fype.pod
index 2773c4e..1e29a6d 100644
--- a/docs/pod/fype.pod
+++ b/docs/pod/fype.pod
@@ -219,7 +219,7 @@ not.
say foo;
}
-=head1 SYNONYMS TO VARIABLES/IDENTIFIERS
+=head1 SYNONYMS
Each variable can have as many synonyms as wished. A synonym is another name to access the content of a specific variable. Here is an example of how to use synomyms:
@@ -232,6 +232,30 @@ Each variable can have as many synonyms as wished. A synonym is another name to
Synonyms can be used for all kind of identifiers. It's not limited to normal variables but can be also used for function and procedure names etc.
+ # 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"
+
+The B<syms> keyword gives you the total number of synonyms pointing to a specific value:
+
+ my foo = 1;
+ say syms foo; # Prints 1
+
+ my baz = \foo;
+ say syms foo; # Prints 2
+ say syms baz; # Prints 2
+
+ undef baz;
+ say syms foo; # Prints 1
+
+
=head1 BUILT IN FUNCTIONS
In Fype, operators are built in functions as well. The difference is, that they may be written in infix notation instead in front of the arguments. The types inside the () specify the return types.