Re: Anonymous multi-subs

2015-06-24 Thread Jon Lang
On Wednesday, June 24, 2015, yary not@gmail.com wrote:

 Now that I've thought about it for 90 seconds (not fully-formed idea), if
 one were to have an anonymous multi-sub, it ought to be constructed from a
 list of *signature*, *body *pairs.

 And/or, any non-finalized sub could have a method to add another *signature,
 body* to its dispatch list.

 apologies if this discussion is already captured in a design doc, I am
 posting this without having read much of the past.


 Or, in the body, be able to examine the actual signature passed in and
decide what to do based on that,  That [i]could[/i] be done using a
given/when structure, which would be equivalent to a list of signature/body
pairs.


-- 
Jonathan Dataweaver Lang


[perl6/specs] a964d4: Fix typo

2015-06-24 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: a964d4bd6aa84919a21e0d5c160968e8c31279ab
  
https://github.com/perl6/specs/commit/a964d4bd6aa84919a21e0d5c160968e8c31279ab
  Author: Rob Hoelz r...@hoelz.ro
  Date:   2015-06-23 (Tue, 23 Jun 2015)

  Changed paths:
M S32-setting-library/IO.pod

  Log Message:
  ---
  Fix typo




[perl6/specs] 65be12: Add a note about list operator flattening.

2015-06-24 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: 65be12770be696034dd41a363ba3804ea9beab4a
  
https://github.com/perl6/specs/commit/65be12770be696034dd41a363ba3804ea9beab4a
  Author: pmichaud pmich...@pobox.com
  Date:   2015-06-23 (Tue, 23 Jun 2015)

  Changed paths:
M S07-glr-draft.pod

  Log Message:
  ---
  Add a note about list operator flattening.




[perl6/specs] e337b9: Propose Str.substr(Range)

2015-06-24 Thread GitHub
  Branch: refs/heads/substr-range
  Home:   https://github.com/perl6/specs
  Commit: e337b938b442a6f5a3070081180972b9f9f01d1e
  
https://github.com/perl6/specs/commit/e337b938b442a6f5a3070081180972b9f9f01d1e
  Author: Rob Hoelz r...@hoelz.ro
  Date:   2015-06-24 (Wed, 24 Jun 2015)

  Changed paths:
M S32-setting-library/Str.pod

  Log Message:
  ---
  Propose Str.substr(Range)




[perl6/specs] 2b0a47: Fix typos

2015-06-24 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: 2b0a478b42a0cd18b635e998415c0bd56300e54c
  
https://github.com/perl6/specs/commit/2b0a478b42a0cd18b635e998415c0bd56300e54c
  Author: Rob Hoelz r...@hoelz.ro
  Date:   2015-06-23 (Tue, 23 Jun 2015)

  Changed paths:
M S32-setting-library/IO.pod

  Log Message:
  ---
  Fix typos




Re: Anonymous multi-subs

2015-06-24 Thread Brent Laabs
I'll just note that you can fake anon multi subs with lexical subs like
this:

my $sub = do {
proto foo (|) { * }
multi foo (Int $x) { $x + 1 }
multi foo (Str $y) { $y ~ 'a' }

foo;
}

say $sub(hello);

The sub there is still named foo as attested by $sub.name, but isn't
available under that name outside of the do block.


On Wed, Jun 24, 2015 at 2:27 PM, Jon Lang datawea...@gmail.com wrote:



 On Wednesday, June 24, 2015, yary not@gmail.com wrote:

 Now that I've thought about it for 90 seconds (not fully-formed idea), if
 one were to have an anonymous multi-sub, it ought to be constructed from a
 list of *signature*, *body *pairs.

 And/or, any non-finalized sub could have a method to add another *signature,
 body* to its dispatch list.

 apologies if this discussion is already captured in a design doc, I am
 posting this without having read much of the past.


  Or, in the body, be able to examine the actual signature passed in and
 decide what to do based on that,  That [i]could[/i] be done using a
 given/when structure, which would be equivalent to a list of signature/body
 pairs.


 --
 Jonathan Dataweaver Lang



[perl6/specs] 64b65b: Revise note about list operator flattening.

2015-06-24 Thread GitHub
  Branch: refs/heads/master
  Home:   https://github.com/perl6/specs
  Commit: 64b65ba84f83dba7843d4c29fadb7ebcee16ce89
  
https://github.com/perl6/specs/commit/64b65ba84f83dba7843d4c29fadb7ebcee16ce89
  Author: pmichaud pmich...@pobox.com
  Date:   2015-06-23 (Tue, 23 Jun 2015)

  Changed paths:
M S07-glr-draft.pod

  Log Message:
  ---
  Revise note about list operator flattening.




Re: Types for Perl 6: request for comments

2015-06-24 Thread yary
I'm reading it a bit at a time on lunch break, thanks for sending it along,
it's educational.

My comments here are all about the example on the top of page 5, starting
with the minutest. First a typo, it says subC where it should say sumC

multi sub sumB is ambiguous, due to your use of ;; there. And sumI
*should* be ambiguous, because the caller sumC(Int $x ;; $y) {sumI($x,$y)}
means sumI will always be called with $x - Int and varying $y. That
example could use a little re-working.

Note to Rakudo-porters: Can the error message remember the ;; in the
sig ? The message from Rakudo * has a ,  where the source has ;; which
is misleading:
Ambiguous call to 'sumB'; these signatures all match:
:(Bool $y, Bool $x)
:(Bool $y, Int $x)

The comment  example about considering anonymous multi definitions in the
same block to define the same anonymous function does show the feature's
desirability, but that proposed syntax might be problematic. (Deciding if 
how to make that part of the syntax is not in the scope of the paper, but
since you brought it up) What if one wants to define two different
anonymous multi subs in the same scope? A contrived example:

sub pick_multi (Bool $p) {
  my multi sub hmmI(Int $y) { 2 * $y }
  my multi sub hmmI(Bool $y) { $y }

  my multi sub hmmB(Int $y) { 1 + $y  }
  my multi sub hmmB(Bool $y) { ! $y }

  $p ?? hmmI !! hmmB
}

Yes, one could enclose each anon-multi-set in a do block, but it feels to
me that defining an anonymous multi-sub should require a single statement,
to avoid unintentional co-mingling within a block.


Anonymous multi-subs

2015-06-24 Thread yary
Now that I've thought about it for 90 seconds (not fully-formed idea), if
one were to have an anonymous multi-sub, it ought to be constructed from a
list of *signature*, *body *pairs.

And/or, any non-finalized sub could have a method to add another *signature,
body* to its dispatch list.

apologies if this discussion is already captured in a design doc, I am
posting this without having read much of the past.

and now, back to our regularly scheduled programming.

-y