Re: variable as subroutine?

2020-02-11 Thread Aureliano Guedes
Sorry, I sent my answer just for you. So, the problem is you didn't call the same var you had declared. my $foo = * **2; Then you call foo(2).say Missing the $ Try: $foo(2).say or say $foo(2) About the my @a = * **2; Your suggestion works @a[0](2) or @a[0].(2) But I would

Re: variable as subroutine?

2020-02-11 Thread Andy Bach
>The * * * call generates a WhateverCode block. This is expecting 2 arguments. -> $x { $x * $x } is taking one argument. > The best documentation would probably be : https://docs.raku.org/type/Whatever so, from: Multiple * in one expression generate closures with as many arguments: my $c = * +

Re: Question about Blob and Buf

2020-02-11 Thread David Santiago
Hi Timo, Thanks for the answer: > the liskov substitution principle I didn't knew about this principle. I'm now going down the rabbit hole. Is this always the case for all the derived classes in Raku? Best regards, David Santiago Timo Paulssen escreveu no dia terça, 11/02/2020 à(s) 13:32: > >

Re: variable as subroutine?

2020-02-11 Thread Simon Proctor
The * * * call generates a WhateverCode block. This is expecting 2 arguments. -> $x { $x * $x } is taking one argument. The best documentation would probably be : https://docs.raku.org/type/Whatever Hope that helps. (For giggles earlier I made this dumb example of functional programming) my

Re: variable as subroutine?

2020-02-11 Thread Andy Bach
I have a few less related questions >> those are 3 ways to write the same sub: sub foo ($x) { $x * $x } my = -> $x { $x * $x } my = * * *; > A Note on Marc's comment: my = * * * is not the same as: my = -> $x { $x * $x } it is the same as: my = -> $x, $y { $x * $y } Okay, "* *

Re: Question about Blob and Buf

2020-02-11 Thread Brad Gilbert
The problem is that you are using ~ with an uninitialized Buf/Blob my Buf $read; $read ~ Buf.new; # Use of uninitialized value element of type Buf in string context. Note that it is not complaining about it being a Buf. It is complaining about it being uninitialized. If you

Re: Question about Blob and Buf

2020-02-11 Thread Timo Paulssen
On 11/02/2020 14:14, David Santiago wrote: > Awesome explanation! Thank you! > > BTW, >> my Blob $read = Buf.new; > Is it creating either a Blob or a Buf? > > Regards, > David Santiago Hi David, "my Blob $read" will define the variable $read to 1) only accept things that typecheck against

Re: Question about Blob and Buf

2020-02-11 Thread David Santiago
Awesome explanation! Thank you! BTW, > my Blob $read = Buf.new; Is it creating either a Blob or a Buf? Regards, David Santiago -- Sent from my Android device with K-9 Mail. Please excuse my brevity.

Re: Question about Blob and Buf

2020-02-11 Thread Timo Paulssen
On 11/02/2020 10:56, David Santiago wrote: > Hi! > > Can someone explain me why this doesn't work: > > my Blob $read; > $read ~= $socket.read(1024); > > Dies with error: > > X::Buf::AsStr: Cannot use a Buf as a string, but you called the Stringy > method on it > > This also doesn't work: > > my

Re: How do I contact the moderator?

2020-02-11 Thread ToddAndMargo via perl6-users
On 2020-02-11 01:03, ToddAndMargo via perl6-users wrote: On 2020-02-11 00:44, Shlomi Fish wrote: Hi Todd, On Mon, 10 Feb 2020 19:25:50 -0800 ToddAndMargo via perl6-users wrote: Hi All, I have been getting a strange eMail on this group. How do I contact the moderator to check and see if it

Re: Question about Blob and Buf

2020-02-11 Thread David Santiago
A 11 de fevereiro de 2020 12:03:19 CET, Simon Proctor escreveu: >Ok I 100% don't know after trying this out : > >my Buf $a = Buf.new(1,2,3); >my Blob $b = Blob.new(4,5,6); >$a ~= $b; >say $a > >And it worked fine so... I dunno. > > >On Tue, 11 Feb 2020 at 11:00, Simon Proctor wrote: > >> I

Re: Question about Blob and Buf

2020-02-11 Thread Simon Proctor
Ok I 100% don't know after trying this out : my Buf $a = Buf.new(1,2,3); my Blob $b = Blob.new(4,5,6); $a ~= $b; say $a And it worked fine so... I dunno. On Tue, 11 Feb 2020 at 11:00, Simon Proctor wrote: > I think the problem is IO::Socket.read() returns a Blob not a Buf. > > ~ has a Buf,

Re: Question about Blob and Buf

2020-02-11 Thread Simon Proctor
I think the problem is IO::Socket.read() returns a Blob not a Buf. ~ has a Buf, Buf variant : https://docs.raku.org/language/operators#infix_~ But not a Blob one. Buf does Blob but not vice versa. I think you need to transform the output from .read into a Buf if you want to use the ~= how you

Re: Question about Blob and Buf

2020-02-11 Thread Kevin Pye
~ works fine for concatenating Bufs; For example: my $a = Buf.new(1,2,3); my $b = $a ~ Buf.new(4,5,6) will assign correctly to $b. I can't work out what the problem is here, despite trying various combinations. Perhaps socket isn't really returning a Blob? Kevin. On Tue, 11 Feb 2020 at 21:01,

Re: printf question

2020-02-11 Thread WFB
Awesome, thanks! That is exactly what I was looking for. On Tue, 11 Feb 2020 at 10:23, Kevin Pye wrote: > The "workaround" is well documented: > https://docs.raku.org/language/create-cli#%*SUB-MAIN-OPTS > > It's just a matter of setting named-anywhere option in the %*SUB-MAIN-OPTS > hash,

Re: Question about Blob and Buf

2020-02-11 Thread JJ Merelo
You are using ~, which stringifies. Bufs are not strings: you need to decode them to concatenate it to a string. If what you want is to concatenate the buffer, probably ,= will work (not sure about this, would have to check), or any other operator that works on Positionals. JJ El mar., 11 feb.

Question about Blob and Buf

2020-02-11 Thread David Santiago
A 11 de fevereiro de 2020 10:47:34 CET, David Santiago escreveu: >A 11 de fevereiro de 2020 09:46:06 CET, David Santiago >escreveu: >> >>Hi! >> >>Can someone explain me why this doesn't work: >> >>my Blob $read; >>$read ~= $socket.read(1024); >> >>Dies with error: >> >>X::Buf::AsStr: Cannot

Re: printf question

2020-02-11 Thread Kevin Pye
The "workaround" is well documented: https://docs.raku.org/language/create-cli#%*SUB-MAIN-OPTS It's just a matter of setting named-anywhere option in the %*SUB-MAIN-OPTS hash, which you will also need to create. There's an example in that doc page. Kevin. On Tue, 11 Feb 2020 at 20:07, WFB

Re: variable as subroutine?

2020-02-11 Thread Simon Proctor
If you can store a subroutine in a variable then you can pass said subroutine to another one as an argument. This leads us into the joys of functional programming. And you may have used it already and not even realised. The .map and .grep methods (and .reduce and bunch of others) all expect a

Re: printf question

2020-02-11 Thread WFB
Interesting stuff. I would like to take the change and ask one question: One thing, I had to get used to is the MAIN handling of parameters. On the command line it is important to write then named parameter in front of the positional ones: MAIN('compile', :$verbose, :$test-only) needs to write:

Re: How do I contact the moderator?

2020-02-11 Thread Shlomi Fish
Hi Todd, On Mon, 10 Feb 2020 19:25:50 -0800 ToddAndMargo via perl6-users wrote: > Hi All, > > I have been getting a strange eMail on this group. > How do I contact the moderator to check and see > if it is a scam? > I think you should send an email to perl6-users-ow...@perl.org . > Many

Re: How do I contact the moderator?

2020-02-11 Thread ToddAndMargo via perl6-users
On 2020-02-11 00:44, Shlomi Fish wrote: Hi Todd, On Mon, 10 Feb 2020 19:25:50 -0800 ToddAndMargo via perl6-users wrote: Hi All, I have been getting a strange eMail on this group. How do I contact the moderator to check and see if it is a scam? I think you should send an email to