Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
r11115 - doc/trunk/design/syn
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
la...@cvs.perl.org  
View profile  
 More options Aug 17 2006, 7:39 pm
Newsgroups: perl.perl6.language
From: la...@cvs.perl.org
Date: Thu, 17 Aug 2006 16:39:39 -0700 (PDT)
Local: Thurs, Aug 17 2006 7:39 pm
Subject: [svn:perl6-synopsis] r11115 - doc/trunk/design/syn
Author: larry
Date: Thu Aug 17 16:39:38 2006
New Revision: 11115

Modified:
   doc/trunk/design/syn/S06.pod

Log:
More old use of multiple invocant terminology changed to longnames.
Added mechanism for both short and long switch names.

Modified: doc/trunk/design/syn/S06.pod
=========================================================================== ===
--- doc/trunk/design/syn/S06.pod        (original)
+++ doc/trunk/design/syn/S06.pod        Thu Aug 17 16:39:38 2006
@@ -13,9 +13,9 @@

   Maintainer: Larry Wall <la...@wall.org>
   Date: 21 Mar 2003
-  Last Modified: 14 Aug 2006
+  Last Modified: 17 Aug 2006
   Number: 6
-  Version: 49
+  Version: 50

 This document summarizes Apocalypse 6, which covers subroutines and the
@@ -481,21 +481,10 @@
     print $obj.get_name();
     $obj.set_name("Sam");

-Multimethod and multisub invocants are specified at the start of the parameter
-list, with a colon terminating the list of invocants:
-
-    multi sub handle_event ($window, $event: $mode) {...}   # two invocants
-    multi method set_name ($self, $name: $nick) {...}       # two invocants
-
-If the parameter list for a C<multi> contains no colon to delimit
-the list of invocant parameters, then all positional parameters are
-considered invocants.  If it's a C<multi method> or C<multi submethod>,
-an additional implicit unnamed C<self> invocant is prepended to the
-signature list.
-
 For the purpose of matching positional arguments against invocant parameters,
 the invocant argument passed via the method call syntax is considered the
-first positional argument:
+first positional argument when failover happens from single dispatch to
+multiple dispatch:

     handle_event($w, $e, $m);   # calls the multi sub
     $w.handle_event($e, $m);    # ditto, but only if there is no
@@ -509,14 +498,28 @@
                             # fall-back to set_name($obj, "Sam")
     $obj.set_name("Sam");   # same as the above

-Passing too many or too few invocants is a fatal error if no matching
-definition can be found.
-
 An invocant is the topic of the corresponding method or multi if that
 formal parameter is declared with the name C<$_>.  A method's first
 invocant always has the alias C<self>.  Other styles of self can be
 declared with the C<self> pragma.

+=head2 Longname parameters
+
+Much like ordinary methods give preference to the invocant,
+multimethods and multisubs can give preference to earlier parameters.
+These are called I<longnames>; see S12 for more about the semantics
+of multiple dispatch.  Syntactically, longnames are declared by
+terminating the list of important parameters with a semicolon:
+
+    multi sub handle_event ($window, $event; $mode) {...}
+    multi method set_name ($self: $name; $nick) {...}
+
+If the parameter list for a C<multi> contains no semicolon to delimit
+the list of invocant parameters, then all positional parameters are
+considered invocants.  If it's a C<multi method> or C<multi submethod>,
+an additional implicit unnamed C<self> invocant is prepended to the
+signature list unless the first parameter is explicitly marked with a colon.
+

 =head2 Required parameters

@@ -2534,3 +2537,14 @@
 parameters, but still give you access to nested matches through those
 parameters, just as any C<Match> object would.  Of course, in this example,
 there's no particular reason the sub has to be named C<MAIN>.
+
+To give both a long and a short switch name, you may use the pair
+notation.  The key will be considered the short switch name, while
+the variable name will be considered the long switch name.  So if
+the previous declaration had been:
+
+    sub MAIN (:f($frompart), :t($topart), *@rest)
+
+then you could invoke the program with either C<-f> or C<--frompart>
+to specify the first parameter.  Likewise you could use either C<-t>
+or C<--topart> for the second parameter.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Markus Laire  
View profile  
 More options Aug 18 2006, 5:56 am
Newsgroups: perl.perl6.language
From: mala...@gmail.com (Markus Laire)
Date: Fri, 18 Aug 2006 12:56:30 +0300
Local: Fri, Aug 18 2006 5:56 am
Subject: Re: [svn:perl6-synopsis] r11115 - doc/trunk/design/syn
On 8/18/06, la...@cvs.perl.org <la...@cvs.perl.org> wrote:

> +To give both a long and a short switch name, you may use the pair
> +notation.  The key will be considered the short switch name, while
> +the variable name will be considered the long switch name.  So if
> +the previous declaration had been:
> +
> +    sub MAIN (:f($frompart), :t($topart), *@rest)
> +
> +then you could invoke the program with either C<-f> or C<--frompart>
> +to specify the first parameter.  Likewise you could use either C<-t>
> +or C<--topart> for the second parameter.

What about combined short switches like C<-abc> to mean C<-a -b -c>?
Will perl6 support this notation or not?

--
Markus Laire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Aug 18 2006, 11:24 am
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Fri, 18 Aug 2006 08:24:09 -0700
Local: Fri, Aug 18 2006 11:24 am
Subject: Re: [svn:perl6-synopsis] r11115 - doc/trunk/design/syn
On Fri, Aug 18, 2006 at 12:56:30PM +0300, Markus Laire wrote:

: What about combined short switches like C<-abc> to mean C<-a -b -c>?
: Will perl6 support this notation or not?

Hmm, that opens up a world of hurt.  Either you have to distinguish a
--abc from -abc, or you have to have some kind of fallback heuristic,
and it doesn't work terribly well with arguments in any case except
for the final one.  Should probably make it possible, just because the
external interface is one of the places where Perl has always tried
to be accommodating to existing culture rather than revisionist.
We can probably work something out here, along the lines of:

    if there's only one -
    if single character aliases are defined
    if the word matches that alphabet
    if the word doesn't match any longer names

At first I was inclined to say that if there's a *% then all the
unrecognized go in there and you can parse the -abc yourself, but
that doesn't tell you how to treat the next argument unless we look
at the definition of -c anyway.  We can't just say that -c's arg
must use the -c=arg form, since even Perl 5 violates that with -e.  :/

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Markus Laire  
View profile  
 More options Aug 18 2006, 12:53 pm
Newsgroups: perl.perl6.language
From: mala...@gmail.com (Markus Laire)
Date: Fri, 18 Aug 2006 19:53:14 +0300
Local: Fri, Aug 18 2006 12:53 pm
Subject: Re: [svn:perl6-synopsis] r11115 - doc/trunk/design/syn
On 8/18/06, Larry Wall <la...@wall.org> wrote:

Yep, I understand it's not an easy question.

Still I was thinking of behaviour where C<-abc> would allways mean
C<-a -b -c> regardless of what 1-char aliases or longer names have
been defined. This would make --abc and -abc mean completely different
things.

And in this proposal only the last switch would be able to get an
argument, e.g. with C<-abc=99> or C<-abc 99> or something like that.

If this can't be the default behaviour, then it would be nice to be
able to easily switch to this kind of behaviour.

ps. Then there's the perl5-behaviour of "perl -n0e unlink" where also
the intervening switches can get arguments. This could be expanded so
that all chars for which there's no 1-char alias defined, are
parameters. So C<-aHellobWorld> would mean C<-a=Hello -b=World> if
there are 1-char aliases only for a & b. ;)

--
Markus Laire


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Aug 18 2006, 1:26 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Fri, 18 Aug 2006 10:26:29 -0700
Local: Fri, Aug 18 2006 1:26 pm
Subject: Re: [svn:perl6-synopsis] r11115 - doc/trunk/design/syn
On Fri, Aug 18, 2006 at 07:53:14PM +0300, Markus Laire wrote:

: ps. Then there's the perl5-behaviour of "perl -n0e unlink" where also
: the intervening switches can get arguments. This could be expanded so
: that all chars for which there's no 1-char alias defined, are
: parameters. So C<-aHellobWorld> would mean C<-a=Hello -b=World> if
: there are 1-char aliases only for a & b. ;)

I think that safely falls into the category of completely psychotic.  @L@

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »