Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Addresses the non-indentityness of packages
Eliminates the wrong paragraph that included that, and adds an explanation and example to clarify that. Closes #2659
  • Loading branch information
JJ committed Mar 12, 2019
1 parent abbb9b5 commit da35fc7
Showing 1 changed file with 29 additions and 22 deletions.
51 changes: 29 additions & 22 deletions doc/Language/packages.pod6
Expand Up @@ -20,7 +20,7 @@ longer name that includes the namespace to disambiguate.
=head1 Names
A I<name> is anything that is a legal part of a variable name (not
A package I<name> is anything that is a legal part of a variable name (not
counting the sigil). This includes:
=begin code
Expand All @@ -45,6 +45,21 @@ $!; # certain punctuation variables
X<|::,package>
C<::> is used to separate nested package names.
Packages do not really have an identity; they can be simply part of a module or
class name, for instance. They are more similar to namespaces than to modules;
with a module of the same name I<capturing> the identity of a package if it
exists.
=begin code
package Foo:ver<0> {};
module Foo:ver<1> {};
say Foo.^ver; OUTPUT: «1␤»
=end code
The syntax allows the declared package to use a version, but as a matter of
fact, it's dismissed; only modules and classes have an identity that might
include C<auth> and C<ver>.
=head2 Package-qualified names
Ordinary package-qualified names look like this: C<$Foo::Bar::quux>,
Expand All @@ -60,13 +75,12 @@ alternate way to write this is:
(This does not work with the C<&zape> variable) The name is resolved at
compile time because the variable name is a constant.
If the name part before C<::> is null, it means the package is
unspecified and must be searched for. Generally this means that an
initial C<::> following the main sigil is a no-op on names that are
known at compile time, though C<::()> can also be used to introduce an
interpolation. Also, in the absence of another sigil, C<::> can serve as
its own sigil indicating intentional use of a not-yet-declared package
name.
If the name part before C<::> is null, it means the package is unspecified and
must be searched for. Generally this means that an initial C<::> following the
main sigil is a no-op on names that are known at compile time, though C<::()>
can also be used to introduce an interpolation. Also, in the absence of another
sigil, C<::> can serve as its own sigil indicating intentional use of a
not-yet-declared package name.
=head1 Pseudo-packages
Expand Down Expand Up @@ -116,13 +130,13 @@ the setting's outermost scope, use C<UNIT::OUTER> instead.
=head2 Interpolating into names
X<|interpolating into names>
X<|::()> You may L<interpolate|/language/packages#Interpolating> a string into a package or variable name
using C<::($expr)> where you'd ordinarily put a package or variable
name. The string is allowed to contain additional instances of C<::>,
which will be interpreted as package nesting. You may only interpolate
entire names, since the construct starts with C<::>, and either ends
immediately or is continued with another C<::> outside the parentheses.
Most symbolic references are done with this notation:
X<|::()> You may L<interpolate|/language/packages#Interpolating> a string into a
package or variable name using C<::($expr)> where you'd ordinarily put a package
or variable name. The string is allowed to contain additional instances of
C<::>, which will be interpreted as package nesting. You may only interpolate
entire names, since the construct starts with C<::>, and either ends immediately
or is continued with another C<::> outside the parentheses. Most symbolic
references are done with this notation:
=for code :skip-test
my $foo = "Foo";
Expand Down Expand Up @@ -243,13 +257,6 @@ go into that package by default. Process-wide variables live in the
C<PROCESS> package. Most predefined globals such as C<$*UID> and C<$*PID>
are actually process globals.
=head1 Version
X<|.^ver,package>
Any package may have a L<Version|/type/Version> object attached to it. This
object can be accessed via C<$?PACKAGE.^ver> or from outside the package
C<Fully::Qualified::Name.^ver>.
=end pod

# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6

0 comments on commit da35fc7

Please sign in to comment.