Skip to content

Commit

Permalink
Merge remote-tracking branch 'perl6'
Browse files Browse the repository at this point in the history
  • Loading branch information
skids committed Feb 12, 2012
2 parents ea4ee96 + d28c8ef commit 9bef5dc
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 286 deletions.
14 changes: 6 additions & 8 deletions S03-operators.pod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Synopsis 3: Perl 6 Operators

Created: 8 Mar 2004

Last Modified: 23 Jan 2012
Version: 236
Last Modified: 6 Feb 2012
Version: 238

=head1 Overview

Expand Down Expand Up @@ -3625,6 +3625,7 @@ as a default because the more specific types listed above it didn't match.
Any Callable:($) item sub truth X($_)
Any Callable:() simple closure truth X() (ignoring $_)
Any Bool simple truth X
Any Match match success X
Any Numeric numeric equality +$_ == X
Any Stringy string equality ~$_ eq X
Any Whatever always matches True
Expand Down Expand Up @@ -3653,8 +3654,6 @@ as a default because the more specific types listed above it didn't match.
Array Regex array "boolean grep" .any.match(X)
Any Regex pattern match .match(X)

Any Match identity $_

Num Range in numeric range X.min <= $_ <= X.max (mod ^'s)
Str Range in string range X.min le $_ le X.max (mod ^'s)
Any Range in generic range [!after] X.min,$_,X.max (etc.)
Expand Down Expand Up @@ -3707,7 +3706,6 @@ the table assumes the following types will behave similarly:
or generic type binding Type
Char Cat Str
Int UInt etc. Num
Match Capture
Byte Str or Int
Buf Str or Array of Int

Expand Down Expand Up @@ -4430,7 +4428,7 @@ a reduction operator really is a list prefix, and is invoked as one.
Hence, you can implement a reduction operator in one of two ways. Either
you can write an explicit list operator:

proto prefix:<[+]> (*@args) {
multi prefix:<[+]> (*@args) is default {
my $accum = 0;
while (@args) {
$accum += @args.shift();
Expand Down Expand Up @@ -4464,8 +4462,8 @@ together, just as if you had written it out explicitly:

If fewer than two arguments are given, a dispatch is still attempted
with whatever arguments are given, and it is up to the receiver of that
dispatch to deal with fewer than two arguments. Note that the proto
list operator definition is the most general, so you are allowed to define
dispatch to deal with fewer than two arguments. Note that the default
list operator signature is the most general, so you are allowed to define
different ways to handle the one argument case depending on type:

multi prefix:<[foo]> (Int $x) { 42 }
Expand Down
1 change: 1 addition & 0 deletions S05-regex.pod
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,7 @@ represents the top node of an abstract syntax tree, the abstract object
may be extracted from the C<Match> object by use of the C<.ast> method.

A second call to C<make> overrides any previous call to C<make>.
C<make> is also available as a method on each match object.

Within a closure, the instantaneous
position within the search is denoted by the C<$¢.pos> method.
Expand Down
2 changes: 1 addition & 1 deletion S12-objects.pod
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ enumeration type itself.
~Fri # 'Fri' (only for numeric enums)
Fri.Stringy # 'Fri' (only for numeric enums)
Fri.Str # 'Fri' (only for numeric enums)
Fri.gist # 'Day::Fri' (used by say)
Fri.gist # 'Fri' (used by say)
Fri.key # 'Fri'
Fri.value # 5
Fri.pair # :Fri(5)
Expand Down
4 changes: 2 additions & 2 deletions S13-overloading.pod
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ is better written:
A class may define methods that allow it to respond as if it were a
routine, array, or hash. The long forms are as follows:

method postcircumfix:<( )> ($capture) {...}
method postcircumfix:<( )> (|capture) {...}
method postcircumfix:<[ ]> (**@slice) {...}
method postcircumfix:<{ }> (**@slice) {...}

Those are a bit unwieldy, so you may also use these short forms:

method &.( $capture ) {...}
method &.( |capture ) {...}
method @.[ **@slice ] {...}
method %.{ **@slice } {...}

Expand Down
54 changes: 27 additions & 27 deletions S29-functions.pod
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ an embedded interpreter, all memory must also be reclaimed.

=item sleep

our Num multi sleep ( Num $for = Inf )
multi sleep ( Num $for = Inf --> Num )

Attempt to sleep for up to C<$for> seconds. Implementations are obligated
to support sub-second resolutions if that is at all possible.
Expand Down Expand Up @@ -287,7 +287,7 @@ the exception.

=item bless

our Object method bless(Object::RepCandidate $candidate, *@protos, *%init_args)
method bless($candidate, *@protos, *%init_args )

Calling C<bless> on any invocant (but typically a type object) to create a new
object with the same class as the invocant.
Expand Down Expand Up @@ -347,27 +347,27 @@ but only the first character will be translated.

=item item

our Item multi item ( $item )
multi item ( $item --> Item )

Forces generic Item context on its argument, and returns it.

=item list

our List multi list ( Iterable $item ) { $item.iterator.list }
our List multi list ( List \$iter ) { $iter }
multi list ( Iterable $item --> List ) { $item.iterator.list }
multi list ( List \$iter --> List ) { $iter }

Almost a no-op; just makes sure that $item can be iterated.

=item flat

our List multi flat ( *@list )
multi flat ( *@list --> List )

Forces flat context on its arguments, and returns them.
The heavy work is done by the C<*@> binding.

=item lol

our List multi lol ( **@list )
multi lol ( **@list --> List )

Forces the argument list to be evaluated in lol ("list of lists") context.
(Subscripts treat such a list of lists as a multidimensional slice.)
Expand All @@ -379,7 +379,7 @@ See also the more general C<.tree> method, which defaults to C<lol> semantics.

The C<hash> contextualizer

our Hash multi hash ( *@list )
multi hash ( *@list --> Hash )

Forces the argument list to be evaluated in hash context.
The expression is evaluated in list context (flattening any C<Capture>s),
Expand All @@ -391,8 +391,8 @@ empty C<hash()> means an empty hash).

=item gist

our Str multi gist( |$item )
our Str multi method gist( Mu $item: )
multi gist( |$item --> Str )
multi method gist( Mu $item: --> Str )

Produces an informal string coercion, something a human might want
to see if debugging, for instance. Each type may decide its own
Expand All @@ -410,10 +410,10 @@ to a printer. C<:-)>

=item :16, :8, :2, :10

our Num multi prefix:<:16> ( Str $hexstr )
our Num multi prefix:<:8> ( Str $octstr )
our Num multi prefix:<:2> ( Str $binstr )
our Num multi prefix:<:10> ( Str $decstr )
multi prefix:<:16> ( Str $hexstr --> Num )
multi prefix:<:8> ( Str $octstr --> Num )
multi prefix:<:2> ( Str $binstr --> Num )
multi prefix:<:10> ( Str $decstr --> Num )
etc.

Interprets string as a number, with a default
Expand Down Expand Up @@ -442,10 +442,10 @@ Replaces Perl 5 C<hex> and C<oct>.

=item gethost

our OS::Name multi gethost()
our OS::Name multi gethost( Str $name, OS::Addfamily :$type )
our OS::Name multi method gethost( OS::Addr $addr: ) is export
our OS::Name multi method gethost( URI $uri: ) is export
multi gethost( --> OS::Name )
multi gethost( Str $name, OS::Addfamily :$type --> OS::Name )
multi method gethost( OS::Addr $addr: --> OS::Name ) is export
multi method gethost( URI $uri: --> OS::Name ) is export

The C<gethost> function operates on host naming or address information
and returns an C<OS::Name>. An C<OS::Name> is, minimally:
Expand Down Expand Up @@ -479,7 +479,7 @@ Examples:

=item chroot

our Bool multi chroot ( Str $path = CALLER::<$_> )
multi chroot ( Str $path = CALLER::<$_> --> Bool )

On POSIX systems, changes the process context of the current process such
that the "root" directory becomes C<$path> and all rooted paths
Expand All @@ -490,15 +490,15 @@ true on success.

=item getlogin

our Str multi getlogin ()
multi getlogin ( --> Str )

Returns the username of the account running the program. This may
not be as secure as using C<getpwuid> on some platforms.

=item kill

our Bool multi kill ( OS::Signal $signal, Bool :$group, *@pids )
our Bool multi method kill ( Proc::PID $pid: OS::Signal $signal?, Bool :$group )
multi kill ( OS::Signal $signal, Bool :$group, *@pids --> Bool )
multi method kill ( Proc::PID $pid: OS::Signal $signal?, Bool :$group --> Bool )

Sends the given C<$signal> to the process(es) given and returns a boolean
value indicating success (true) if all of the processes existed and were
Expand Down Expand Up @@ -534,8 +534,8 @@ signal at all, and is used to determine if processes are still running:
=item shell


our Proc::Status multi shell ( $expression, :$bg, :%env = %*ENV )
our Proc::Status multi run ( *$cmd, *@args, :$bg, :%env = %*ENV )
multi shell ( $expression, :$bg, :%env = %*ENV --> Proc::Status )
multi run ( *$cmd, *@args, :$bg, :%env = %*ENV --> Proc::Status )

C<shell> and C<run> execute an external program, and return control to
the caller once the program has exited.
Expand Down Expand Up @@ -594,7 +594,7 @@ tools

=item fork

our Proc sub Processes::fork()
sub Processes::fork( --> Proc )

Creates a copy of the current process. Both processes return from
C<fork>. The original process returns
Expand All @@ -618,9 +618,9 @@ Typical usage would be:

=item wait

our Proc::Status multi method wait( Proc $process: *%options )
multi method wait( Proc $process: *%options --> Proc::Status )

our Proc::Status multi wait ( Proc $process = -1, *%options )
multi wait ( Proc $process = -1, *%options --> Proc::Status )

Waits for a child process to terminate and returns the status
object for the child. This status object will numify to the process
Expand Down
44 changes: 22 additions & 22 deletions S32-setting-library/Basics.pod
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ so edit it there in the git repository if you would like to make changes.
The following are defined in the C<Mu> role:

role Mu {
our Bool multi method defined ($self:) is export {...}
our Bool multi method defined ($self: ::role ) is export {...}
multi method defined ($self: --> Bool ) is export {...}
multi method defined ($self: ::role --> Bool ) is export {...}

our multi method undefine( $self: ) is export {...}
multi method undefine( $self: --> Any ) is export {...}

method not() {...}
method so() {...}
Expand All @@ -49,8 +49,8 @@ The following are defined in the C<Mu> role:

=item defined

our Bool multi method defined ( $self: ) is export
our Bool multi method defined ( $self: ::role ) is export
multi method defined ( $self: --> Bool ) is export
multi method defined ( $self: ::role --> Bool ) is export

C<defined> returns true if the parameter has a value and that value is
considered defined by its type, otherwise false is returned.
Expand All @@ -66,8 +66,8 @@ the type of the object.

=item undefine

our multi undefine( Any $thing )
our multi method undefine( Any $self )
multi undefine( Any $thing --> Any )
multi method undefine( Any $self --> Any )

Takes any variable as a parameter and attempts to "remove" its
definition. For simple scalar variables this means assigning
Expand Down Expand Up @@ -106,21 +106,21 @@ instantiate a C<Mu> it would be considered defined, and thus true.
The following are defined in the C<Any> role:

role Any does Mu does Pattern {
our multi method clone (::T $self --> T) {...}
our multi method clone (::T $self, *%attributes --> T) {...}

our Callable multi method can ($self:, Str $method) {...}
our Bool multi method does ($self:, $type) {...}
our Bool multi method isa ($self:, $type) {...}
our Str multi method perl ( Mu $o: ) is export {...}
our multi method warn ( Mu $o: ) is export {...}
multi method clone (::T $self --> T --> Any ) {...}
multi method clone (::T $self, *%attributes --> T --> Any ) {...}

multi method can ($self:, Str $method --> Callable ) {...}
multi method does ($self:, $type --> Bool ) {...}
multi method isa ($self:, $type --> Bool ) {...}
multi method perl ( Mu $o: --> Str ) is export {...}
multi method warn ( Mu $o: --> Any ) is export {...}
}

=over

=item can

our Callable multi method can ($self:, Str $method)
multi method can ($self:, Str $method --> Callable )

If there is a multi method of name C<$method> that can be called on
C<$self>, then a closure is return which has C<$self> bound to the position
Expand All @@ -130,8 +130,8 @@ Otherwise an undefined value is returned.

=item clone

our multi method clone (::T $self --> T)
our multi method clone (::T $self, *%attributes --> T)
multi method clone (::T $self --> T --> Any )
multi method clone (::T $self, *%attributes --> T --> Any )

The first variant returns an independent copy of C<$o> that is equivalent
to C<$o>.
Expand All @@ -141,27 +141,27 @@ attribute during the cloning process.

=item does

our Bool multi method does ($self:, $type)
multi method does ($self:, $type --> Bool )

Returns C<True> if and only if C<$self> conforms to type C<$type>.

=item isa

our Bool multi method isa ($self:, $type)
multi method isa ($self:, $type --> Bool )

Returns C<True> if a the invocant an instance of class C<$type>, or
of a subset type or a derived class (through inheritance) of C<$type>.

=item perl

our Str multi method perl ( Mu $o: ) is export
multi method perl ( Mu $o: --> Str ) is export

Returns a perlish representation of the object, so that calling C<eval>
on the returned string reproduces the object as accurately as possible.

=item warn

our multi method warn ( Mu $o: ) is export
multi method warn ( Mu $o: --> Any ) is export

Throws a resumable warning exception, which is considered a control
exception, and hence is invisible to most normal exception handlers.
Expand Down
Loading

0 comments on commit 9bef5dc

Please sign in to comment.