Thanks raiph for everything!

Including getting me to upgrade my Raku, "Welcome to Rakudo(tm) v2021.02.1.

Implementing the Raku(tm) programming language v6.d.

Built on MoarVM version 2021.02."


As it is I get same kinds of errors in the REPL, perhaps it is MacOS with
Linenoise that's mucking that up. The code in a file does better, matching
the docs. Still I had hoped to work around these issues by interpolating
with the bare variables not inside of angle-brackets. Here's the test code-


my $str = ' grr huh yeah 388 boo! ';

say $str ~~ / (\d+) \s (\w+) /; # 388 boo

say "Match 0=$0, 1=$1"; # Match 0=388, 1=boo

say  "=== below is the interesting case";

my $rd = /(\d+)/;

my $rw = /(\w+)/;

say $str.match: / $rd \s $rw /; # 388 boo

say "Match 0=$0, 1=$1"; # Match 0=, 1=

say "=== below shows literal string matching";

my $sd = '(\d+)';

my $sw = '(\w+)';

$str ~= "$sd $sw";

say $str.match: / ($sd) \s ($sw) /; # (\d+) (\w+)

say "Match 0=$0, 1=$1"; # Match 0=(\d+), 1=(\w+)

I had hoped that by directly interpolating $rd and $rw they would fill in
the top-level match object and fill in $0, $1 – but it has the same issue
as Joe's original example. It matches the right text but doesn't fill in
the top-level match.

-y


On Wed, Mar 17, 2021 at 6:55 PM Ralph Mellor <ralphdjmel...@gmail.com>
wrote:

> > 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 were to add just the line you
> suggest then
> you'd be able to do it ASAP.
>
> > 2. There are some shortcuts that don't seem to follow a set pattern. For
> example
> > a named capture can be accessed using $<myname> instead of $/<myname> ;
> > the "/' can be elided. Do you have a method you can share for remembering
> > these sorts of shortcuts? Or are they disfavored?
>
> I know you're asking Brad, but fwiw my overall method for mnemonics is to
> stay
> creative and bring in visual and audio elements (like images and rhyming)
> and
> weave them into a little made up story that fits in with an overall
> adventure story
> about Raku. The elements would be ones that work for a given individual
> for a
> given aspect of a given feature of Raku, with the story being made up by
> the
> person doing the learning.
>
> Thus, for example, I might note that the @ symbol looks something like a
> `0`
> and is sounded out as "at" and have a kid tell me a little story they
> imagine
> getting added to the twitter profile of someone they know about programming
> that involves the fact that array indexing is `0` based, thus giving
> them a strong
> reminder of the latter aspect.
>
> Fwiw I'm not seeing much value in developing one for eliding the `/`.
> If a dev doesn't
> know they can elide the `/` when writing code, then no harm done; just
> leave it in.
> If a dev is *reading* code and sees syntax of the form `$<foo>` and
> wonders what
> it is, they can type `$<` into the search box in the doc and get a
> match. I personally
> found it really easy to remember because it's so simple and used so
> frequently. I
> think mnemonics
>
> > 3. Finally, I've never seen in the Perl6/Raku literature the motto you
> cite:
> > "One of the mottos of Raku, is that it is ok to confuse a new programmer,
> > it is not ok to confuse an expert."
>
> I think that's a reasonable distillation of Larry's perspective. It's
> another way
> of expressing that Python is good as a first language, Raku as a last one.
>
> Consider the options:
>
> * Ok to confuse a new programmer or an expert. (Not a good option.)
>
> * Ok to confuse an expert, not Ok to confuse a new programmer. ScratchJr?
>
> * Not Ok to confuse a new programmer or an expert. ScratchJr?
>
> > [ The motto I prefer is from Larry Wall: "...easy things should stay
> easy,
> > hard things should get easier, and impossible things should get hard...
> ."
>
> I like that one too. I daresay I prefer it too. But for it to work, it
> really needs
> to be Ok to confuse a new programmer but not Ok to confuse an expert.
>
> Note that easy things being easy does not mean that new programmers
> won't get confused. For example, a new Raku programmer who is used
> to Perl might  be confused that `<$foo>` does not capture in Raku, even
> though it does in Perl. But it's still easy to capture; you write
> `<foo=$foo>`.
>
> But when *experts* are *systematically* confused, i.e. *all* experts just
> keep falling for the same trap, then impossible things won't just be hard,
> they'll stop happening.
>
> Note that I say that as a non-expert in many, many areas of Raku. What
> I *do* know is that whenever I encounter something that surprises me,
> and keep an open mind about what's going on, no matter how annoyed
> I am or convinced Raku is being stupid, I almost always eventually arrive
> at an interim conclusion it's appropriate as is.
>
> *Almost* always. And always an *interim* conclusion at best. That is to
> say, I retain an eternally open mind toward all such things. So if someone
> were to add a table to the doc listing all the assertion types, noting
> which
> ones capture and which ones don't, rather than just the one rule ("starts
> with an alpha") I'd be open minded about what the outcome would be.
> Likewise if Brad reveals some master method he has for coming up with
> a mnemonic covering dropping the `/` in `$<foo>`. And if it turns out Larry
> has never said something directly to the effect that Brad has mentioned,
> I'd be surprised but curious why I was surprised.
>
> --
> love, raiph
>

Reply via email to