Author: lwall
Date: 2009-09-07 20:32:55 +0200 (Mon, 07 Sep 2009)
New Revision: 28201
Modified:
docs/Perl6/Spec/S06-routines.pod
Log:
[S06] remove the slightly non-sensical 'use GLOBAL' in favor of 'defines'
Modified: docs/Perl6/Spec/S06-routines.pod
===================================================================
--- docs/Perl6/Spec/S06-routines.pod 2009-09-07 18:03:22 UTC (rev 28200)
+++ docs/Perl6/Spec/S06-routines.pod 2009-09-07 18:32:55 UTC (rev 28201)
@@ -15,8 +15,8 @@
Created: 21 Mar 2003
- Last Modified: 31 Aug 2009
- Version: 113
+ Last Modified: 7 Sep 2009
+ Version: 114
This document summarizes Apocalypse 6, which covers subroutines and the
@@ -270,20 +270,27 @@
may be made directly visible by importation.
Global subroutines and variables are normally referred to by prefixing
-their identifiers with C<*> (short for "C<GLOBAL::>").
+their identifiers with the C<*> twigil, to allow contextual overrides.
- $*next_id = 0;
+ GLOBAL::<$next_id> = 0;
sub GLOBAL::saith($text) { print "Yea verily, $text" }
module A {
my $next_id = 2; # hides any global or package $next_id
&*saith($next_id); # print the lexical $next_id;
- &*saith($*next_id); # print the global $next_id;
+ &*saith($*next_id); # print the dynamic $next_id;
}
+To disallow contextual overrides, you must access the globals directly:
+
+ GLOBAL::saith($GLOBAL::next_id);
+
+The fact that this is verbose is construed to be a feature. Alternately,
+you may play aliasing tricks like this:
+
module B {
- use GLOBAL <$next_id>;
- &*saith($next_id); # Unambiguously the global $next_id
+ GLOBAL defines <&saith $next_id>;
+ saith($next_id); # Unambiguously the global definitions
}
=head2 Dynamically scoped subroutines
@@ -2532,8 +2539,8 @@
require COMPILING <$x $y $z>;
-Note that you need to use the run-time C<:=> and C<require> forms, not C<::=>
-and C<use>, because the macro caller's compile-time is the macro's runtime.
+Note that you need to use the run-time C<require> form, not
+C<use>, because the macro caller's compile-time is the macro's runtime.
=head2 Splicing