Larry Wall wrote:
I should point out that we're still contemplating breaking .foo() so it
no longer means $_.foo().  I wish there were more keys on my keyboard...

What is the status of my proposal to reserve the indirect object syntax for calls on $_ and the .method form for the invocant in (single)methods? Thus .method *always* expands to $?SELF which of course isn't available outside of method definitions.

This postfix colon call syntax has to go with a new syntax for landing sites
into code positions like we have goto for jumping out. I proposed to call
the goto partner 'land' but it could also be the enter function which
defines the entry points into a block, calling the ENTER blocks if
coming from the outside or so. Typical entry points that come to mind
are before/after parameter (type) check. BTW, does goto call all LEAVE
blocks that are left and all ENTER blocks that are entered? If not all,
which ones are picked?

Then the example becomes

given open 'mailto:[EMAIL PROTECTED]' {
        say: (...); # space needed to avoid &say:(...) syntax?
        close: or fail; # or even 'close or fail'
}

This postfix colon syntax is basically needed only if a different entry
point into the dispatch of e.g. close shall be taken. A plain close starts
from MMD, while close: starts from namespace scoped single dispatch on $_
and fails over to MMD. Either syntax '$_.close' and 'close $_:' is already
valid and both need more chars when interpolated: "$_.close()" or "{$_.close}"
and "{close $_:}".

But some whitespace rules are needed to disambiguate

method: option; #1

from

method :option; #2a

and

method:option; #2b

Case #1 calls method on $_ with the return value of option,
while cases #2 call method with adverbial modifier option set
to true.

A nice extension that also saves the trailing ; is to say that
a single indirect method call in a line autoterminates or some such.
I mean to warp the postfix colon indirect object syntax into doing
double duty as statement separator. Well, actually the
semicolon is half a colon in that respect :)

Then we get:

given baz()    # $_ := baz() or with temp?
{
   bar:        # $_.bar()
   blubb:      # $_.blubb()
   whatever:   # $_.whatever()
}

and

method foo()    # foo( $?SELF: )
{
   .bar;        # $?SELF.bar()
   .blubb;      # $?SELF.blubb()
   .whatever;   # $?SELF.whatever()
}

and combined:

method foo()    # foo( $?SELF: )
{
 # given foo() works syntactically but could recurse infinitly
   given baz() # temp $_ := baz()
   {
      .bar;       # $?SELF.bar()
      blubb:      # $_.blubb()
      .whatever:  # MMD whatever( $?SELF, $_: )
   }
}

BTW, are the two method examples valid without a surrounding class scope?
I think it's not strictly needed because foo would be added to class Any.

Hmm, this would also produce:

$obj.method $foo, $bar: $x, $y, $z;

to mean

method( $obj, $foo, $bar: $x, $y, $z );

and of course

$obj.method: $x, $y, $z;

means

method( $obj, $_: $x, $y, $z );
--
TSa (Thomas Sandlaß)




Reply via email to