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: 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
%*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 wrote: > >> Interesting stuff. >> I would like to take the change and ask one question: >> One thing, I had to get

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
20:07, WFB wrote: > 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('comp

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: printf question

2020-02-10 Thread ToddAndMargo via perl6-users
On 2020-02-10 03:18, Timo Paulssen wrote: Hope that's interesting Very! :-)

Re: printf question

2020-02-10 Thread Paul Procacci
Thanks Timo, I was, in part, aware of this, but didn't have the full knowledge/details as you've explained it. Thanks! On Mon, Feb 10, 2020 at 6:18 AM Timo Paulssen wrote: > Hi Paul and Todd, > > just a little extra info: the limitation for nameds to come after > positionals is only for

Re: printf question

2020-02-10 Thread Timo Paulssen
Hi Paul and Todd, just a little extra info: the limitation for nameds to come after positionals is only for declarations of signatures. Usage of subs/methods as well as capture literals (which you don't use often, i imagine, so feel free to disregard) allow you to mix nameds and positionals

Re: printf question

2020-02-10 Thread ToddAndMargo via perl6-users
On 2020-02-09 22:48, Paul Procacci wrote: Named parameters must come after all positional parameters. Your example subroutine is invalid for this reason, while the following would be fine: sub abcdefg( $b, $f, $g, :$a, :$c, :$e) abcdefg("position1", "position2", "position3", :e("named_e"),

Re: printf question

2020-02-09 Thread Paul Procacci
Named parameters must come after all positional parameters. Your example subroutine is invalid for this reason, while the following would be fine: sub abcdefg( $b, $f, $g, :$a, :$c, :$e) abcdefg("position1", "position2", "position3", :e("named_e"), :a("named_a"), :c("named_c")); On Sun, Feb

Re: printf question

2020-02-09 Thread ToddAndMargo via perl6-users
On 2020-02-09 14:53, Paul Procacci wrote: subchdir(IO() $path, :$d=True, :$r, :$w, :$x-->IO::Path:D) Hi Paul, What I wanted to see is how something liek sub abcdefg( :$a, $b, :$c, :$e, $f, $g ) would be called -T

Re: printf question

2020-02-09 Thread Paul Procacci
I think it's best that I show you examples from the official documentation. Let's use chdir as our example. https://docs.raku.org/routine/chdir chdir has the following signature: sub chdir(IO() $path, :$d = True, :$r, :$w, :$x --> IO::Path:D) So let's break this down. $path :: This is a

Re: printf question

2020-02-09 Thread ToddAndMargo via perl6-users
On 2020-02-08 15:39, Paul Procacci wrote: sub a(:$a, :$b, :$c) {} a(:c(1), :a(0), :b(3)); Hi Paul, I think I got it, but would yo give me one more exampale to make sure I fully understand? sub a(:$a, :$b, :$c) {} a(:c(1), :a(0), :b(3)); But with two that are not named and two that are

Re: printf question

2020-02-08 Thread Paul Procacci
Named parameters are an important part of the raku language. In fact, named parameters are used in several other languages as well. It's in your best interest to learn how they work in order to use the language properly. sub a (:$a) {} This is a named parameter. You know it's a

Re: printf question

2020-02-07 Thread ToddAndMargo via perl6-users
On Thu, Feb 6, 2020 at 11:43 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2020-02-05 20:12, Paul Procacci wrote: > I wasn't going to follow up but decided to do so since there is a small > but subtle bug in my original post. > I wouldn't want to

Re: printf question

2020-02-06 Thread Paul Procacci
The subroutine I wrote defines a named parameter that goes by the name alignment 'Int :$alignment'. If the caller wants to call the callee using the given named parameter there are several ways to so do hence the ':alignment(4)'. If instead you have a variable already defined you can

Re: printf question

2020-02-06 Thread ToddAndMargo via perl6-users
On 2020-02-05 20:12, Paul Procacci wrote: I wasn't going to follow up but decided to do so since there is a small but subtle bug in my original post. I wouldn't want to mislead you Todd. The \d has been changed to [0..9] as the expected input would only ever be in that range.  (\d includes

Re: printf question

2020-02-05 Thread ToddAndMargo via perl6-users
On 2020-02-05 20:12, Paul Procacci wrote: I wasn't going to follow up but decided to do so since there is a small but subtle bug in my original post. I wouldn't want to mislead you Todd. The \d has been changed to [0..9] as the expected input would only ever be in that range.  (\d includes

Re: printf question

2020-02-05 Thread Paul Procacci
I wasn't going to follow up but decided to do so since there is a small but subtle bug in my original post. I wouldn't want to mislead you Todd. The \d has been changed to [0..9] as the expected input would only ever be in that range. (\d includes Unicode Characters) I've also included an

Re: printf question

2020-02-05 Thread ToddAndMargo via perl6-users
On 2020-02-03 13:51, ToddAndMargo via perl6-users wrote: Hi All, Is ther a way to get $ p6 'my uint8 $u = 84; printf "\$u = <%08s>\n", $u;' $u = <0084> to print $u = <_0084> ? Many thanks, -T Hi All, Just to torment myself, I wrote a sub to do this:

Re: printf question

2020-02-05 Thread ToddAndMargo via perl6-users
On 2020-02-04 17:08, Paul Procacci wrote: The only thing that's wrong is that you didn't account for leading zero's. Your initial question has a type who's size is always 1 byte. However your second question, the one where 'something is wrong' requires more bits of information to hold the given

Re: printf question

2020-02-05 Thread ToddAndMargo via perl6-users
On 2020-02-04 02:49, Tom Browder wrote: On Tue, Feb 4, 2020 at 01:04 ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: ... >>     Who do I get it to print >> >>           0b0100_ Look at my module Text::Utils and its "commify" sub taken from "The Perl

Re: printf question

2020-02-04 Thread Paul Procacci
The only thing that's wrong is that you didn't account for leading zero's. Your initial question has a type who's size is always 1 byte. However your second question, the one where 'something is wrong' requires more bits of information to hold the given value. You need to modify the sprintf to pad

Re: printf question

2020-02-04 Thread Tom Browder
On Tue, Feb 4, 2020 at 01:04 ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: ... > >> Who do I get it to print >> > >> 0b0100_ Look at my module Text::Utils and its "commify" sub taken from "The Perl Cookbook." Its algorithm (similar to Paul's) should be able to

Re: printf question

2020-02-03 Thread ToddAndMargo via perl6-users
On Mon, Feb 3, 2020 at 8:17 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2020-02-03 13:51, ToddAndMargo via perl6-users wrote: > p6 'my uint8 $u = 84; printf "\$u = <%08s>\n", $u;' Oops, that should have been $ p6 'my uint8 $u = 0x4F; printf "\$u =

Re: printf question

2020-02-03 Thread Paul Procacci
Here's one way my uint8 $u = 0x4F; say '$u = <0b' ~ '%08b'.sprintf($u).comb(/\d ** 4/).join('_') ~ '>;'; There's probably others as well. On Mon, Feb 3, 2020 at 8:17 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 2020-02-03 13:51, ToddAndMargo via perl6-users wrote: >

Re: printf question

2020-02-03 Thread ToddAndMargo via perl6-users
On 2020-02-03 13:51, ToddAndMargo via perl6-users wrote: p6 'my uint8 $u = 84; printf "\$u = <%08s>\n", $u;' Oops, that should have been $ p6 'my uint8 $u = 0x4F; printf "\$u = <%#b>\n", $u;' $u = <0b100> Who do I get it to print 0b0100_ ? -T

Re: printf question

2020-02-03 Thread ToddAndMargo via perl6-users
Many thanks, -T On 2020-02-03 14:13, yary wrote: I think you need a more specific question... p6 'my uint8 $u = 84; printf "\$u = <_%04s>\n", $u;' -y Hi Yary, That is printing out in base 10. $ p6 'my uint8 $u = 84; printf "\$u = <_%04s>\n",

Re: printf question

2020-02-03 Thread yary
I think you need a more specific question... p6 'my uint8 $u = 84; printf "\$u = <_%04s>\n", $u;' -y On Mon, Feb 3, 2020 at 3:52 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > Is ther a way to get > > $ p6 'my uint8 $u = 8

printf question

2020-02-03 Thread ToddAndMargo via perl6-users
Hi All, Is ther a way to get $ p6 'my uint8 $u = 84; printf "\$u = <%08s>\n", $u;' $u = <0084> to print $u = <_0084> ? Many thanks, -T

Re: int and Str in sub declaration question

2020-01-12 Thread ToddAndMargo via perl6-users
On 2020-01-12 18:23, ToddAndMargo via perl6-users wrote: On 2020-01-12 16:05, Joseph Brenner wrote: This can be done with an explicit, named subset if you like:    subset StrOrInt where Str | Int;    sub do_stuff ( StrOrInt $item ) {    say "$item is a " ~ $item.^name;    } Hi Joseph,

Re: int and Str in sub declaration question

2020-01-12 Thread ToddAndMargo via perl6-users
ut up with the other types of "Any"?     Many thanks,     -T On Thu, 9 Jan 2020 at 08:13, WFB <mailto:wolfgang.banas...@gmail.com>> wrote:     Hi, Todd,     If I understand your question right, then you mean something like that:     sub do-soemthing($value where {

Re: int and Str in sub declaration question

2020-01-12 Thread ToddAndMargo via perl6-users
On 2020-01-12 16:05, Joseph Brenner wrote: This can be done with an explicit, named subset if you like: subset StrOrInt where Str | Int; sub do_stuff ( StrOrInt $item ) { say "$item is a " ~ $item.^name; } Hi Joseph, I like it. Now to figure where to put it so it is

Re: int and Str in sub declaration question

2020-01-12 Thread Joseph Brenner
ith the other types of "Any"? >>>> >>>> Many thanks, >>>> -T >>>> > >>> On Thu, 9 Jan 2020 at 08:13, WFB >> <mailto:wolfgang.banas...@gmail.com>> wrote: >>> >>> Hi, Todd, >

Re: int and Str in sub declaration question

2020-01-09 Thread ToddAndMargo via perl6-users
ks, -T On Thu, 9 Jan 2020 at 08:13, WFB <mailto:wolfgang.banas...@gmail.com>> wrote: Hi, Todd, If I understand your question right, then you mean something like that: sub do-soemthing($value where { .WHAT ~~ Str || .WHAT ~~ Int }) {} https://docs.rak

Re: int and Str in sub declaration question

2020-01-08 Thread WFB
For the sake of readability you might want use a subset: https://docs.raku.org/language/typesystem#subset On Thu, 9 Jan 2020 at 08:13, WFB wrote: > Hi, Todd, > > If I understand your question right, then you mean something like that: > > sub do-soemthing($value where { .WHAT

Re: int and Str in sub declaration question

2020-01-08 Thread WFB
Hi, Todd, If I understand your question right, then you mean something like that: sub do-soemthing($value where { .WHAT ~~ Str || .WHAT ~~ Int }) {} https://docs.raku.org/type/Signature#index-entry-where_clause Regards On Thu, 9 Jan 2020 at 03:58, ToddAndMargo via perl6-users < perl6-us

int and Str in sub declaration question

2020-01-08 Thread ToddAndMargo via perl6-users
Hi All, In a sub declaration, is there a way to constrain a variable to only an "int32" or a "Str" (I want both)? Or do I have to put up with the other types of "Any"? Many thanks, -T

global variables and modules question

2019-12-31 Thread ToddAndMargo via perl6-users
Hi All, Is there a way to restrict variables, constants, enums and such declared in the global section of a module to only the module? Many thanks, -T -- ~ When we ask for advice, we are usually looking for an accomplice. --

NativeCall and C String question

2019-12-29 Thread ToddAndMargo via perl6-users
Hi All, When Native call gives me back an address and byte count to a C string, how do I turn that into a Raku string? Address = 5636171 0x56004B byte count = 14 (UTF16) two of these are presumed to be chr(0) Actual string is `KVM-W7` Many thanks, -T --

Re: null and native call question

2019-12-29 Thread ToddAndMargo via perl6-users
her today for evaluation. On the "null and native call question", Native Call translates a zero into a C NULL for you. My run and die issue was not lpReserved being sent a NULL incorrectly. The culprit was M$ and lpType. https://docs.microsoft.com/en-us/windows/win32/api/winreg

Re: null and native call question

2019-12-29 Thread WFB
Hi Todd, I am curious, what was the problem? I tried 0 in the first place and the script died. Though it has something to do with the 0 but obviously it has not. On Sun, 29 Dec 2019 at 10:31, ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 2019-12-29 00:28, ToddAndMargo via

Re: null and native call question

2019-12-29 Thread ToddAndMargo via perl6-users
On 2019-12-29 00:28, ToddAndMargo via perl6-users wrote: On Fri, Dec 27, 2019 at 6:06 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote:     Hi All,     https://docs.perl6.org/language/nativecall    "As you may have predicted by now, a NULL pointer    is

Re: null and native call question

2019-12-29 Thread ToddAndMargo via perl6-users
On Fri, Dec 27, 2019 at 6:06 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, https://docs.perl6.org/language/nativecall "As you may have predicted by now, a NULL pointer is represented by the type object of the struct type."

Re: null and native call question

2019-12-27 Thread Brad Gilbert
A Null pointer is just a pointer that points to the address 0. So if you are dealing with it as an integer it will be 0. On Fri, Dec 27, 2019 at 6:06 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > https://docs.perl6.org/language/nativecall > > "As you may

null and native call question

2019-12-27 Thread ToddAndMargo via perl6-users
Hi All, https://docs.perl6.org/language/nativecall "As you may have predicted by now, a NULL pointer is represented by the type object of the struct type." https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw C++ LSTATUS RegQueryValueExW(

Re: square root question

2019-12-15 Thread ToddAndMargo via perl6-users
On 2019-12-15 12:30, Simon Proctor wrote: https://docs.raku.org/language/optut This should cover it. On Sun, 15 Dec 2019, 20:17 ToddAndMargo via perl6-users, mailto:perl6-users@perl.org>> wrote: On 2019-12-15 02:56, Tobias Boege wrote: > On Sat, 14 Dec 2019, ToddAndMargo wrote:

Re: square root question

2019-12-15 Thread Simon Proctor
https://docs.raku.org/language/optut This should cover it. On Sun, 15 Dec 2019, 20:17 ToddAndMargo via perl6-users, < perl6-users@perl.org> wrote: > On 2019-12-15 02:56, Tobias Boege wrote: > > On Sat, 14 Dec 2019, ToddAndMargo wrote: > >> What am I doing wrong here? > >> > >>> multi prefix:<√>

Re: square root question

2019-12-15 Thread ToddAndMargo via perl6-users
On 2019-12-15 02:56, Tobias Boege wrote: On Sat, 14 Dec 2019, ToddAndMargo wrote: What am I doing wrong here? multi prefix:<√> (Cool:D $x) { $x.sqrt } :<√> say √2 ===SORRY!=== Argument to "say" seems to be malformed --> say⏏ √2 Bogus postfix If this is inside the REPL, it's not your

Re: square root question

2019-12-15 Thread Tobias Boege
On Sat, 14 Dec 2019, ToddAndMargo wrote: > What am I doing wrong here? > > > multi prefix:<√> (Cool:D $x) { $x.sqrt } > :<√> > > > say √2 > ===SORRY!=== > Argument to "say" seems to be malformed > --> say⏏ √2 > Bogus postfix If this is inside the REPL, it's not your fault. It's a known

Re: square root question

2019-12-14 Thread ToddAndMargo via perl6-users
On 2019-12-14 18:43, Tobias Boege wrote: On Sat, 14 Dec 2019, ToddAndMargo via perl6-users wrote: Hi All, Am I pushing it with the unicodes here? say 2.√ ===SORRY!=== Error while compiling: Malformed postfix call --> say 2.⏏√ √ is not a valid identifier character, so this can't be a

square root question

2019-12-14 Thread ToddAndMargo via perl6-users
Hi All, Am I pushing it with the unicodes here? say sqrt(2) 1.4142135623730951 say 2.sqrt 1.4142135623730951 say ½*2.sqrt 0.7071067811865476 say 2.√ ===SORRY!=== Error while compiling: Malformed postfix call --> say 2.⏏√ say √2 ===SORRY!=== Argument to "say" seems to be malformed

Re: restricted value passed to a sub question

2019-12-07 Thread ToddAndMargo via perl6-users
On 2019-12-04 00:40, ToddAndMargo via perl6-users wrote: Hi All, I am cooking up something where I want top pass a value to a sub, but I want to restrict what those values are. For instance, things like    AbortRetryIgnore    CancelRetryContinue    Help    YesNo    Maybe And so on and

Re: restricted value passed to a sub question

2019-12-05 Thread ToddAndMargo via perl6-users
On 2019-12-05 03:25, William Michels via perl6-users wrote: If you want to view a publisher-authorized preview of brian d foy's "Learning Perl 6" book, here's a good place to start (there's also a link to purchase an eBook): https://books.google.com/books?id=sbRqDwAAQBAJ Todd, you could try

Re: restricted value passed to a sub question

2019-12-05 Thread William Michels via perl6-users
If you want to view a publisher-authorized preview of brian d foy's "Learning Perl 6" book, here's a good place to start (there's also a link to purchase an eBook): https://books.google.com/books?id=sbRqDwAAQBAJ Todd, you could try searching in the search box for: "Checking Allowed Values".

Re: hash and print question

2019-12-05 Thread Todd Chester via perl6-users
On 2019-12-05 01:59, Todd Chester via perl6-users wrote: put he space or the "t" before "the". Chuckle.

Re: hash and print question

2019-12-05 Thread Todd Chester via perl6-users
On Thu, Dec 5, 2019 at 10:52 AM Todd Chester via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, In the following, $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="YesNo"; if %x<<$y>> {say %x<<$y >>.base(16)}else{say "n"};' FF $ p6 'my %x= YesNo=>0xff,

Re: hash and print question

2019-12-05 Thread Fernando Santagata
Try say %x{$y}.base(16); On Thu, Dec 5, 2019 at 10:52 AM Todd Chester via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > In the following, > > > $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="YesNo"; if %x<<$y>> > {say %x<<$y >>.base(16)}else{say "n"};' > FF > > $ p6 'my %x=

hash and print question

2019-12-05 Thread Todd Chester via perl6-users
Hi All, In the following, $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="YesNo"; if %x<<$y>> {say %x<<$y >>.base(16)}else{say "n"};' FF $ p6 'my %x= YesNo=>0xff, OkayCancel=>0x55; my $y="Help"; if %x<<$y>> {say %x<< $y >>.base(16)}else{say "n"};' n I have to use a space after $y

Re: restricted value passed to a sub question

2019-12-04 Thread ToddAndMargo via perl6-users
On 2019-12-04 04:25, Mark Senn wrote: I can't have books in my house. It is along story. If you can have ebooks a Google search showed https://www.amazon.com/Learning-Perl-Keeping-Impossible-Within-ebook-dp-B07GT9KPP1/dp/B07GT9KPP1/ref=mt_kindle?_encoding=UTF8== for Kindle versions or

Re: restricted value passed to a sub question

2019-12-04 Thread ToddAndMargo via perl6-users
El mié., 4 dic. 2019 a las 11:06, ToddAndMargo via perl6-users https://docs.perl6.org/type/Map.html On 2019-12-04 02:12, JJ Merelo wrote:  Please use this now: https://docs.raku.org/type/Map.html (also, we should probably move the deprecation notice from the footer to the

Re: restricted value passed to a sub question

2019-12-04 Thread JJ Merelo
El mié., 4 dic. 2019 a las 11:06, ToddAndMargo via perl6-users (< perl6-users@perl.org>) escribió: > On 2019-12-04 01:44, William Michels via perl6-users wrote: > > Hi Todd, > > > > Chapter 9 (Associatives) of "Learning Perl 6" by brian d foy has a > > section on Maps, "the immutable mapping of

Re: restricted value passed to a sub question

2019-12-04 Thread ToddAndMargo via perl6-users
On Wed, 4 Dec 2019 at 08:45, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, I am cooking up something where I want top pass a value to a sub, but I want to restrict what those values are. For instance, things like AbortRetryIgnore

Re: restricted value passed to a sub question

2019-12-04 Thread ToddAndMargo via perl6-users
On 2019-12-04 01:44, William Michels via perl6-users wrote: Hi Todd, Chapter 9 (Associatives) of "Learning Perl 6" by brian d foy has a section on Maps, "the immutable mapping of zero or more keys to values". In that section there are subsections entitled 'Checking Keys', 'Creating from a

Re: restricted value passed to a sub question

2019-12-04 Thread William Michels via perl6-users
Hi Todd, Chapter 9 (Associatives) of "Learning Perl 6" by brian d foy has a section on Maps, "the immutable mapping of zero or more keys to values". In that section there are subsections entitled 'Checking Keys', 'Creating from a Positional' and 'Checking Allowed Values.' HTH, Bill. On Wed, Dec

Re: restricted value passed to a sub question

2019-12-04 Thread Simon Proctor
So I'd approach this in one of two ways. Firstly there's the multi sub with constants option : multi selector( "AbortRetryIgnore" ) { ... } multi selector( "CancelRetryContinue" ) { ... } multi selector( "Help" ) { ... } multi selector( "YesNo" ) { ... } multi selector( "Maybe" ) { ... } I'd do

restricted value passed to a sub question

2019-12-04 Thread ToddAndMargo via perl6-users
Hi All, I am cooking up something where I want top pass a value to a sub, but I want to restrict what those values are. For instance, things like AbortRetryIgnore CancelRetryContinue Help YesNo Maybe And so on and so forth. If the wrong value is passed, I want the checker to

Re: rmdir question

2019-12-03 Thread Timo Paulssen
On 03/12/2019 04:46, Paul Procacci wrote: > On success it return a Bool::True. > On failure it throws an exception. > It doesn't crash the program. > If you are interested in handling the exception, add logic to handle it. > > Examples: > --- > # mkdir a ; `which perl6` -e

Re: rmdir question

2019-12-02 Thread ToddAndMargo via perl6-users
On Mon, Dec 2, 2019 at 9:39 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, From the manual page of rmdir: https://docs.perl6.org/routine/rmdir subrmdir(*@dirs --> List:D) method rmdir(IO::Path:D: --> True) Does

Re: rmdir question

2019-12-02 Thread Paul Procacci
It seems to me all your questions are answered by the very documentation you referenced. >> Does *@dirs mean I can give it multiple directories as an array? Remove the invocant in sub form of the provided directories in the given list . Example: - # mkdir

rmdir question

2019-12-02 Thread ToddAndMargo via perl6-users
Hi All, From the manual page of rmdir: https://docs.perl6.org/routine/rmdir subrmdir(*@dirs --> List:D) method rmdir(IO::Path:D: --> True) Does *@dirs mean I can give it multiple directories as an array? What does "--> List:D" give me back? An array of Booleans as to which

Re: run line question

2019-11-30 Thread ToddAndMargo via perl6-users
On 2019-11-30 00:10, ToddAndMargo via perl6-users wrote: On 2019-11-23 18:26, ToddAndMargo via perl6-users wrote: Hi All, When folks write programs that read the run line like    /a abc /r xyz or    /r xyz /a aaabc or    dd bs=4096 if=xxx.iso of=/dev/sdc basically, in

Re: run line question

2019-11-30 Thread ToddAndMargo via perl6-users
On 2019-11-23 18:26, ToddAndMargo via perl6-users wrote: Hi All, When folks write programs that read the run line like   /a abc /r xyz or   /r xyz /a aaabc or   dd bs=4096 if=xxx.iso of=/dev/sdc basically, in any order. How do they keep track of what goes where?

Re: words and separators question

2019-11-29 Thread ToddAndMargo via perl6-users
On 2019-11-28 05:51, ToddAndMargo via perl6-users wrote: Hi All, I have a situation where I can see two different strings:     "xxx     zzz"     "avcde    fg hi  jklmx" "fg hi" only has one space in the middle. All the words have multiple spaces between them. Is there a

Re: words and separators question

2019-11-28 Thread ToddAndMargo via perl6-users
On 2019-11-28 06:47, The Sidhekin wrote: On Thu, Nov 28, 2019 at 2:53 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Is there a way I can tell words that I want "fg hi" to be considered one word?  A way to make the separator two or more spaces?   I don't

Re: qx and echo question

2019-11-28 Thread ToddAndMargo via perl6-users
On 2019-11-28 12:57, yary wrote: One of the clues is the exitcode=1, there is an error coming back. I think there are two issues which I didn't realize until now 1. DOS command "dir" is a cmd.exe built-in, not its own executable 2. Raku (perl6) "run" takes a list of arguments, not a

Re: words and separators question

2019-11-28 Thread ToddAndMargo via perl6-users
On 2019-11-28 05:51, ToddAndMargo via perl6-users wrote: Hi All, I have a situation where I can see two different strings:     "xxx     zzz"     "avcde    fg hi  jklmx" "fg hi" only has one space in the middle. All the words have multiple spaces between them. Is there a

Re: qx and echo question

2019-11-28 Thread ToddAndMargo via perl6-users
On 2019-11-28 09:39, WFB wrote: Hi T, I have very little knowledge about the interna, but 'dir' is a raku as well as Shell command. THat might cause a problem here. Try, "shell" instead of "run", that works for me at least: perl6 -e "shell 'dir'" Greetings Hi WFB, I am only using "dir"

Re: qx and echo question

2019-11-28 Thread yary
One of the clues is the exitcode=1, there is an error coming back. I think there are two issues which I didn't realize until now 1. DOS command "dir" is a cmd.exe built-in, not its own executable 2. Raku (perl6) "run" takes a list of arguments, not a space-separated command-line Let's try these

Re: words and separators question

2019-11-28 Thread The Sidhekin
On Thu, Nov 28, 2019 at 2:53 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Is there a way I can tell words that I want "fg hi" to > be considered one word? A way to make the separator > two or more spaces? > I don't think you can pass a separator to words. But you can

words and separators question

2019-11-28 Thread ToddAndMargo via perl6-users
Hi All, I have a situation where I can see two different strings: "xxx zzz" "avcdefg hi jklmx" "fg hi" only has one space in the middle. All the words have multiple spaces between them. Is there a way I can tell words that I want "fg hi" to be considered one

Re: qx and echo question

2019-11-27 Thread ToddAndMargo via perl6-users
On Mon, Nov 25, 2019 at 9:02 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: >> On Mon, Nov 25, 2019 at 6:46 AM ToddAndMargo via perl6-users >> mailto:perl6-users@perl.org> >> wrote: >>

Re: qx and echo question

2019-11-26 Thread yary
quote the argument to run - try the below - and yes, I switched to forward slash. My experience is that Windows accepts either slash, and forward slashes create fewer confusing situations. perl6 -e "my $proc=run 'dir'; say 'Exit code=', $proc.exitcode;" perl6 -e "chdir 'c:/NtUtil'; my $proc=run

Re: qx and echo question

2019-11-25 Thread ToddAndMargo via perl6-users
On Mon, Nov 25, 2019 at 6:46 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, In Perl6 for Windows, how can I get "qx" (or other) to send the output to the shell as its happens (not afterwards)? >ver Microsoft Windows [Version 6.1.7601]

Re: qx and echo question

2019-11-25 Thread yary
So, you want to see the output as it happens, and the program doesn't need the output, it only needs the error code? my $proc = run 'ls'; say $proc.exitcode ?? 'error' !! 'good' ; I got that from the examples on https://docs.perl6.org/type/Proc#sub_run - even if documentation usually leaves you

qx and echo question

2019-11-25 Thread ToddAndMargo via perl6-users
Hi All, In Perl6 for Windows, how can I get "qx" (or other) to send the output to the shell as its happens (not afterwards)? >ver Microsoft Windows [Version 6.1.7601] >perl6 -e "qx ( ver );" (One of) my goal(s) is to watch "chkdsk" on the shell as it runs through its various stages. I

run line question

2019-11-23 Thread ToddAndMargo via perl6-users
Hi All, When folks write programs that read the run line like /a abc /r xyz or /r xyz /a aaabc or dd bs=4096 if=xxx.iso of=/dev/sdc basically, in any order. How do they keep track of what goes where? Many thanks, -T

Re: Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-19 Thread Brad Gilbert
anonymous variable '$' >> >> -y >> >> >> On Mon, Nov 18, 2019 at 8:38 AM yary wrote: >> >>> looks like a bug to me-file an issue on the rakudo GitHub >>> >>> On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens < >>> raymon

Re: Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-18 Thread Raymond Dresens
rint on the > anonymous variable '$' > > -y > > > On Mon, Nov 18, 2019 at 8:38 AM yary wrote: > >> looks like a bug to me-file an issue on the rakudo GitHub >> >> On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens < >> raymond.dres...@gmail.com> wro

Re: Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-18 Thread Vadim Belman
ymous variable '$' > > -y > > > On Mon, Nov 18, 2019 at 8:38 AM yary <mailto:not@gmail.com>> wrote: > looks like a bug to me-file an issue on the rakudo GitHub > > On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens <mailto:raymond.dres...@gmail.com>> wrote: &

Re: Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-18 Thread yary
o GitHub > > On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens > wrote: > >> Hello, >> >> I have a question related to the 'colon syntax' of Raku, which allows >> you to call methods without parenthesis like this: >> >> class Foo >> { >>

Re: Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-18 Thread yary
looks like a bug to me-file an issue on the rakudo GitHub On Sat, Nov 16, 2019 at 5:29 AM Raymond Dresens wrote: > Hello, > > I have a question related to the 'colon syntax' of Raku, which allows > you to call methods without parenthesis like this: > > class Foo >

Question about "colon syntax" for calling other methods on 'self' inside a method

2019-11-16 Thread Raymond Dresens
Hello, I have a question related to the 'colon syntax' of Raku, which allows you to call methods without parenthesis like this: class Foo { method print($x, $y) { say "bar: {$x}, {$y}" } } my $a = Foo.new; $a.p

Re: subs and variables speed question

2019-02-11 Thread Timo Paulssen
> On 2/11/19 3:27 AM, Timo Paulssen wrote: > > WHICH doesn't give you a numerical value. just print it as it is. > > > $ p6 'sub a (Buf $b) { say $b.WHICH }; my $c = Buf.new(1,2,3); say > $c.WHICH; a($c);' > Buf|71848984 > Buf|71848984 > > If "moarvm has a moving garbage collector" moves my 100

<    1   2   3   4   5   6   7   >