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: 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: 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
On Mon, Feb 3, 2020 at 3:52 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> 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 On

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 = 84; printf "\$u = <%08s>\n", $u;' > $u

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