DefiniteHOW and SubsetHOW don't support named parameters

2018-09-05 Thread Ralph Mellor
Vadim wrote: > BTW, while researching the core sources I discovered a potential problem with DefiniteHOW and SubsetHOW. They both define their own find_method() which is re-delegating to their base type HOW.find_method. But they don't support named parameters. Combined with classes with FALLBACK

WATs (Array[Str] vs Array and list vs scalar assignment)

2018-09-05 Thread Ralph Mellor
Hi Vadim, This is for you and anyone else interested in a little bit about tricky aspects of sub-types, of P6, of my perspective on learning in response to WTF? moments, and P6 strengths and weaknesses in relation to the foregoing. Vadim wrote: > my Array[Str] $a = ["a", "b", "c"]; > my Str @a

Is Proxy a first class part of P6 or not?

2018-09-05 Thread Ralph Mellor
This is the first in a series of a half dozen responses to Vadim's AttrX::Moo post that replace a couple earlier failed attempts to post here. I apologize if there end up being repeats or my following up with several responses is inappropriate. Hi Vadim. I'm making this my first post because it

How to shield users from side effects of applying an attribute trait for a Moo like trigger

2018-09-05 Thread Ralph Mellor
In Vadim's recent post about his AttrX::Moo module he describes his P6 solution for bringing functionality he was used to having in P5 via Moo. (In another post I've asked about the option and relevance of using Moo:from in P6. If you reply to this post please consider also replying to that one.

perl6-users in groups.google.com

2018-09-06 Thread Ralph Mellor
Does anyone know the mysteries of groups.google.com? Will the messages I'm posting here eventually turn up at https://groups.google.com/forum/#!forum/perl.perl6.users? I sent a bunch of messages via the groups.google.com interface and they disappeared into the void. I searched for the generic

Re: case insensitive "contains"?

2018-09-10 Thread Ralph Mellor
Hi Todd, > What are the rules for what goes inside and what goes outside? > Also, do y have a link to what the various ":x" commands are that I can use? > See https://docs.perl6.org/language/regexes#Adverbs The first section explains the two types of "adverb". "regex adverbs" like `:i` can go

Re: flatten?

2018-10-05 Thread Ralph Mellor
Well I guess my first way of explaining it was a complete bust. :) It's not going to be worth me discussing your reply to my first attempt. List context means that something appears in the context of a list. For example, given the list of characters A, A appears in the context of a list

Re: need --> help

2018-10-12 Thread Ralph Mellor
I imagine P6 may one day be changed to do as you suggest. But for now I think something like this is the closest you'll get: subset Str_Int of List where Str, Int; sub foo (--> Str_Int) { return 'a', 42 } -- raiph On Fri, Oct 12, 2018 at 11:23 PM ToddAndMargo via perl6-users <

Re: Malformed UTF-8 ???

2018-10-13 Thread Ralph Mellor
Why are you asking about cleaning something up? Is it because you thought `Malformed UTF-8` was an error message? If so, great, because it IS an error message. If not, you need to know that Malformed UTF-8 is an error message and we need to think about how to make that more clear. So that's

Re: need --> help

2018-10-13 Thread Ralph Mellor
That would work. I think it's more idiomatic to write the declaration as: my (Str $x, Int $y) = ... which saves repeating the `my`. -- raiph On Fri, Oct 12, 2018 at 11:47 PM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 10/12/18 3:27 PM, Curt Tilmes wrote: > > > > > > On

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
In P6 "assign" means use of `=`. And "assign to" means to copy into the thing on the left of the `=`. And to copy into something the thing has to be a mutable container. The error message is saying that $ReturnStr is bound to an immutable value (eg a string) not a container. So that's

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
e changeable. > that's presumably a problem with whatever code you've written that has earlier bound $ReturnStr to an immutable value. Or you need to use a fresh variable. -- raiph On Sun, Oct 14, 2018 at 10:29 AM Ralph Mellor wrote: > In P6 "assign" means use of `=`. > >

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
4/18 2:29 AM, Ralph Mellor wrote: > > In P6 "assign" means use of `=`. > > > > And "assign to" means to copy into the thing on the left of the `=`. > > > > And to copy into something the thing has to be a mutable container. > > > > The err

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
a perl6-users < perl6-users@perl.org> wrote: > >> On Sun, Oct 14, 2018 at 10:35 AM ToddAndMargo via perl6-users > >> mailto:perl6-users@perl.org>> wrote: > >> > >> On 10/14/18 2:29 AM, Ralph Mellor wrote: > >> > In P6 "a

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
gives me > >> > >>Malformed UTF-8 > >> > >> How do I clean up $$proc.out.slurp-rest ?? > >> > >> Many thanks, > >> -T > >> > > On 10/13/18 7:19 AM, Ralph Mellor wrote: > > Why are you asking abo

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
is then taken out of the container. Which means the extra `$` is redundant. -- raiph On Sun, Oct 14, 2018 at 12:36 PM Tom Browder wrote: > On Sun, Oct 14, 2018 at 5:13 AM Ralph Mellor > wrote: > > > > Almost certainly your problem is elsewhere. > > What is the mean

Re: What is |c ?

2018-10-14 Thread Ralph Mellor
|foo in a signature captures all remaining arguments using a local variable called foo. sub foo (|foo) { foo } say foo 42; # \(42) -- raiph On Sun, Oct 14, 2018 at 10:21 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > Over on > >

Re: enc ?

2018-10-14 Thread Ralph Mellor
https://docs.perl6.org/routine/encoding On Sun, Oct 14, 2018 at 10:23 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > Hi All, > > Over on > > https://docs.perl6.org/routine/slurp > > # read entire file as Latin1 Str > my $text_contents = slurp "path/to/file",

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
is to do with code that you haven't yet shown. -- raiph On Sun, Oct 14, 2018 at 11:08 AM Ralph Mellor wrote: > Are you sure the error message you showed applies to the line you showed? > > This code works fine: > > spurt 'foo', 'bar'; > my Str $ReturnStr = "

Re: Malformed UTF-8 ???

2018-10-14 Thread Ralph Mellor
any difference. We can pick things up from there. Catch ya later. -- raiph On Sun, Oct 14, 2018 at 11:30 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > On 10/14/18 3:08 AM, Ralph Mellor wrote: > > This code works fine: > > > > spurt 'foo', '

Re: need :enc help?I

2018-10-15 Thread Ralph Mellor
https://docs.perl6.org/type/Pair#index-entry-%3A%24 Food for thought: For your previous question about encodings I didn't know the answer. So I went to doc.perl6.org and entered `encoding` in the search box. There were several exact matches. I saw the encoding routine, clicked it. I saw it was

Re: what type $in,$out and $err is

2018-11-01 Thread Ralph Mellor
On Sun, Oct 28, 2018 at 7:26 PM Xiao Yafeng wrote: > I'm curious about what type of $in is on Proc class. `$in` isn't "on `Proc` class". `$in` is a *parameter* of the `.new` *method*. > I mean, if $in is IO::Pipe object As a *parameter* of the `.new` method *declaration* the type of `$in`

Re: what type $in,$out and $err is

2018-11-05 Thread Ralph Mellor
On Sun, Oct 28, 2018 at 7:26 PM Xiao Yafeng wrote: > Besides, just curious, why choose '_' as default it looks strange > Turns out it's deprecated in 6.d: https://marketing.perl6.org/id/1541379592/pdf_digital

Re: <> thank you

2018-10-05 Thread Ralph Mellor
That was me. Sending off list was a mistake. And you're welcome. :) -- raiph On Fri, Oct 5, 2018 at 7:30 AM Todd Chester wrote: > Hi All, > > I went to reply to someone, I think it was Brandon for sending me > an eMail to my private address and the stinker disappeared! > > Anyway whoever sent

Re: Could this be any more obscure?

2018-10-02 Thread Ralph Mellor
>> On 10/1/18 3:37 PM, Donald Hunter wrote: >> > Methods don't accept [], values that are positional do that. >> Is your distinction that [] is actually a routine in itself >> and not part of the method? And I am lumping them together? On 10/2/18 12:18 AM,

Feedback requested on playlist of 200 Perl 6 videos

2018-10-03 Thread Ralph Mellor
On Wed, Oct 3, 2018 at 6:16 AM David Green wrote: > There are quite a few recorded P6 presentations around, but I > don't know if there's a collected list anywhere, or one that links > to recent talks (anything not too out-of-date). > I've been building a collection of P6 videos for about 5

Re: What are the official names?

2018-10-03 Thread Ralph Mellor
longer. One is a longname which appends a signature: `postcircumfix:<[ ]>($, | is raw)` is a longname. (See also https://docs.perl6.org/syntax/Long%20names) The other way is to prepend a package qualifier: `::postcircumfix:<[ ]>` is a package qualified name. -- raiph On Wed, Oct 3, 2

Re: What are the official names?

2018-10-03 Thread Ralph Mellor
> Any idea what the official name of the crypto line is? You haven't mentioned "crypto line" until this point. So I'm guessing you mean the line that starts "multi". That's called a routine declaration. More specifically a method declaration. More specifically a multi method declaration.

Re: Grammar doesn't seem to match any token

2018-09-24 Thread Ralph Mellor
Do you use Grammar::Tracer and especially Grammar::Debugger? I'd say a TOP rule is... don't leave TOP without them. -- raiph

Re: POD: linking to a module

2019-01-16 Thread Ralph Mellor
Hi JJ, Wouldn't it be useful if Vadim commented on an appropriate GH issue? If so, which would that be? https://github.com/perl6/user-experience/issues/35 ? https://github.com/perl6/Pod-To-HTML/issues/55 ? https://github.com/perl6/doc/issues/167 ? Somewhere else? -- raiph On Mon, Jan 14, 2019 at

Re: method vs multi method

2018-09-14 Thread Ralph Mellor
> multi method kv ... Use of `multi` means there *may* be more than one *declaration* using the same declared routine name (`kv` in this case). There usually *will* be more than one. (Otherwise, why was it declared `multi`?) The normal way to *use* a routine is to call it. If you declare

Re: contains booboo

2018-12-18 Thread Ralph Mellor
.contains tests whether its invocant, treated as a string, contains its argument, treated as a string. The argument you've given to .contains is: "b" && not "q". That's not a string. Here's one option: my$x="abcd"; if $x.contains("b") && not $x.contains("q") {say "y"}else{say "n"}; On Tue,

Re: contains booboo

2018-12-19 Thread Ralph Mellor
On Wed, Dec 19, 2018 at 7:58 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > In the mean time, I will ue if $x.contains("b") && not $x.contains( "q" ) > On 12/18/18 4:13 PM, Ralph Mellor wrote, demonstrating he never misses > anythi

Re: unflattering flat

2020-04-04 Thread Ralph Mellor
A microwave is easier: https://www.google.com/search?q=microwave+garlic+to+remove+skin [**] will be a wonderful thing when it's implemented. In the meantime, you could maybe use this as a hack that works to 10 levels deep: my %hash-with-arrays = a => [1,2], b => [3,4]; sub postfix:<[**]> ($arg)

Re: Readline package

2020-08-28 Thread Ralph Mellor
> You can alter to whatever (it just needs to be a string... Larry may comment, but in case not, or, if he does, to save him some time and give him something to correct, here's my take on what he specified^H^H^H^H^Hulated. @Larry defined the auth to be a URI. Quoting

Re: Avoiding monkey typing for custom roles on built-in types...

2020-08-09 Thread Ralph Mellor
> Would a better approach be to create custom subtypes of the built-in numeric types that mixin the algebraic roles? It could maybe work out better to mix roles into numeric instances: role G { has Numeric $numeric handles *; has ThreeDObject[:Rotation] $threedobject-rotation handles *;

Re: root cubic

2020-07-09 Thread Ralph Mellor
You have several useful answers. I want to summarize what they saButy, and add a couple resources. * You probably meant 9 ** <1/2>. Which will display 3. But it's a Num. It's not the right type if you care about accuracy. * A solution to get rationals right is built into Raku. See

Re: perl streaming framework

2020-07-14 Thread Ralph Mellor
I second Brad's comment -- perlmonks.org is a great place to ask. Use the following link for a quick start. The user interface is something out of the dark ages but you'll generally get outstandingly good replies, especially if you explicitly add something like "Thank you for considering my

Re: Help converting CArray[uint8] to Blob

2020-06-17 Thread Ralph Mellor
> Unfortunately, i get the error "Error > X::AdHoc+{X::Await::Died}+{X::React::Died}: Don't know how many elements a C array returned from a library" I googled the error message and got a bunch of matches including this:

Re: Help converting CArray[uint8] to Blob

2020-06-18 Thread Ralph Mellor
> from approx 1.1 to 0.0006 secs. That's quite an improvement! :) Be aware of the stop gap nature of the module, and its WARNING: > At some point, these problems will be addressed in core, but in the > meantime... > This module depends on internal details of the REPRs > of the involved types

Re: Help converting CArray[uint8] to Blob

2020-06-16 Thread Ralph Mellor
> my Data $ed = await $yenc_promise; The promise must initialize each element of the CArray[uint]. It looks pretty quick; I'm guessing it's low-level code doing that. > my uint8 @data = $ed.data[0..$ed.data_size-1].Array; > my Blob $bindata = Blob[uint8].new(@data); Afaict that's a total of

Re: Baby steps to create a dataframe structure

2020-07-29 Thread Ralph Mellor
The first half of this email is some StackOverflow links and commentary. The second half is some specific responses to your questions. https://stackoverflow.com/questions/tagged/raku+r https://stackoverflow.com/search?q=%5Braku%5D+%22data+structures%22

Re: Re-exporting modules that export operators...

2020-08-15 Thread Ralph Mellor
The SO you quote includes an operator. So that's not the problem. The SO is written by jnthn. It doesn't get more authoritative than that. "Cannot import symbol '%?LANG' from 'Graphics::Shapes', because it already exists in this lexical scope." Your export code is attempting to export `%?LANG`,

Re: The ,= operator

2020-11-29 Thread Ralph Mellor
> Ralph Mellor wrote: > >> > @r = @r , 'd'; > >> > >> There isn't anything very useful in this behavior though, is there? > > Just to be clear, I wasn't saying I didn't think circular references > should be forbidden, I just specifically meant that you

Re: The ,= operator

2020-11-29 Thread Ralph Mellor
> Zen slicing as a possible way of 'de-containerizing' : > https://docs.raku.org/language/subscripts#index-entry-Zen_slices A zen-slice only affects the single reference it's applied to. And it is a no op when applied to anything other than a `Scalar`. So it'll have no effect when applied

Re: The ,= operator

2020-11-27 Thread Ralph Mellor
@r ,= 'd'; The above expands to: @r = @r , 'd'; That in turn passes a list of two values to the LHS receiver. That receiver is `@r`, an array, and what arrays do with `=` is to empty themselves and then assign the list of elements on the RHS of the `=` into corresponding `Scalar`s stored in

Fwd: The ,= operator

2020-11-27 Thread Ralph Mellor
I accidentally sent this privately. -- Forwarded message - From: Ralph Mellor Date: Fri, Nov 27, 2020 at 6:06 PM Subject: Re: The ,= operator To: William Michels > I can reproduce your results on Rakudo_2020.10, but I'm afraid I don't > have much more to say

Re: Missing NullPointerException

2020-12-05 Thread Ralph Mellor
On Thu, Dec 3, 2020 at 10:20 PM Konrad Bucheli via perl6-users wrote: > > What is actually the rationale for such a behaviour? Ergonomically sound null safety. First, consider what other languages have. Quoting https://en.wikipedia.org/wiki/Safe_navigation_operator: > In object-oriented

Re: The ,= operator

2020-12-07 Thread Ralph Mellor
> > @fib[1, 5, 10..15, 20] > (1 8 (89 144 233 377 610 987) 10946) > ^ > > Why??? As Joe noted in his last email: > remember, back in perl-land the default behavior is to flatten, > in raku ... by default [raku is] oriented toward building up > complex structures like

Re: The ,= operator

2020-11-28 Thread Ralph Mellor
> > @r = @r , 'd'; > > Okay, that makes sense. So the circular reference I thought I > was seeing is really there, and it's working as designed. > > There isn't anything very useful in this behavior though, is there? Yes. Here are some relevant results from a search for "self referential" in

Re: Missing NullPointerException

2020-12-02 Thread Ralph Mellor
On Wed, Dec 2, 2020 at 7:08 AM Patrick R. Michaud wrote: > Nil.any_non_existent method always seems to return Nil. I'm not sure where > this is documented It's near the top of the `Nil` doc page you linked: > Any method call on `Nil` of a method that does not exist ... will succeed and >

Re: Missing NullPointerException

2020-12-17 Thread Ralph Mellor
On Wed, Dec 16, 2020 at 5:10 AM Konrad Bucheli ... wrote: > there is surely a way to make sure that my Nil > explodes in my code. Is there a `use FailingNil`? I'd +1 a `use fatal :Nil;`. In the meantime, this appears to work: ``` engine.?Raptor::start ``` Might be a bug because an

Re: Is the cosine page wrong?

2020-12-23 Thread Ralph Mellor
If a method does not explicitly specify its invocant type, it is set to the type of the enclosing class. The `cos` method is declared in the `Cool` class, so that is its invocant type. The doc shows that it's declared in the `Cool` class. So, the doc is fine as is for the invocant. The

Re: I need help understanding ".contains" method construction

2020-12-23 Thread Ralph Mellor
>1) why is it "$needle" and not "$!needle" on line 338? >Is this because it is an internal variable and not >a variable from the class declaration? It's a parameter from line 337. If that's what you mean by "an internal variable", then yes. :) >2) where is variable ".value" defined on

Re: I need help understanding ".contains" method construction

2020-12-26 Thread Ralph Mellor
> >> What kind of variable is .value? > > > > I don't see a `.value`, only a `$!value`. > > Is this .self with a better name? No. I know you've been progressing in your understanding of OO in general, and Raku's in particular, since you wrote this email. So I won't explain it for now, but

Re: Junctions wrapped in singleton lists

2020-11-16 Thread Ralph Mellor
say $*PERL.version; # v6.d say $*PERL.compiler.version; # v2018.12 say ({ 1 | -1 } ... *)[^3]; # (any(1, -1) any(1, -1) any(1, -1)) say $*PERL.version; # v6.d say $*PERL.compiler.version; # v2020.07 say ({ 1 | -1 } ... *)[^3]; # ((any(1, -1)) (any(1, -1)) (any(1, -1)))

Re: Junctions wrapped in singleton lists

2020-11-17 Thread Ralph Mellor
https://github.com/rakudo/rakudo/issues/4039 On Tue, Nov 17, 2020 at 3:12 AM yary wrote: > > Open a bug report at https://github.com/rakudo/rakudo/issues/ showing the > change in behavior > > -y > > > On Mon, Nov 16, 2020 at 4:39 PM Ralph Mellor wrote: >> >&g

Re: Practical Raku projects

2020-12-25 Thread Ralph Mellor
Have you tried: ``` use DBIx::Class:from; ``` ? On Thu, Dec 24, 2020 at 11:24 AM Matthias Peng wrote: > > Do you know if there is any for Perl6’s DBIx::Class the ORM library? Regards > >> >> Hi, >> >> El jue, 24 dic 2020 a las 3:55, Matthias Peng () >> escribió: >>> >>> May I ask if there is

Re: Is the cosine page wrong?

2020-12-25 Thread Ralph Mellor
> On 12/23/20 4:28 PM, Ralph Mellor wrote: > > If a method does not explicitly specify its invocant type, it is set > > to the type of the enclosing class. > > But it does not specify an invocant. It just leaves it blank This is how it works in Raku source code. If there'

Re: LTA documentation page

2021-01-05 Thread Ralph Mellor
I googled rakudoc and that led to: https://github.com/Raku/rakudoc which says it's forked from: https://github.com/noisegul/perl6-p6doc So I tried that in m.r.o and it's listed: https://modules.raku.org/search/?q=p6doc So, perhaps you can zef install p6doc? Maybe the doc you read mentioning

Re: surprise with start

2021-01-05 Thread Ralph Mellor
Sounds to me like it's time to raise a doc issue. Also, does anyone know if doc examples are tested? Not just when first published, but as part of blinning? On Tue, Jan 5, 2021 at 1:30 PM Theo van den Heuvel wrote: > > Hi gurus, > > The first example in the documentation on the start control

Re: list assignment

2021-01-19 Thread Ralph Mellor
Food for thought... Python: one = 1,2,3 two = 4,5,6 both = one,two first = both[0] print(one) # (1, 2, 3) print(first) # (1, 2, 3) Python's `=` operator is like Raku's `:=`. my @one := 1,2,3; my @two := 4,5,6; my @both := @one,@two; my @first := @both[0]; say @one.raku; # (1, 2, 3) say

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 3:22 AM Joseph Brenner wrote: > > > That is a large part of the beauty of the junction design. All functions > > (and thus all operators) automatically get a very useful and powerful > > junctional behavior for free. They don't even know junctions exist. > > I can see the

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:12 PM Joseph Brenner wrote: > > my impression was that junctions, by design aren't supposed to be > treated as compound data structures, they're a *single* thing but > with multiple values that co-exist with each other in "superposition". That's correct. Until they're

Re: File::Find using a junction with exclude

2021-05-23 Thread Ralph Mellor
On Sun, May 23, 2021 at 9:15 PM Joseph Brenner wrote: > > Junctions continue to surprise me: That must be either that your mental model doesn't match the default design, or you're being tripped up by DWIMs, or WATs that can't be removed due to the overall DWIM of junctions (which usually work

Re: In regexes with :P5 compatibility turned-on, do embedded modifiers work?

2021-05-23 Thread Ralph Mellor
> It's looking to me like perl5's embedded pattern modifiers don't work > when used with raku's :P5 compatibility modifier... The `:P5` modifier only supports a small subset of P5 regexes. I don't think there's any champion who wishes to push it further. (There's been talk of deprecating it

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
On Fri, May 21, 2021 at 9:39 PM Joseph Brenner wrote: > > Thanks, yes the actual result is certainly consistent with the > junction applied at the top level, and not internally, which is > what I was expecting. A junction passed as an argument is immediately expanded unless a function is

Re: File::Find using a junction with exclude

2021-05-21 Thread Ralph Mellor
Your results are what I would expect. The hand crafted regex puts the exclusion logic in the *single* regex that's applied by the *single* call to the `find` function. The `any` value results in calling the `find` function *twice*, with 'mothera' excluded one time, and 'camel' excluded the

Re: What's going on with "given (junction) {when (value)...}"

2021-06-04 Thread Ralph Mellor
On Wed, Jun 2, 2021 at 11:57 AM William Michels wrote: > > Hi Ralph, Both prefix/postfix 'when' look okay on my Rakudo_2020.10 install: Only postfix in 2021.03: https://replit.com/@RalphMellor/FooACCEPT-junction#main.raku

Re: File::Find using a junction with exclude

2021-06-01 Thread Ralph Mellor
On Fri, May 21, 2021 at 4:36 PM Ralph Mellor wrote: > > * Things multiply. If *two* function arguments are junctions, and > each junction has, say, three elements, the function is set to be > called *six* times. That should have been *nine* times. > * The combinatio

Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
On Tue, Jun 1, 2021 at 4:02 AM Larry Wall wrote: > > In my opinion, the most consistent approach is to disallow any > autothreading of the argument to .ACCEPTS That sounds like a really appropriate simplification as I write this. > All those other smartmatches are sugar for .ACCEPTS, and >

Re: What's going on with "given (junction) {when (value)...}"

2021-06-01 Thread Ralph Mellor
Curiously, it works for postfix `when`: ``` $_ := any(4,3); {say 'postfix when'} when 3; # 3 when 3 { say 'prefix when' } # (no output) ``` -- love, raiph

Re: slurpy hash signatures

2021-04-23 Thread Ralph Mellor
On Wed, Apr 21, 2021 at 2:17 AM Joseph Brenner wrote: > Ralph Mellor wrote: > > [ list of idioms ] > > > Learn to use the right idioms as soon as possible. > > Okay. Where's the list of preferred idioms? The list you presented. If you had or have chosen %h3 as the

Re: Comparing Int and Num

2021-04-24 Thread Ralph Mellor
On Fri, Apr 16, 2021 at 7:22 AM sisyphus wrote: >> > The conversion from int to num looks sane. Sounds good. :) So presumably our early tentative conclusion of what we hope will pan out is that if one wants precise IEEE float behaviour, one uses `num` instead of `Num`. Right? > However, the

Re: Working with a regex using positional captures stored in a variable

2021-03-22 Thread Ralph Mellor
On Mon, Mar 22, 2021 at 2:50 PM yary wrote: > > how to get all nested captures worked for me ... not sure I agree with the > design I think the current flattening aspect is awkward in a couple ways: * Having to specify ``. I half like Brad's suggestion. * Having to write `.pairs` to extract

Re: Objects, TWEAK and return

2021-03-22 Thread Ralph Mellor
On Mon, Mar 22, 2021 at 2:12 PM yary wrote: > > It's not good practice to use "map" for side effects only, discarding > the returned value–which happens here I agree. > Would [using `for`] also work-around the lack of sink context in TWEAK? Yes. > I think it is a cause of the unexpected

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-06 Thread Ralph Mellor
On Tue, Apr 6, 2021 at 11:54 AM sisyphus wrote: > 1/10 == 1e1 # True Aiui this is correct (and to me intuitive) behaviour described here: https://docs.raku.org/language/numerics#Numeric_infectiousness So if there's a `Num` (float) in a numeric operation (like `==`) then any other number

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-06 Thread Ralph Mellor
> 1/10 == 1e1 # True > > Aiui this is correct (and to me intuitive) behaviour described here: Except A) that's not what the doc says, and B) how does one compare numbers *without* infection, if that's what's going on? So it probably makes sense to ignore at least that part of my previous email.

Re: "rule" declarator: Different results for 'unadorned' match vs unnamed/named captures? (in re Grammars...).

2021-03-12 Thread Ralph Mellor
On Thu, Mar 11, 2021 at 8:53 PM William Michels wrote: > > I think there's something going on with the examples below, as I'm > seeing different results when comparing a basic "rule" match vs either > unnamed or named "rule" captures. All your examples are correct according to my current

Re: Objects, TWEAK and return

2021-03-14 Thread Ralph Mellor
On Sun, Mar 14, 2021 at 2:12 AM Brad Gilbert wrote: > > Ralph, the last value in all functions are not sunk by default, > so of course the last one in `TWEAK` is not sunk by default. Right. Thanks for correcting this misleading part of my explanation. > The bug is that the calling code is not

Re: Working with a regex using positional captures stored in a variable

2021-03-18 Thread Ralph Mellor
On Thu, Mar 18, 2021 at 12:59 AM yary wrote: > > As it is I get same kinds of errors in the REPL, perhaps it is MacOS > with Linenoise that's mucking that up. I can confirm your new test code also works fine in both program and repl forms in 2020.12. Though obviously the case you mark as

Re: Objects, TWEAK and return

2021-03-21 Thread Ralph Mellor
On Sun, Mar 21, 2021 at 9:47 PM wrote: > > Waw! :) Following your examples and suggestions, these work: > > > class { submethod TWEAK(-->Nil) { Any.map: {say 99} } }.new; > > class { submethod TWEAK { sink Any.map: {say 99} } }.new; > > class { submethod TWEAK { eager Any.map: {say 99} }

Re: Working with a regex using positional captures stored in a variable

2021-03-19 Thread Ralph Mellor
On Fri, Mar 19, 2021 at 6:12 PM yary wrote: > > I don't know how to get the result. > DB<1> $word = qr/(\w+)/; > DB<2> $AwithB = qr/$word with $word/ > DB<3> $_ = 'Interpolating regexes with arbitrary captures is fun!' > DB<4> x /$AwithB.*is $word/ A Raku equivalent: my $word = '(\w+)'; my

Re: Working with a regex using positional captures stored in a variable

2021-03-20 Thread Ralph Mellor
On Wed, Mar 17, 2021 at 7:17 PM William Michels via perl6-users wrote: > > ("If the first character inside is anything other than an alpha it doesn't > capture"). > It should be added to the Raku Docs ASAP. Fyi, here's how Larry Wall expressed it 15-18 years ago: > A leading alphabetic

Re: Objects, TWEAK and return

2021-03-13 Thread Ralph Mellor
Here's a golf: class { submethod TWEAK { Any.map: {say 99} } }.new; # class { submethod TWEAK { Any.map: {say 99}; 42 } }.new; # 99 class { submethod TWEAK (--> 42) { Any.map: {say 99} } }.new; # 99 The last line in a `BUILD` or `TWEAK` submethod is not eagerly

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
Er, by wfm I mean it matches 「Is」 as the code suggests. On Wed, Mar 17, 2021 at 10:32 PM Ralph Mellor wrote: > > Works for me in Rakudo 2020.12. > > On Wed, Mar 17, 2021 at 9:33 PM yary wrote: > > > > The "Interpolation" section of the raku docs use strings a

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
Works for me in Rakudo 2020.12. On Wed, Mar 17, 2021 at 9:33 PM yary wrote: > > The "Interpolation" section of the raku docs use strings as the elements of > building up a larger regex from smaller pieces, but the example that looks > fruitful isn't working in my raku. This is taken from >

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
And when I cut/paste from the doc, the number example works too, in both script and repl. On Wed, Mar 17, 2021 at 10:33 PM Ralph Mellor wrote: > > Er, by wfm I mean it matches 「Is」 as the code suggests. > > On Wed, Mar 17, 2021 at 10:32 PM Ralph Mellor wrote: > > > >

Re: Working with a regex using positional captures stored in a variable

2021-03-17 Thread Ralph Mellor
> 1. The list you posted is fantastic ("If the first character inside is > anything other > than an alpha it doesn't capture"). It should be added to the Raku Docs ASAP. Not the list, right? Just the rule. (There are dozens of kinds of assertions. No one is going to remember the list.) If you

Re: Find Packages with prefix ...

2021-03-07 Thread Ralph Mellor
Afaik, existing mechanisms (`use`, `zef`, `-I`) support the following: > Within this namespace, I would ideally designate > SuperDuperProgram::Modules to be the namespace > that modules would live under. > These modules would have their own git repos and > depend on SuperDuperProgram being

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
One last final piece I want to add in while we prepare to document what is worth documenting in issues is what I was trying to get at in this comment: https://www.reddit.com/r/perl/comments/93dabg/perl_6_small_stuff_4_why_perl_isnt_cobol_nor/e3etgvf/ Reviewing it I think I got a couple things

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
On Thu, Apr 8, 2021 at 3:25 AM Ralph Mellor wrote: > > On Wed, Apr 7, 2021 at 2:12 PM sisyphus wrote: > > > 2) Update Issue 5013 to better reflect the current state of > > the bugginess of "%.*g" formatting. > > Yeah. I'm focusing on 5519 ("sprintf %f

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-08 Thread Ralph Mellor
Another thing I've bumped into in my travels: > From: Zefram > Sent: Thursday, February 18, 2016 4:08 AM > To: perl5-port...@perl.org > Subject: Re: [perl #127182] One digit short to correctly stringify a double >> To have different NVs stringify identically is surprising; to have the >> closest

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-07 Thread Ralph Mellor
On Wed, Apr 7, 2021 at 3:29 PM Simon Proctor wrote: > > Would =~= be what you're looking for? To quote Wikipedia, "A floating-point number is a rational number". Rob wants to compare a float with its exact equivalent rational and get True if they're exactly the same and False otherwise. --

Re: Accurate conversion of Num to Rat (and comparing Num and Rat)

2021-04-07 Thread Ralph Mellor
On Wed, Apr 7, 2021 at 2:12 PM sisyphus wrote: > > I think the important flaw is raku's incapacity to convert a Num > to its exact Rat/FatRat expression. My 2c is that I agree that that needs to be addressed. I currently see that as something to first address via sprintf. Do you agree? I get

Re: Comparing Int and Num

2021-04-15 Thread Ralph Mellor
On Wed, Apr 14, 2021 at 3:10 AM sisyphus wrote: > > Is this a bug that I ought to report ? I'm not yet convinced the issues you showed are classifiable as bugs. Part of my reasoning for my conservatism is per the guidance Larry provided in the design docs. In particular, per design doc S02: >

Re: slurpy hash signatures

2021-04-18 Thread Ralph Mellor
On Sun, Apr 18, 2021 at 8:00 PM Joseph Brenner wrote: > > Before I get started here, a small point about defining hashes. > There are various ways that work: > >my %h1 = ( 'ha' => 1, 'ho' => 2, 'hum' => 3 ); >my %h2 = ( ha => 1, ho => 2, hum => 3 ); >my %h3 = ha => 1, ho => 2,

Re: slurpy hash signatures

2021-04-19 Thread Ralph Mellor
On Mon, Apr 19, 2021 at 4:03 PM Andy Bach wrote: > > Very impressive and complete explanation, thanks! Thanks for that feedback, it's very helpful. I enjoy trying to help, but it's hard to ensure I've conveyed a tone of respect for whoever I'm replying to, at the same time as trying to keep

Re: slurpy hash signatures

2021-04-19 Thread Ralph Mellor
Btw, I had misunderstood ERN when, in 2018, I wrote the email message I linked in the Note section of my previous email. ERN is an intuitive sense that some movement you are initiating is in some way a mistake. For example, quoting keys of a pair. It's often unconscious, and, aiui, ignoring it

Re: gather take eager syntax

2021-04-20 Thread Ralph Mellor
You've gotten a pile of great answers. :) I'll add another to the pile, but omit explanation. say % = ["foo" => "bar"], "baz" => 42; # {foo bar => baz => 42} say % = ["foo" => "bar"]; # {foo => bar} say % = ["foo" => "bar"],; # Odd number ... Only saw:

  1   2   >