Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[svn:perl6-synopsis] r13587 - doc/trunk/design/syn

4 views
Skip to first unread message

la...@cvs.perl.org

unread,
Feb 15, 2007, 4:04:59 PM2/15/07
to perl6-l...@perl.org
Author: larry
Date: Thu Feb 15 13:04:59 2007
New Revision: 13587

Modified:
doc/trunk/design/syn/S02.pod
doc/trunk/design/syn/S04.pod
doc/trunk/design/syn/S12.pod

Log:
Split statement_modifier category in two.
List comprehensions can now be done with statement modifiers.
Multiple dispatch now explained in terms of topological sort.
Multiple dispatch with single semicolons clarified, maybe. However, multis
with single semicolon are likely just a reserved syntax in 6.0.0.


Modified: doc/trunk/design/syn/S02.pod
==============================================================================
--- doc/trunk/design/syn/S02.pod (original)
+++ doc/trunk/design/syn/S02.pod Thu Feb 15 13:04:59 2007
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <la...@wall.org>
Date: 10 Aug 2004
- Last Modified: 13 Feb 2007
+ Last Modified: 15 Feb 2007
Number: 2
- Version: 87
+ Version: 88

This document summarizes Apocalypse 2, which covers small-scale
lexical items and typological issues. (These Synopses also contain
@@ -2768,7 +2768,8 @@
scope_declarator:<has> has $.x;
statement_prefix:<gather> gather for @foo { .take }
statement_control:<if> if $condition {...} else {...}
- statement_modifier:<if> ... if $condition
+ statement_mod_cond:<if> ... if $condition
+ statement_mod_loop:<for> ... for 1..10
infix_prefix_meta_operator:<!> $x !~~ 2;
infix_postfix_meta_operator:<=> $x += 2;
postfix_prefix_meta_operator:{'»'} @array »++

Modified: doc/trunk/design/syn/S04.pod
==============================================================================
--- doc/trunk/design/syn/S04.pod (original)
+++ doc/trunk/design/syn/S04.pod Thu Feb 15 13:04:59 2007
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <la...@wall.org>
Date: 19 Aug 2004
- Last Modified: 11 Feb 2007
+ Last Modified: 15 Feb 2007
Number: 4
- Version: 52
+ Version: 53

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
@@ -188,16 +188,29 @@
...
}

-Conditional statement modifiers work as in Perl 5. So do the
-implicit conditionals implied by short-circuit operators.
-
If the final statement is a conditional which does not execute any
branch, the return value is C<undef> in item context and C<()> in
list context.

+Conditional statement modifiers work as in Perl 5. So do the
+implicit conditionals implied by short-circuit operators. Note though that
+the first expression within parens or brackets is parsed as a statement,
+so you can say:
+
+ @x = 41, (42 if $answer), 43;
+
+and that is equivalent to:
+
+ @x = 41, ($answer ?? 42 !! ()), 43
+
=head1 Loop statements

-Looping statement modifiers are the same as in Perl 5.
+Looping statement modifiers are the same as in Perl 5 except that,
+for ease of writing list comprehensions, a looping statement modifier
+is allowed to contain a single conditional statement modifier:
+
+ @evens = ($_ * 2 if .odd for 0..100);
+
Loop modifiers C<next>, C<last>, and C<redo> also work as in Perl 5.

There is no longer a C<continue> block. Instead, use a C<NEXT> block

Modified: doc/trunk/design/syn/S12.pod
==============================================================================
--- doc/trunk/design/syn/S12.pod (original)
+++ doc/trunk/design/syn/S12.pod Thu Feb 15 13:04:59 2007
@@ -12,9 +12,9 @@

Maintainer: Larry Wall <la...@wall.org>
Date: 27 Oct 2004
- Last Modified: 9 Feb 2007
+ Last Modified: 15 Feb 2007
Number: 12
- Version: 40
+ Version: 41

=head1 Overview

@@ -788,6 +788,19 @@
a final tie-breaking proto sub is called, if there is one (see above).
Otherwise an exception is thrown.

+The order in which candidates are considered is defined by a
+topological sort based on the "type narrowness" of each candidate's
+long name, where that in turn depends on the narrowness of each
+parameter that is participating. Identical types are considered tied.
+Parameters whose types are not comparable are also considered tied.
+A candidate is considered narrower than another candidate if at least
+one of its parameters is narrower and all the rest of its parameters
+are either narrower or tied. This defines the partial ordering of
+all the candidates. If the topological sort detects a circularity in
+the partial ordering, all candidates in the circle are considered tied.
+A warning will be issued at C<CHECK> time if this is detected and there is
+no default candidate to fall back to.
+
Ordinarily all the parameters of a multi sub are considered for dispatch.
Here's a declaration for an integer range operator with two parameters
in its long name:
@@ -807,17 +820,27 @@
Note that a call to the routine must still be compatible with
subsequent arguments.

-However, a given multi may advertise multiple long names, some
-of which are shorter than the complete long name. This is done by
-putting a semicolon after each advertised long name (replacing the comma,
-if present). The initial dispatch starts by pretending that the shortest
-advertised long name is the complete long name (and likewise across the entire
-set of candidates). Since the shorter long name does not guarantee uniqueness,
-if that shorter long name is chosen for dispatch, and a tie would be
-declared for that dispatch, the next longer set of long names may be
-used to break ties, for those candidates that supply longer names.
-(As a limiting case, putting a semicolon after every parameter produces
-dispatch semantics like Common Lisp.)
+[Conjecture: However, a given multi may advertise multiple long names,
+some of which are shorter than the complete long name. This is done
+by putting a semicolon after each advertised long name (replacing
+the comma, if present). A semicolon has the effect of inserting two
+candidates into the list. One of them is inserted with exactly the
+same types, as if the semicolon were a comma. The other is inserted
+as if all the types after the semicolon were of type Any, which puts
+it later in the list than the narrower actual candidate. This merely
+determines its sort order; the candidate uses its real type signature
+if the dispatcher gets to it after rejecting all earlier entries on the
+candidate list. If that set of delayed candidates also contains ties,
+then additional semicolons have the same effect within that sublist
+of ties. Note, however, that semicolon is a no-op if the types after
+it are all C<Any>. (As a limiting case, putting a semicolon after
+every parameter produces dispatch semantics much like Common Lisp.
+And putting a semicolon after only the first argument is much like
+ordinary single-dispatch methods.) Note: This single-semicolon syntax
+is merely to be considered reserved until we understand the semantics
+of it, and more importantly, the pragamatics of it (that is, whether
+it has any valid use case). Until then only the double-semicolon
+form will be implemented in the standard language.]

Within a class, C<multi submethod> is visible to both method-dispatch
and subroutine-dispatch. A C<multi method> never participates in the
@@ -871,8 +894,8 @@

=head1 Multi dispatch

-Multi submethods work just like multi subs except they are constrained
-to an exact type match on the invocant.
+Multi submethods work just like multi methods except they are constrained
+to an exact type match on the invocant, just as ordinary submethods are.

Perl 6.0.0 is not required to support multiple dispatch on named parameters,
only on positional parameters. Note that most builtins will map known
@@ -880,7 +903,7 @@

Within a multiple dispatch, C<next METHOD> means to try the next best
match, or next best default in case of tie, or the proto sub if there
-is one.
+is one. The C<nextsame> function has the same effect.

Attributes are tied to a particular class definition, so a multi method
can only directly access the attributes of a class it's defined within
@@ -896,9 +919,11 @@

The syntax for calling back to C<MyClass> is C<$obj!MyClass::meth()>.

-The C<sub> keyword is optional after either C<multi> or C<proto>.
+The C<sub> keyword is optional immediately after a C<proto>, C<multi>,
+or C<only> keyword.

-A C<proto> declaration must come before any matching multis, if at all.
+A C<proto> declaration may not occur after a C<multi> declaration in the
+same scope.

=head1 Roles

0 new messages