Created
March 28, 2009 19:53
-
-
Save mberends/87185 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> | |
<html xmlns="http://www.w3.org/1999/xhtml"><head> | |
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> | |
<title>S28-special-names.pod</title> | |
<style type="text/css"> | |
h1 { font-family: Sans; } | |
table { } | |
td { vertical-align: top; } | |
td#pod { border-style: solid; width: 100%; } | |
td#pod > pre { font-size: 8pt; } | |
</style> | |
<title>test</title></head><body> | |
<h1>S28-special-names.pod</h1> | |
Path: <a href="http://autoexec.demon.nl:2080/">(root)</a> / | |
<a href="http://autoexec.demon.nl:2080/home">home</a> / | |
<a href="http://autoexec.demon.nl:2080/home/rakudo">rakudo</a> / | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs">pugs</a> / | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs">docs</a> / | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6">Perl6</a> / | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec">Spec</a><br> | |
<table><tbody><tr> | |
<td> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S32-setting-library">S32-setting-library/</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S01-overview.pod">S01-overview.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S02-bits.pod">S02-bits.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S03-operators.pod">S03-operators.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S04-control.pod">S04-control.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S05-regex.pod">S05-regex.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S06-routines.pod">S06-routines.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S07-iterators.pod">S07-iterators.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S09-data.pod">S09-data.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S10-packages.pod">S10-packages.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S11-modules.pod">S11-modules.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S12-objects.pod">S12-objects.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S13-overloading.pod">S13-overloading.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S14-roles-and-parametric-types.pod">S14-roles-and-parametric-types.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S16-io.pod">S16-io.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S17-concurrency.pod">S17-concurrency.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S19-commandline.pod">S19-commandline.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S21-calling-foreign-code.pod">S21-calling-foreign-code.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S22-package-format.pod">S22-package-format.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S26-documentation.pod">S26-documentation.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S28-special-names.pod">S28-special-names.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S29-functions.pod">S29-functions.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/S31-pragmatic-modules.pod">S31-pragmatic-modules.pod</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/update">update</a><br> | |
<a href="http://autoexec.demon.nl:2080/home/rakudo/pugs/docs/Perl6/Spec/update.bat">update.bat</a><br> | |
</td> | |
<td id="pod"> | |
<style type="text/css"> | |
code { font-size:large; font-weight:bold; } | |
h1 { font-family:helvetica,sans-serif; font-weight:bold; } | |
h2 { font-family:helvetica,sans-serif; font-weight:bold; } | |
pre { font-size: 10pt; background-color: lightgray; border-style: solid; | |
border-width: 1px; padding-left: 1em; } | |
</style> | |
<h1>Name</h1> | |
<pre> | |
[DRAFT] Synopsis 28 - Special Names [DRAFT] | |
</pre> | |
<h1>Version</h1> | |
<pre> | |
Author: Larry Wall <[email protected]> | |
Maintainer: Larry Wall <[email protected]> | |
Contributions: Tim Nelson <[email protected]> | |
Date: 23 Feb 2009, created by Tim Nelson from miscellaneous documents lying around | |
Last Modified: 25 Feb 2009 | |
Version: 5 | |
</pre> | |
<h1>Special Variables</h1> | |
<h2>Introduction</h2> | |
<p>This document serves as a collection point for what is known about | |
special variables in Perl 6 and correlates them with the changes from Perl | |
5. </p> | |
<p>If you are trying to find the Perl 6 equivalent of a Perl 5 special | |
variable you know, try searching this file for the Perl 5 version. Each | |
main entry is followed by a note containing the corresponding Perl 5 | |
variable(s). The list of main entries is also followed by a table showing | |
the 5 and 6 variables side-by-side.</p> | |
<h2>Overview</h2> | |
<h3>Secondary Sigils (also known as "twigils")</h3> | |
<p>A quick reminder of the relevant twigils from S02:</p> | |
<pre> | |
$?foo # Compiler constants (fixed at compile time) | |
$*foo # Context variable, default global (run time) | |
$=foo # File-scoped POD data | |
</pre> | |
<p>The various <code>$?foo</code> variables are determined at compile time, | |
and are not modifiable at run time. This does not mean that the variable | |
has the same value everywhere; for instance, <code>$?LINE</code> is | |
different on every line of the program.</p> | |
<p>The <code>$*foo</code> variables function both as dymamically scoped | |
variables and as globals. Globalness is relative, in other words. Any | |
dynamic scope may modify the set of globals visible via the <code>$*foo | |
</code> notation. Most of the standard globals listed below actually live | |
either in the <code>PROCESS</code> or the <code>GLOBAL</code> package, | |
where <code>PROCESS</code> contains globals belonging to the entire | |
process, while <code>GLOBAL</code> contains the globals belonging to the | |
current interpreter, since a process may be running more than one | |
interpreter. Unless otherwise indicated below, the outermost definition of | |
these variables are kept in the <code>PROCESS</code>package.</p> | |
<p>The <code>$=foo</code> variables are related to the the <code>$?foo | |
</code> variables insofar as the text of the program is known at compile | |
time, so the values are static. However, the different twigil indicates | |
that the variable contains POD data, which is primarily under user control | |
rather than compiler control. The structure of these variables will be | |
fleshed out in S26.</p> | |
<h3>Named variables</h3> | |
<pre> | |
Variable Spec Type Description | |
-------- ---- ---- ----------- | |
</pre> | |
<pre> | |
@_ # ??? | |
$! S04 # Current Exception object | |
$/ S05 Match # Last match | |
$0, $1, $2 S05 Str # First captured value from match: $/[0] | |
$?ARCH SoftwarePackage # Host architecture | |
$?XARCH SoftwarePackage # Target architecture | |
@*ARGS S06 Array of Str # command-line arguments | |
$*ARGFILES S02 IO # The magic command-line input handle | |
&?BLOCK S06 Block # current block (itself) | |
::?CLASS S12 Str # current class (as package or type name) | |
$?CLASS S02 Class # current class | |
@=COMMENT (S26) # All the comment blocks in the file | |
%?CONFIG Hash of XXX # configuration hash XXX What does this do? | |
$=DATA (S26) IO # data block handle (=begin DATA ... =end) | |
@=DATA (S26) Array # Same as above, but array | |
%?DEEPMAGIC S13 Hash of XXX # Controls the mappings of magical names to sub definitions | |
$?DISTRO S02 SoftwarePackage # Which OS distribution am I compiling under | |
$*DISTRO S02 SoftwarePackage # Which OS distribution am I running under | |
$*EGID Int # effective group id | |
%*ENV S02 Hash of Str # system environment variables | |
$*ERR S16 IO # Standard error handle | |
$*EUID Int # effective user id | |
$*EXECUTABLE_NAME Str # executable name | |
$?FILE S02 Str # current filename of source file | |
$?GRAMMAR S02 Grammar # current grammar | |
$*GID Int # group id | |
$*IN S16 IO # Standard input handle; is an IO object | |
$*INC S11 # where to search for user modules (but not std lib!) | |
$?LANG S02 # Which Perl parser should embedded closures parse with? | |
$*LANG S02 Str # LANG variable from %*ENV that defines what human language is used | |
$?LINE S02 Int # current line number in source file | |
%*META-ARGS S19 Hash of XXX # Meta-arguments | |
$?MODULE S02 Module # current module | |
%*OPTS S19 Hash of XXX # Options from command line | |
%*OPT... S19 Hash of XXX # Options from command line to be passed down | |
$?KERNEL SoftwarePackage # operating system compiled for | |
$*KERNEL SoftwarePackage # operating system running under | |
$*OUT S16 IO # Standard output handle | |
$?PARSER S02 Grammar # Which Perl grammar was used to parse this statement? | |
$?PACKAGE S02 Package # current package | |
$?PERL S02 SoftwarePackage # Which Perl am I compiled for? | |
$*PERL S02 SoftwarePackage # perl version running under | |
$*PID Int # system process id | |
%=POD S02 # (or some such) | |
$*PROGRAM_NAME S19 Str # name of the Perl program being executed | |
%*PROTOCOLS S16 Hash of Method # Stores the methods needed for the uri() function | |
::?ROLE Str # current role (as package or type name) | |
$?ROLE S02 Role # current role | |
&?ROUTINE S06 Routine # current sub or method (itself) | |
$?SCOPE S02 # Current "my" scope (XXX unnecessary?) | |
$*UID Int # system user id | |
$?USAGE S06 Str # Default usage message generated at compile time | |
$?VM S02 SoftwarePackage # Which virtual machine am I compiling under | |
$?XVM S02 SoftwarePackage # Which virtual machine am I cross-compiling for | |
</pre> | |
<p>Note that contextual variables such as <code>$*OUT</code> may have more | |
than one current definition in the outer dynamic context, in which case the | |
innermost dynamic scope determines the meaning. For instance, <code> | |
$PROCESS::OUT</code> is the stdout for the entire process, but each | |
interpreter can set its own <code>$GLOBAL::OUT</code> to make <code>$*OUT | |
</code> mean whatever it wants independently of other interpreters. Any | |
dynamic scope may also declare a local meaning of <code>$*OUT</code> that | |
applies only to called code. Likewise each thread could log its own errors | |
to its own <code>$*ERR</code>, since a thread is a dynamic scope.</p> | |
<h2>Special Classes</h2> | |
<p>These are classes defined especially for the benefit of the Special | |
Variables. </p> | |
<pre> | |
class SoftwarePackage { | |
has Str $name; | |
has Version $version; | |
} | |
</pre> | |
<p>This class is intended to represent a software package at a fairly basic | |
level. </p> | |
<h3>Perl5 to Perl6 special variable translation</h3> | |
<p>If a column has a "-" in it, it means that item is unavailable in that | |
version of Perl. </p> | |
<pre> | |
Perl 5 Perl 6 Comment | |
----------- ----------- ----------------------- | |
STDIN $*IN See S16; actual variable is $PROCESS::IN | |
STDOUT $*OUT See S16; actual variable is $PROCESS::OUT | |
STDERR $*ERR See S16; actual variable is $PROCESS::ERR | |
$_ $ARG $_ More lexically aware | |
$_[1],$_[2].. $^a,$^b.. | |
$a,$b - Just params to anonymous block | |
- $/ Object with results of last regex match | |
$1,$2,$3... $1,$2,$3... | |
$& $MATCH $<> | |
$` $PREMATCH substr based on $/.from | |
$' $POSTMATCH substr based on $/.to | |
$+ - But info can now be retrieved from $/ | |
$^N $*MOST_RECENT_CAPTURED_MATCH ...or some such. | |
or $/[*-$n] ...or omit | |
@- $1.start, etc | |
@+ $1.end, etc. | |
%! - | |
$[ - This feature has been removed | |
$* - Deprecated long ago | |
$# - Deprecated long ago | |
$^H - These were only ever internal anyway | |
%^H - | |
- $! Current exception (see | |
S04-control | |
) | |
$! $ERRNO $OS_ERROR - Use shiny new $! | |
$? $CHILD_ERROR - Use shiny new $! | |
$@ $EVAL_ERROR - Use shiny new $! | |
$^E - Use shiny new $! | |
$^S - | |
$. $NR $*IN.input_record_number() | |
$/ $RS $*IN.input_record_separator() | |
$| $*OUT.autoflush() | |
$, $OFS $*OUT.output_field_separator() | |
$\ $*OUT.output_record_separator() | |
$" $LIST_SEPARATOR - | |
$; $SUBSEP - | |
$$ $PID $*PID | |
$< $UID $*UID Real UID (User ID) | |
$( $GID $*GID Real GID (Group ID) | |
$> $EUID $*EUID Effective UID | |
$) $EGID $*EGID Effective GID | |
$0 $PROGRAM_NAME $*PROGRAM_NAME | |
$^C $COMPILING $*COMPILING | |
$^D $DEBUGGING $*DEBUGGING | |
$^F $SYS_FD_MAX $*SYS_FD_MAX ...or some such | |
$^I $INPLACE_EDIT $*INPLACE_EDIT ...or some such | |
$^M $*EMERGENCY_MEMORY ...or some such (or omit) | |
$^O $OSNAME $*OSNAME ...or some such | |
$^P $PERLDB $*PERLDB ...or some such | |
$^R $*LAST_REGEXP_CODE_RESULT ...or some such. Or omit. | |
$^T $BASETIME $*INITTIME A Temporal::Instant object | |
$^V $] $?PERL.version | |
$^W $*WARNINGS (if any dynamic control needed) | |
${^WARNING_BITS} $?WARNINGS | |
$^X $*EXECUTABLE_NAME ...or some such | |
ARGV $*ARGS Note the P6 idiom for this handle: | |
for =$*ARGS { | |
# each time through loop | |
# proc a line from files named in ARGS | |
} | |
@ARGV @*ARGS | |
ARGVOUT TBD | |
$ARGV TBD | |
@F @_ | |
%ENV %*ENV | |
@INC @*INC (but not for std library modules) | |
%INC %*INC (maybe, if needed) | |
%SIG event filters plus exception translation | |
$SIG{__WARN__} $*ON_WARN | |
$SIG{__DIE__} $*ON_DIE | |
${^OPEN} - This was internal; forget it | |
<a href="http://perldoc.perl.org/S04-control.html">S04-control</a> | |
</pre> | |
<h2>NOT YET DEFINED</h2> | |
<p>The following items are not yet defined, but will need to be defined. | |
</p> | |
<p>XXX Don't remove this line until this section is completely blank. </p> | |
<p>We also seem to have $*INC in the table at the top, @*INC in S19 and the | |
table immediately above, %*INC also in the table above. </p> | |
<p>The $?LANG and $*LANG variables are also confusing (both in S02). </p> | |
<h3>Form.pm</h3> | |
<p>These go in the Perl5 to Perl6 conversion table:</p> | |
<pre> | |
Perl6 Perl5 | |
----- ----------------------------------------- | |
- $% $FORMAT_PAGE_NUMBER | |
- HANDLE->format_page_number(EXPR) | |
</pre> | |
<pre> | |
- $= $FORMAT_LINES_PER_PAGE | |
- HANDLE->format_lines_per_page(EXPR) | |
</pre> | |
<pre> | |
- $- $FORMAT_LINES_LEFT | |
- HANDLE->format_lines_left(EXPR) | |
</pre> | |
<pre> | |
- $~ $FORMAT_NAME | |
- HANDLE->format_name(EXPR) | |
</pre> | |
<pre> | |
- $^ $FORMAT_TOP_NAME | |
- HANDLE->format_top_name(EXPR) | |
</pre> | |
<pre> | |
- $: $FORMAT_LINE_BREAK_CHARACTERS | |
- IO::Handle->format_line_break_characters | |
</pre> | |
<pre> | |
- $^L $FORMAT_FORMFEED | |
- IO::Handle->format_formfeed | |
</pre> | |
<pre> | |
- $^A $ACCUMULATOR | |
</pre> | |
<h3>S15-unicode.pod</h3> | |
<p>${^ENCODING} variable -- S32/Str.pod implies this is $*ENC ${^UNICODE} | |
variable</p> | |
<h3>Infectious trait spec</h3> | |
<p>${^TAINT} variable, which is pending, among other things, infectious | |
trait spec</p> | |
<h1>Additions</h1> | |
<p>Please post errors and feedback to perl6-language. If you are making a | |
general laundry list, please separate messages by topic.</p> | |
<p>=for vim:set expandtab sw=4:</p> | |
</td> | |
</tr></tbody></table> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment