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

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

4 views
Skip to first unread message

aud...@cvs.perl.org

unread,
Oct 5, 2006, 12:16:27 AM10/5/06
to perl6-l...@perl.org
Author: audreyt
Date: Wed Oct 4 21:16:26 2006
New Revision: 12675

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

Log:
* S12: Remove the troublesome single-arg-function-become-method rule:

sub foo (*$x) { $x }
foo(want); # Always in list context, never evaluated as "want.foo"

As an alternative solution to the "close $fh" problem, specify that
class IO has a "method close () is export" that manufactures a multi
sub-into-method dispatcher.

The export-method semantics needs more detailed treatment in the spec,
but it's important to note that "somesub $x" and "$x.somesub" are no
longer interchangeable now.


Modified: doc/trunk/design/syn/S12.pod
==============================================================================
--- doc/trunk/design/syn/S12.pod (original)
+++ doc/trunk/design/syn/S12.pod Wed Oct 4 21:16:26 2006
@@ -14,7 +14,7 @@
Date: 27 Oct 2004
Last Modified: 20 Sept 2006
Number: 12
- Version: 27
+ Version: 28

=head1 Overview

@@ -196,18 +196,24 @@
Indirect object notation now requires a colon after the invocant if
there are any arguments. If there are no arguments and you omit the
colon, the notation is parsed either as a named unary operator or a
-list operator with one argument. In any case, all of these come out
-to the same thing:
+list operator with one argument.
+
+These two are considered method calls, which will fall back to a
+subroutine call if the method was not found:

$handle.close
- close($handle)
close $handle:
- close $handle

-To explicitly reject method call and only consider subs, put a
-trailing comma after the single positional argument:
+To reject method call and only consider subs, simply omit the colon
+from the invocation line:

- close($handle,)
+ close($handle)
+ close $handle
+
+However, here the built-in B<IO> class defines C<method close is export ()>,
+which puts a C<multi sub close (IO)> in scope by default. Thus if the
+C<$handle> evaluates to an IO object, then the two subroutine calls above
+are still translated into method calls.

Dot notation can omit the invocant if it's in C<$_>:

0 new messages