Special variables: Difference between revisions

→‎{{header|Raku}}: limit list of 'special variables' to those currently supported
m (→‎{{header|Raku}}: Fix link to docs)
(→‎{{header|Raku}}: limit list of 'special variables' to those currently supported)
Line 1,647:
::foo package/module/class/role/subset/enum/type/grammar</lang>
Sigils indicate overall interface, not the exact type of the bound object. Different sigils imply different minimal abilities. Ordinary sigils indicate normally scoped variables, either lexical or package scoped. Oddly scoped variables include a secondary sigil (a twigil) that indicates what kind of strange scoping the variable is subject to:
<lang perl6> $foo # ordinary scoping
$.foo # object attribute public accessor
$^foo # self-declared formal positional parameter
$:foo # self-declared formal named parameter
$*foo # dynamically overridable global variable
$?foo # compiler hint variable
$=foo # PodPOD variable
$<foo> # match variable, short for $/{'foo'}
$!foo # object attribute private storage
$~foo # the foo sublanguage seen by the parser at this lexical spot</lang>
 
A selection (not comprehensive) of Raku's automatically set and/or pre-defined compile-time and run-time variables.
Special Variables:
 
<lang perl6># Lexical variables
Raku has deprecated most of the "line-noise" variables from Perl 5 in favor of named variables.
 
<lang perl6> $_ # The # implicit variable lexically scoped to the current block
$?ROLE! # current roleException object
@_ # Implicit array of parameters to the current block. Still available but rarely used or needed with the improved sub signatures
$!/ # Current Exception# last objectmatch
$/0, $1, $2... # captured values from match: $/[0], $/[1], #$/[2] Last match...
 
$0, $1, $2... # Captured values from match: $/[0], $/[1], $/[2] ...
# Compile-time variables
$?ARCH # Host architecture
 
$?XARCH # Target architecture
@*ARGS$?PACKAGE # command-linecurrent argumentspackage
$*ARGFILES?CLASS # The magic command-line input handle # current class
&$?BLOCKMODULE # current block (itself)module
::$?CLASSROLE # current class (as package or# typecurrent name)role
$?CLASSDISTRIBUTION # which OS distribution #am I currentcompiling classunder
@=COMMENT$?FILE # All the comment blocks in the# current filename of source file
%$?CONFIGLINE # configurationcurrent line number in hashsource file
$*CWD &?ROUTINE # current workingsub or method directory(itself)
$=DATA&?BLOCK # datacurrent block handle (=begin DATA ... =enditself)
 
@=DATA # Same as above, but array
# Dynamic variables
%?DEEPMAGIC # Controls the mappings of magical names to sub definitions
 
$?DISTRO # Which OS distribution am I compiling under
$*DISTROUSAGE # Which OS distribution am# value of the Iauto-generated runningUSAGE undermessage
$*EGIDPROGRAM-NAME # path to the current # effective group idexecutable
$*PROGRAM_NAMEPROGRAM # namelocation (in the form of an IO::Path object) of the Raku program being executed
%*ENV # system environment variables
$@*ERRARGS # Standard error# command-line handlearguments
$*EUID ARGFILES # effectivethe magic command-line userinput idhandle
$?PACKAGE*CWD # current packageworking directory
$*EXECUTABLE_NAME # executable name
$?FILE*DISTRO # currentwhich OS distribution filenameam ofI sourcerunning fileunder
$?GRAMMAR%*ENV # currentsystem environment grammarvariables
$*GIDERR # groupstandard error idhandle
$*EXECUTABLE-NAME # name of the Raku executable that is currently running
$*IN # Standard input handle; is an IO object
$*EXECUTABLE # IO::Path absolute path of the Raku executable that is currently running
@*INC # where to search for user modules (but not std lib!)
$?KERNEL*IN # operatingstandard input handle; is systeman compiledIO forobject
$*KERNEL # operating system running under
%?LANG$*OUT # What is the current set# ofstandard interwovenoutput languages?handle
$*LANGRAKU # LANG variable from %*ENV that defines what# humanRaku languageversion isrunning usedunder
$?LINE*PID # current line number in# system sourceprocess fileid
%$*META-ARGSTZ # Meta-argumentslocal time zone
$?MODULE*USER # currentsystem user moduleid
 
%*OPTS # Options from command line
# Run-time variables
%*OPT... # Options from command line to be passed down
 
$*OUT # Standard output handle
$*COLLATION # object that can be used to configure Unicode collation levels
$?PACKAGE # current package
$*TOLERANCE # used by the =~= operator to decide if two values are approximately equal
$*RAKU # Raku version running under
$*DEFAULT-READ-ELEMS # affects the number of bytes read by default by IO::Handle.read</lang>
$*PID # system process id
%=POD # POD
$*PROGRAM_NAME # name of the Raku program being executed
%*PROTOCOLS # Stores the methods needed for the uri() function
::?ROLE # current role (as package or type name)
$?ROLE # current role
&?ROUTINE # current sub or method (itself)
$?SCOPE # Current "my" scope
$*TZ # Local time zone
$*UID # system user id
$?USAGE # Default usage message generated at compile time
$?VM # Which virtual machine am I compiling under
$?XVM # Which virtual machine am I cross-compiling for</lang>
 
Also, not really a variable but...
2,392

edits