diff options
Diffstat (limited to 'docs/pod/fype.html')
| -rw-r--r-- | docs/pod/fype.html | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/docs/pod/fype.html b/docs/pod/fype.html index 02c30c4..6400295 100644 --- a/docs/pod/fype.html +++ b/docs/pod/fype.html @@ -38,7 +38,7 @@ </ul> <li><a href="#variables">VARIABLES</a></li> - <li><a href="#synonyms_to_variables_identifiers">SYNONYMS TO VARIABLES/IDENTIFIERS</a></li> + <li><a href="#synonyms">SYNONYMS</a></li> <li><a href="#built_in_functions">BUILT IN FUNCTIONS</a></li> <ul> @@ -311,7 +311,7 @@ not.</p> <p> </p> <hr /> -<h1><a name="synonyms_to_variables_identifiers">SYNONYMS TO VARIABLES/IDENTIFIERS</a></h1> +<h1><a name="synonyms">SYNONYMS</a></h1> <p>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:</p> <pre> my foo = "foo"; @@ -321,6 +321,28 @@ not.</p> # The synonym variable should now also set to "bar" assert "bar" == bar;</pre> <p>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.</p> +<pre> + # Create a new procedure baz + proc baz { say "I am baz"; }</pre> +<pre> + # Make a synonym baz, and undefine baz + my bay = \baz;</pre> +<pre> + undef baz;</pre> +<pre> + # bay still has a reference of the original procedure baz + bay; # this prints aut "I am baz"</pre> +<p>The <strong>syms</strong> keyword gives you the total number of synonyms pointing to a specific value:</p> +<pre> + my foo = 1; + say syms foo; # Prints 1</pre> +<pre> + my baz = \foo; + say syms foo; # Prints 2 + say syms baz; # Prints 2</pre> +<pre> + undef baz; + say syms foo; # Prints 1</pre> <p> </p> <hr /> |
