Re: subset problem

2016-09-30 Thread mimosinnet

El Saturday, 17 de September del 2016 a les 10:21, MT va escriure:


Btw the following has the same problem;

> my Hash $h = {a=>1,b=>2}
{a => 1, b => 2}
> $h:exists
True
> subset mh of Str where $h{$_}:exists
(mh)
> my mh $x = 'b'
Type check failed in assignment to $x; expected mh but got Str ("b")
  in block  at  line 1



And:

my Hash $h = {a=>1,b=>2};

{a => 1, b => 2}

subset mh of Str where $h{$_}:exists;my mh $x = 'b'

b

:O ;-)

Cheers!


I can’t help but think this can all be solved by using enums?

my enum pv (  );
my pv $x = aa;


??


On 16 Sep 2016, at 13:49, mt1957  wrote:

Hi everyone,

I am trying to create a subset but get errors when used. Surely I do something 
wrong here or is it a bug?

In REPL


my Map $p .= new(.kv.reverse);

Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))

subset pv of Str where $_ (elem) $p;

(pv)

my pv $x = 'aa';

Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce





--
(≧∇≦) Mimosinnet (Linux User: #463211)

(≧∇≦) Ningún Lugar

★ Activisme Cultural per a la Transformació Social

(≧∇≦) Fractalitats en Investigació Crítica

* Investigació Crítica per a la Transformació Social
* http://psicologiasocial.uab.es/fic



Re: What are variables/parameters that start with a pipe | char

2016-09-30 Thread Brandon Allbery
On Fri, Sep 30, 2016 at 10:22 PM, Francis (Grizzly) Smit  wrote:

> I keep finding stuff like this:
>
> multi method spurt(IO::Path:D: Blob $contents, :$bin, |c)multi method 
> spurt(IO::Path:D: Cool $contents, :$bin, |c)
>
>
> but I cannot find the |c syntax in the docs I have googled but no good
> a pointer or link would be good.
>
>
You are looking for captures:
https://docs.perl6.org/type/Signature#Capture_Parameters

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: What are variables/parameters that start with a pipe | char

2016-09-30 Thread Francis (Grizzly) Smit



On 01/10/16 12:22, Francis (Grizzly) Smit wrote:


I keep finding stuff like this:

multi  method  spurt(IO::Path:D:  Blob  $contents, :$bin, |c)
multi  method  spurt(IO::Path:D:  Cool  $contents, :$bin, |c)


but I cannot find the |c syntax in the docs I have googled but no good
a pointer or link would be good.


sorry to bother you I found what I need

https://docs.perl6.org/type/Signature#Capture_Parameters

https://docs.perl6.org/type/Capture

--

   .~. In my life God comes first
   /V\ but Linux is pretty high after that :-D
  /( )\Francis (Grizzly) Smit
  ^^-^^http://www.smit.id.au/
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GM/CS/H/P/S/IT/L d- s+:+ a++ C UL$ P+++ L+++$ E--- W+++
N w--- M-- V-- PE- PGP t+ 5-- X-- R- tv b DI(+) D-
G e++ h+ y? r% z---
--END GEEK CODE BLOCK--
http://www.geekcode.com/



What are variables/parameters that start with a pipe | char

2016-09-30 Thread Francis (Grizzly) Smit

I keep finding stuff like this:

multi  method  spurt(IO::Path:D:  Blob  $contents, :$bin, |c)
multi  method  spurt(IO::Path:D:  Cool  $contents, :$bin, |c)


but I cannot find the |c syntax in the docs I have googled but no good
a pointer or link would be good.


--

   .~. In my life God comes first
   /V\ but Linux is pretty high after that :-D
  /( )\Francis (Grizzly) Smit
  ^^-^^http://www.smit.id.au/
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GM/CS/H/P/S/IT/L d- s+:+ a++ C UL$ P+++ L+++$ E--- W+++
N w--- M-- V-- PE- PGP t+ 5-- X-- R- tv b DI(+) D-
G e++ h+ y? r% z---
--END GEEK CODE BLOCK--
http://www.geekcode.com/



Re: What are variables/parameters that start with a pipe | char

2016-09-30 Thread Francis (Grizzly) Smit



On 01/10/16 12:27, Brandon Allbery wrote:
On Fri, Sep 30, 2016 at 10:22 PM, Francis (Grizzly) Smit 
> wrote:


I keep finding stuff like this:

multi  method  spurt(IO::Path:D:  Blob  $contents, :$bin, |c)
multi  method  spurt(IO::Path:D:  Cool  $contents, :$bin, |c)


but I cannot find the |c syntax in the docs I have googled but no good
a pointer or link would be good.


You are looking for captures: 
https://docs.perl6.org/type/Signature#Capture_Parameters


--
brandon s allbery kf8nh sine nomine associates
allber...@gmail.com  
ballb...@sinenomine.net 

unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net


Thx I found it on my own, finally googled the right thing

--

   .~. In my life God comes first
   /V\ but Linux is pretty high after that :-D
  /( )\Francis (Grizzly) Smit
  ^^-^^http://www.smit.id.au/
-BEGIN GEEK CODE BLOCK-
Version: 3.1
GM/CS/H/P/S/IT/L d- s+:+ a++ C UL$ P+++ L+++$ E--- W+++
N w--- M-- V-- PE- PGP t+ 5-- X-- R- tv b DI(+) D-
G e++ h+ y? r% z---
--END GEEK CODE BLOCK--
http://www.geekcode.com/



[perl #129772] [LTA] error message when using int parameters as subs

2016-09-30 Thread via RT
# New Ticket Created by  Zoffix Znet 
# Please include the string:  [perl #129772]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=129772 >



If you accidentally use an `int` variable as a Callable, you get a  
helpful error:

  m: my int $i; $i()
  rakudo-moar 1f29cb: OUTPUT«No such method 'CALL-ME' for  
invocant of type 'Int'␤  in block  at  line 1␤␤»

However, that's not the case if the variable is a parameter:

  m: sub (int $i) { $i() }
  rakudo-moar 1f29cb: OUTPUT«===SORRY!===␤callee  
expression must be an object␤»

Most heinous issue is the line number/file of the issue is missing  
from the error message.



[perl #129768] [BUG] Wrong error message when (disallowed) positional slurpy with a default is preceded by named in Rakudo

2016-09-30 Thread Carl Mäsak
# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #129768]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=129768 >


 Hello :) So, wondering if anyone might know - in a parameter
signature, if you have a slurpy array (*@thing) -- is there a way to
define a default set of values for it, if nothing gets slurped up?
 sub MAIN ( Str :$log-file = 'blah', Bool :$thing = False,
@srcDirs = ('/tmp', '/var/log' ))
 that would give the error
 Cannot put optional positional parameter @srcDirs after
variadic parameters
 and if you give it the slurpy splat, it's the same error message
 seatek: I agree that "it's the same error message" is more
confusing than it has to be
 m: sub MAIN (:$named, *@srcDirs = ("/tmp", "/var/log" )) {}
 rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling ␤Cannot put optional positional parameter @srcDirs
after variadic parameters [...]
 seatek: what it really should do in the case of the slurpy is
to give you the error "Cannot put default on slurpy parameter
@srcDirs"
 m: sub MAIN (*@srcDirs = ("/tmp", "/var/log" )) {}
21:07 <+camelia> rakudo-moar 83d733: OUTPUT«===SORRY!=== Error while
compiling ␤Cannot put default on slurpy parameter @srcDirs [...]
 ...which it does if you don't put named parameters before it
 seatek: I think as to your original question -- whether it's
supported -- the answer is no because you basically can not *not* pass
in a set of values to the slurpy parameter.
 masak: yeah, that makes complete sense when you really think about it