Re: Please create a Raku community channel

2021-03-13 Thread Darren Duncan

On 2021-03-13 2:27 p.m., Vadim Belman wrote:

Concerning the accidental duplication of projects, aside of the fact that it is 
dissipation of scarce community resources, the good side is that there will be 
two options to choose from. I will be happy to see both project launched. One 
could eventually become part of the official site, the other may be ran 
independently. One way or another I hope there will be more gains from it than 
loses.


These projects could be merged if both authors are conducive to it, now that 
this is known.


If there is reason for them to stay separate, I don't see why they can't BOTH be 
official sites, like Version 1 plus Version A, no reason to have to pick one.


-- Darren Duncan


Re: Please create a Raku community channel

2021-03-13 Thread JJ Merelo
I don't think it's a duplication (or, as might be the case, triplication)
of resources, or a waste of resources. I learned early on that the
"resources" of the community is not, as in a company, a pool with a
constant value from which you, as in yourself, can draw to push forward
your favorite project. On the contrary, it falls on you to try and steer
anyone's favorite project in a direction that could help *your* favorite
project, and also to prop up your project so that it's open to
contributions in a way that don't break or derail it. That's the best you
can do. Also, a community with three or four projects in the same direction
(documentation or whatever) is a great community; at the end of the day,
you can profit from all three, even if it's in a tiny detail or simply on
the effort put into implementing a standard.
That said, the initial problem still stands: there's no way to make the
whole community know something that might be important, such as the doc
site dropping from some parts of the internet, or an adoption drive for
some community module, really, whatever.  Voting for the RSC... And that's
got several sub-problems
1. We need to define community. If it's someone with a commit bit in every
repo of the 5 (yes 5) Raku organizations, well, that's a tall order. There
are myriad teams, some people have a commit bit just in one repo. And then
this excludes people who contribute to the community in a different way,
from organizing challenges to curating subreddits through answering
questions in StackOverflow.
2. Even if you include all and everyone, you need to define what would go
into that channel. As in a logging system, you need to define the severity
of the issue to make the channel really relevant and actionnable. That, of
course, goes against the fact that it needs to be open to everyone, and
also interactive.
3. There's no single communication channel that's a) used by everyone and
b) accessed by everyone on a hourly, or even daily, basis.

So there's really no solution to your problem, other than try and tell
everyone, many times, in different channels, whatever the heck you're
interested on, and it will eventually grab the attention of the
stakeholders (and don't have me defining stakeholders...).

I really appreciate everyone's contributions, I really do. So heartfelt
thanks to all :-)

Cheers

JJ

El sáb, 13 mar 2021 a las 23:27, Vadim Belman () escribió:

>
> I would like to make an important note here. Up to my knowledge, the new
> documentation site project is personal initiative of Alexander (Altai-man)
> of which nobody of RSC members was informed about. For this reason it is
> rather unlikely that any notification would be issued on any official
> channel, would such one existed. I personally got to know about it the
> moment Alexander posted his request for help on IRC.
>
> Apparently, the above paragraph doesn't say that we don't need an official
> channel of a kind. I was asking a similar question ~1.5yr ago. As it is
> with many other matters, this one needed some time to gain momentum.
> Perhaps, the time has come to get it answered.
>
> Concerning the accidental duplication of projects, aside of the fact that
> it is dissipation of scarce community resources, the good side is that
> there will be two options to choose from. I will be happy to see both
> project launched. One could eventually become part of the official site,
> the other may be ran independently. One way or another I hope there will be
> more gains from it than loses.
>
> Best regards,
> Vadim Belman
>
> > On Mar 13, 2021, at 2:21 AM, Richard Hainsworth 
> wrote:
> >
> > This is a request to the Raku Coordinating Council that was elected at
> the end of last year.
> >
> > Please name a channel where community wide plans or announcements are
> made. Or may be establish one.
> >
> > I found out yesterday by the intervention of a regular participant in
> the community that a new documentation website is being worked on.
> >
> > I joined a conversation on the raku-dev IRC and discovered that the
> plans are quite far established. Since I have been working full-time for
> three months on a project that could (not should!!) serve as the
> infra-structure of a new site, I was really quite surprised and I am sure
> many of you will understand it was jarring.
> >
> > I follow all the conversations on this email list. I have found it very
> difficult (due to my own technical incompetence relating to github) to set
> up my github preferences to get regular notification about issues. I have
> also found that the IRC chats are streams of consciousness that are
> difficult for me to manage.
> >
> > It seems however, that it is my fault that I was taken by surprise  by
> the news of a different documentation website and that I should have been
> following all the issues on the documentation repo or the problem solving
> repo.
> >
> > It *IS* reasonable for Raku developers and community organisers to make
> it the 

Re: Objects, TWEAK and return

2021-03-13 Thread Brad Gilbert
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.
This is intended behaviour.

It is up to the code that calls a function to sink the result if that is
the desired behaviour.

sub foo {
'a b c'.words».uc.map: *.say;
}

my $ = foo(); # nothing is printed

sink foo(); # «A␤B␤C␤» is printed

The bug is that the calling code is not sinking the result.


On Sat, Mar 13, 2021 at 8:05 PM Ralph Mellor 
wrote:

> 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 evaluated
> by default.
>
> That sounds like a bug to me. But if not, and in the meantime,
> because your `$!filelist.lines...` line is the last one in your `TWEAK`
> submethod, the `@!show` array is being left empty, so the value to
> the right of `%` evaluates to zero, hence the error message you're seeing.
>
> On Sat, Mar 13, 2021 at 8:30 PM  wrote:
> >
> > Hi,
> >
> > When working with this week challenge for the PerlWeeklyChallenge, I
> noticed this behaviour with TWEAK:
> >
> > This does not work:
> >   submethod TWEAK {
> > $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a,
> $b )  });
> >   }
> >
> > This works:
> >   submethod TWEAK {
> > $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a,
> $b )  });
> > return;
> >   }
> >
> > It also works with other commands instead of 'return' (like assigning a
> value to a variable). From the examples in the documentation, I am not
> certain this is the expected behaviour.
> >
> > Thanks for this extraordinary language,
> >
> > Joan
> >
> >
> > P.S: This is the context where the command appears.  Apologies for the
> messy-Raku,
> > --
> > use Test;
> >
> > my $data = '1709363,"Les Miserables Episode 1: The Bishop (broadcast
> date: 1937-07-23)"
> > 1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
> > 1723781,"Les Miserables Episode 3: The Trial (broadcast date:
> 1937-08-06)"
> > 1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
> > 1646043,"Les Miserables Episode 5: The Grave (broadcast date:
> 1937-08-20)"
> > 1714640,"Les Miserables Episode 6: The Barricade (broadcast date:
> 1937-08-27)"
> > 1714640,"Les Miserables Episode 7: Conclusion (broadcast date:
> 1937-09-03)"';
> >
> > class Movies {
> >
> >   has $.starttime;
> >   has $.currenttime;
> >   has $.filelist;
> >   has @!show; # ( [ time, show ] )
> >
> >   submethod TWEAK {
> > # miliseconds -> seconds
> > $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a,
> $b )  });
> > return;
> >   }
> >
> >   method what-show() {
> > my $position =  ( $!currenttime - $!starttime ) %
> @!show[*;0].sum/1000;
> > my ($time, $show);
> > for @!show[*;0] -> $show-time {
> >   $time += $show-time;
> >   return @!show[$show++;1] if $time > $position;
> > }
> >   }
> > }
> >
> > my $mv = Movies.new(
> >   starttime   => '1606134123',
> >   currenttime => '1614591276',
> >   filelist=> $data
> > );
> >
> > is $mv.what-show, '"Les Miserables Episode 1: The Bishop (broadcast
> date: 1937-07-23)"';
>


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 evaluated
by default.

That sounds like a bug to me. But if not, and in the meantime,
because your `$!filelist.lines...` line is the last one in your `TWEAK`
submethod, the `@!show` array is being left empty, so the value to
the right of `%` evaluates to zero, hence the error message you're seeing.

On Sat, Mar 13, 2021 at 8:30 PM  wrote:
>
> Hi,
>
> When working with this week challenge for the PerlWeeklyChallenge, I noticed 
> this behaviour with TWEAK:
>
> This does not work:
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
>   }
>
> This works:
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
> return;
>   }
>
> It also works with other commands instead of 'return' (like assigning a value 
> to a variable). From the examples in the documentation, I am not certain this 
> is the expected behaviour.
>
> Thanks for this extraordinary language,
>
> Joan
>
>
> P.S: This is the context where the command appears.  Apologies for the 
> messy-Raku,
> --
> use Test;
>
> my $data = '1709363,"Les Miserables Episode 1: The Bishop (broadcast date: 
> 1937-07-23)"
> 1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
> 1723781,"Les Miserables Episode 3: The Trial (broadcast date: 1937-08-06)"
> 1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
> 1646043,"Les Miserables Episode 5: The Grave (broadcast date: 1937-08-20)"
> 1714640,"Les Miserables Episode 6: The Barricade (broadcast date: 1937-08-27)"
> 1714640,"Les Miserables Episode 7: Conclusion (broadcast date: 1937-09-03)"';
>
> class Movies {
>
>   has $.starttime;
>   has $.currenttime;
>   has $.filelist;
>   has @!show; # ( [ time, show ] )
>
>   submethod TWEAK {
> # miliseconds -> seconds
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
> return;
>   }
>
>   method what-show() {
> my $position =  ( $!currenttime - $!starttime ) % @!show[*;0].sum/1000;
> my ($time, $show);
> for @!show[*;0] -> $show-time {
>   $time += $show-time;
>   return @!show[$show++;1] if $time > $position;
> }
>   }
> }
>
> my $mv = Movies.new(
>   starttime   => '1606134123',
>   currenttime => '1614591276',
>   filelist=> $data
> );
>
> is $mv.what-show, '"Les Miserables Episode 1: The Bishop (broadcast date: 
> 1937-07-23)"';


Re: Objects, TWEAK and return

2021-03-13 Thread Brad Gilbert
I think that this is caused because it is returning a 「Sequence」 that is
not getting sunk.
This is because the last value from a function is never sunk in that
function.

You could also use 「eager」 「sink」 or follow it with 「Nil」 or some other
value (instead of 「return」)

eager $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: (
$a, $b )  });
sink $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a,
$b )  });
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )
 });  Nil
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )
 });  'some other value'

You can also make 「TWEAK」 return a 「Nil」 in the signature (or any
constant/literal).

submethod TWEAK (-->Nil) { … }

Since the last value in the function is never returned it is also sunk.

---

It might be a good idea if the code that calls 「TWEAK」 (and maybe 「BUILD」)
sinks any result that they get.
Or maybe it should only sink 「Sequence」 values.

There are good reasons for allowing a 「submethod」 to return a value that
doesn't get sunk, so that should not change.

At any rate I don't think there is a bug in how 「submethod TWEAK」 is
compiled and run.
That part is working as intended.

On Sat, Mar 13, 2021 at 2:30 PM  wrote:

> Hi,
>
> When working with this week challenge for the PerlWeeklyChallenge
> , I noticed this behaviour with TWEAK:
>
> *This does not work:*
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
> )  });
>   }
>
> *This works:*
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
> )  });
> return;
>   }
>
> It also works with other commands instead of 'return' (like assigning a
> value to a variable). From the examples in the documentation, I am not
> certain this is the expected behaviour.
>
> Thanks for this extraordinary language,
>
> Joan
>
>
> P.S: This is the context where the command appears.  Apologies for the
> messy-Raku,
> --
> use Test;
>
> my $data = '1709363,"Les Miserables Episode 1: The Bishop (broadcast date:
> 1937-07-23)"
> 1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
> 1723781,"Les Miserables Episode 3: The Trial (broadcast date: 1937-08-06)"
> 1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
> 1646043,"Les Miserables Episode 5: The Grave (broadcast date: 1937-08-20)"
> 1714640,"Les Miserables Episode 6: The Barricade (broadcast date:
> 1937-08-27)"
> 1714640,"Les Miserables Episode 7: Conclusion (broadcast date:
> 1937-09-03)"';
>
> class Movies {
>
>   has $.starttime;
>   has $.currenttime;
>   has $.filelist;
>   has @!show; # ( [ time, show ] )
>
>   submethod TWEAK {
> # miliseconds -> seconds
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
> )  });
> return;
>   }
>
>   method what-show() {
> my $position =  ( $!currenttime - $!starttime ) % @!show[*;0].sum/1000;
> my ($time, $show);
> for @!show[*;0] -> $show-time {
>   $time += $show-time;
>   return @!show[$show++;1] if $time > $position;
> }
>   }
> }
>
> my $mv = Movies.new(
>   starttime   => '1606134123',
>   currenttime => '1614591276',
>   filelist=> $data
> );
>
> is $mv.what-show, '"Les Miserables Episode 1: The Bishop (broadcast date:
> 1937-07-23)"';
>


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

2021-03-13 Thread Brad Gilbert
It makes <…> more consistent precisely because <$pattern> doesn't capture.

If the first character inside is anything other than an alpha it doesn't
capture.
Which is a very simple description of when it captures.

 doesn't capture because of the 「?」
 doesn't capture because of the 「!」
<.ws> doesn't capture because of the 「.」
<> doesn't capture because of the 「&」
<$pattern> doesn't capture because of the 「$」
<$0> doesn't capture because of the 「$」
<@a> doesn't capture because of the 「@」
<[…]> doesn't capture because of the 「[」
<-[…]> doesn't capture because of the 「-]
<:Ll> doesn't capture because of the 「:」

For most of those, you don't actually want it to capture.
With 「.」 the whole point is that it doesn't capture.

 does capture because it starts with an alpha
 does capture because it starts with an alpha

$0 = <$pattern> doesn't capture to $, but does capture to $0
$ = <$pattern> captures because of $ =

It would be a mistake to just make <$pattern> capture.
Consistency is perhaps Raku's most important feature.

One of the mottos of Raku, is that it is ok to confuse a new programmer, it
is not ok to confuse an expert.
An expert in Raku understands the deep fundamental ways that Raku is
consistent.
So breaking consistency should be very carefully considered.

In this case, there is very little benefit.
Even worse, you then have to come up with some new syntax to prevent it
from capturing when you don't want it to.
That new syntax wouldn't be as guessible as it currently is. Which again
would confuse experts.

If anyone seriously suggests such a change, I will vehemently fight to
prevent it from happening.

I would be more likely to accept <=$pattern> being added as a synonym to
.

On Sat, Mar 13, 2021 at 3:30 PM Joseph Brenner  wrote:

> Thanks much for your answer on this.  I think this is the sort of
> trick I was looking for:
>
> Brad Gilbert wrote:
>
> > You can put it back in as a named
>
> > > $input ~~ / 
> > 「9 million」
> >  pattern => 「9 million」
> >   0 => 「9」
> >   1 => 「million」
>
> That's good enough, I guess, though you need to know about the
> issue... is there some reason it shouldn't happen automatically,
> using the variable name to label the captures?
>
> I don't think this particular gotcha is all that well
> documented, though I guess there's a reference to this being a
> "known trap" in the documentation under "Regex interpolation"--
> but that's the sort of remark that makes sense only after you know
> what its talking about.
>
> I have to say, my first reaction was something like "if they
> couldn't get this working right, why did they put it in?"
>
>
> On 3/11/21, Brad Gilbert  wrote:
> > If you interpolate a regex, it is a sub regex.
> >
> > If you have something like a sigil, then the match data structure gets
> > thrown away.
> >
> > You can put it back in as a named
> >
> > > $input ~~ / 
> > 「9 million」
> >  pattern => 「9 million」
> >   0 => 「9」
> >   1 => 「million」
> >
> > Or as a numbered:
> >
> > > $input ~~ / $0 = <$pattern>
> > 「9 million」
> >  0 => 「9 million」
> >   0 => 「9」
> >   1 => 「million」
> >
> > Or put it in as a lexical regex
> >
> > > my regex pattern { (\d+) \s+ (\w+) }
> > > $input ~~ /   /
> > 「9 million」
> >  pattern => 「9 million」
> >   0 => 「9」
> >   1 => 「million」
> >
> > Or just use it as the whole regex
> >
> > > $input ~~ $pattern # variable
> > 「9 million」
> >  0 => 「9」
> >  1 => 「million」
> >
> > > $input ~~  # my regex pattern /…/
> > 「9 million」
> >  0 => 「9」
> >  1 => 「million」
> >
> > On Thu, Mar 11, 2021 at 2:29 AM Joseph Brenner 
> wrote:
> >
> >> Does this behavior make sense to anyone?  When you've got a regex
> >> with captures in it, the captures don't work if the regex is
> >> stashed in a variable and then interpolated into a regex.
> >>
> >> Do capture groups need to be defined at the top level where the
> >> regex is used?
> >>
> >> { #  From a code example in the "Parsing" book by Moritz Lenz, p. 48,
> >> section 5.2
> >>my $input = 'There are 9 million bicycles in beijing.';
> >>if $input ~~ / (\d+) \s+ (\w+) / {
> >>say $0.^name;  # Match
> >>say $0;# 「9」
> >>say $1.^name;  # Match
> >>say $1;# 「million」
> >>say $/;
> >> # 「9 million」
> >> #  0 => 「9」
> >> #  1 => 「million」
> >>}
> >> }
> >>
> >> say '---';
> >>
> >> { # Moving the pattern to var which we interpolate into match
> >>my $input = 'There are 9 million bicycles in beijing.';
> >>my $pattern = rx{ (\d+) \s+ (\w+) };
> >>if $input ~~ / <$pattern> / {
> >>say $0.^name;  # Nil
> >>say $0;# Nil
> >>say $1.^name;  # Nil
> >>say $1;# Nil
> >>say $/;# 「9 million」
> >>}
> >> }
> >>
> >> In the second case, the match clearly works, but it 

Re: Objects, TWEAK and return

2021-03-13 Thread Vadim Belman

At the first glance it looks like bug. Possibly a result of over-optimization. 
Worth opening an issue at https://github.com/rakudo/rakudo/issues

Best regards,
Vadim Belman

> On Mar 13, 2021, at 3:29 PM, mimosin...@gmail.com wrote:
> 
> Hi,
> 
> When working with this week challenge for the PerlWeeklyChallenge 
> , I noticed this behaviour with TWEAK:
> 
> This does not work:
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
>   }
> 
> This works:
>   submethod TWEAK {
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
> return;
>   }
> 
> It also works with other commands instead of 'return' (like assigning a value 
> to a variable). From the examples in the documentation, I am not certain this 
> is the expected behaviour.
> 
> Thanks for this extraordinary language,
> 
> Joan
> 
> 
> P.S: This is the context where the command appears.  Apologies for the 
> messy-Raku, 
> --
> use Test;
> 
> my $data = '1709363,"Les Miserables Episode 1: The Bishop (broadcast date: 
> 1937-07-23)"
> 1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
> 1723781,"Les Miserables Episode 3: The Trial (broadcast date: 1937-08-06)"
> 1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
> 1646043,"Les Miserables Episode 5: The Grave (broadcast date: 1937-08-20)"
> 1714640,"Les Miserables Episode 6: The Barricade (broadcast date: 1937-08-27)"
> 1714640,"Les Miserables Episode 7: Conclusion (broadcast date: 1937-09-03)"';
> 
> class Movies {
> 
>   has $.starttime;
>   has $.currenttime;
>   has $.filelist;
>   has @!show; # ( [ time, show ] )
> 
>   submethod TWEAK {
> # miliseconds -> seconds
> $!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b )  
> });
> return;
>   }
> 
>   method what-show() {
> my $position =  ( $!currenttime - $!starttime ) % @!show[*;0].sum/1000;
> my ($time, $show);
> for @!show[*;0] -> $show-time {
>   $time += $show-time;
>   return @!show[$show++;1] if $time > $position;
> }
>   }
> }
> 
> my $mv = Movies.new( 
>   starttime   => '1606134123',
>   currenttime => '1614591276',
>   filelist=> $data
> );
> 
> is $mv.what-show, '"Les Miserables Episode 1: The Bishop (broadcast date: 
> 1937-07-23)"';



Re: Please create a Raku community channel

2021-03-13 Thread Vadim Belman


I would like to make an important note here. Up to my knowledge, the new 
documentation site project is personal initiative of Alexander (Altai-man) of 
which nobody of RSC members was informed about. For this reason it is rather 
unlikely that any notification would be issued on any official channel, would 
such one existed. I personally got to know about it the moment Alexander posted 
his request for help on IRC.

Apparently, the above paragraph doesn't say that we don't need an official 
channel of a kind. I was asking a similar question ~1.5yr ago. As it is with 
many other matters, this one needed some time to gain momentum. Perhaps, the 
time has come to get it answered.

Concerning the accidental duplication of projects, aside of the fact that it is 
dissipation of scarce community resources, the good side is that there will be 
two options to choose from. I will be happy to see both project launched. One 
could eventually become part of the official site, the other may be ran 
independently. One way or another I hope there will be more gains from it than 
loses.

Best regards,
Vadim Belman

> On Mar 13, 2021, at 2:21 AM, Richard Hainsworth  
> wrote:
> 
> This is a request to the Raku Coordinating Council that was elected at the 
> end of last year.
> 
> Please name a channel where community wide plans or announcements are made. 
> Or may be establish one.
> 
> I found out yesterday by the intervention of a regular participant in the 
> community that a new documentation website is being worked on.
> 
> I joined a conversation on the raku-dev IRC and discovered that the plans are 
> quite far established. Since I have been working full-time for three months 
> on a project that could (not should!!) serve as the infra-structure of a new 
> site, I was really quite surprised and I am sure many of you will understand 
> it was jarring.
> 
> I follow all the conversations on this email list. I have found it very 
> difficult (due to my own technical incompetence relating to github) to set up 
> my github preferences to get regular notification about issues. I have also 
> found that the IRC chats are streams of consciousness that are difficult for 
> me to manage.
> 
> It seems however, that it is my fault that I was taken by surprise  by the 
> news of a different documentation website and that I should have been 
> following all the issues on the documentation repo or the problem solving 
> repo.
> 
> It *IS* reasonable for Raku developers and community organisers to make it 
> the responsibility of a participant to follow conversations, but I would 
> suggest that the current scattering of conversations, on the IRC chat, 
> various github repositories, this email list, is not *optimal* for the 
> development of a coherent Raku community. It is also - I would suggest - a 
> waste of human resources if the same objectives are pursued by multiple 
> enthusiasts without any coordination or communication.
> 
> If the Raku Council were to designate some channel, whether its an email 
> list, an IRC chat, or a github repo, or maybe a discord or slack or other 
> channel as the main community resource, then I would make sure I could read 
> all the messages there and stay in touch with what is happening.
> 
> Hence my request to the Raku council to consider improving communication 
> between developers and the wider Raku community.
> 
> Regards
> 
> Richard Hainsworth
> 
> aka finanalyst
> 
> 



Re: Fwd: Working with a regex using positional captures stored in a variableperl6-us...@perl.org

2021-03-13 Thread Joseph Brenner
Thanks much for the response.  Though this isn't particularly
about anything mentioned in your book, of course, I was starting
with one of your examples then mutating it...

Moritz Lenz wrote:

> When the match is in a different variable, you need to access the
> capture group as $match[0] instead of its alias $/[0].

I had the feeling you might be saying something like this, that
there was a way to access the 0th capture group like so:

   if $input ~~ / <$pattern> / {
   say $pattern[0]; # rx{ (\d+) \s+ (\w+) }
   say $input[0];   # There are 9 million bicycles in beijing.
   # Aside: funny there's no error: they're strings, not arrays
  }

I would guess you meant something like this, though:

   if $input ~~ /  / {
   say $[0]; # 「9」
   say $[1]; # 「million」
   }

Which certainly works.


On 3/11/21, Moritz Lenz  wrote:
> Hi there,
>
> On 11.03.21 17:43, William Michels wrote:
>> Hi Moritz your book is mentioned below. Care to chime in? Reply to
>> perl6-users  .
>>
>> Thx, Bill.
>> W. Michels, Ph.D.
>>
>> -- Forwarded message -
>> From: Joseph Brenner 
>> Date: Thu, Mar 11, 2021 at 12:28 AM
>> Subject: Working with a regex using positional captures stored in a
>> variable
>> To: perl6-users 
>>
>>
>> Does this behavior make sense to anyone?  When you've got a regex
>> with captures in it, the captures don't work if the regex is
>> stashed in a variable and then interpolated into a regex.
>>
>> Do capture groups need to be defined at the top level where the
>> regex is used?
>>
>> { #  From a code example in the "Parsing" book by Moritz Lenz, p. 48,
>> section 5.2
>>my $input = 'There are 9 million bicycles in beijing.';
>>if $input ~~ / (\d+) \s+ (\w+) / {
>>say $0.^name;  # Match
>>say $0;# 「9」
>>say $1.^name;  # Match
>>say $1;# 「million」
>>say $/;
>> # 「9 million」
>> #  0 => 「9」
>> #  1 => 「million」
>>}
>> }
>>
>> say '---';
>>
>> { # Moving the pattern to var which we interpolate into match
>>my $input = 'There are 9 million bicycles in beijing.';
>>my $pattern = rx{ (\d+) \s+ (\w+) };
>>if $input ~~ / <$pattern> / {
>>say $0.^name;  # Nil
>>say $0;# Nil
>>say $1.^name;  # Nil
>>say $1;# Nil
>>say $/;# 「9 million」
>>}
>> }
>>
>> In the second case, the match clearly works, but it behaves as
>> though the capture groups aren't there.
>
> $0 is an alias for $/[0].
>
> When the match is in a different variable, you need to access the
> capture group as $match[0] instead of its alias $/[0].
>
> Regards,
> Moritz
>
> --
> Moritz Lenz
> https://perlgeek.de/ -- https://raku.org/
>


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

2021-03-13 Thread Joseph Brenner
Thanks much for your answer on this.  I think this is the sort of
trick I was looking for:

Brad Gilbert wrote:

> You can put it back in as a named

> > $input ~~ / 
> 「9 million」
>  pattern => 「9 million」
>   0 => 「9」
>   1 => 「million」

That's good enough, I guess, though you need to know about the
issue... is there some reason it shouldn't happen automatically,
using the variable name to label the captures?

I don't think this particular gotcha is all that well
documented, though I guess there's a reference to this being a
"known trap" in the documentation under "Regex interpolation"--
but that's the sort of remark that makes sense only after you know
what its talking about.

I have to say, my first reaction was something like "if they
couldn't get this working right, why did they put it in?"


On 3/11/21, Brad Gilbert  wrote:
> If you interpolate a regex, it is a sub regex.
>
> If you have something like a sigil, then the match data structure gets
> thrown away.
>
> You can put it back in as a named
>
> > $input ~~ / 
> 「9 million」
>  pattern => 「9 million」
>   0 => 「9」
>   1 => 「million」
>
> Or as a numbered:
>
> > $input ~~ / $0 = <$pattern>
> 「9 million」
>  0 => 「9 million」
>   0 => 「9」
>   1 => 「million」
>
> Or put it in as a lexical regex
>
> > my regex pattern { (\d+) \s+ (\w+) }
> > $input ~~ /   /
> 「9 million」
>  pattern => 「9 million」
>   0 => 「9」
>   1 => 「million」
>
> Or just use it as the whole regex
>
> > $input ~~ $pattern # variable
> 「9 million」
>  0 => 「9」
>  1 => 「million」
>
> > $input ~~  # my regex pattern /…/
> 「9 million」
>  0 => 「9」
>  1 => 「million」
>
> On Thu, Mar 11, 2021 at 2:29 AM Joseph Brenner  wrote:
>
>> Does this behavior make sense to anyone?  When you've got a regex
>> with captures in it, the captures don't work if the regex is
>> stashed in a variable and then interpolated into a regex.
>>
>> Do capture groups need to be defined at the top level where the
>> regex is used?
>>
>> { #  From a code example in the "Parsing" book by Moritz Lenz, p. 48,
>> section 5.2
>>my $input = 'There are 9 million bicycles in beijing.';
>>if $input ~~ / (\d+) \s+ (\w+) / {
>>say $0.^name;  # Match
>>say $0;# 「9」
>>say $1.^name;  # Match
>>say $1;# 「million」
>>say $/;
>> # 「9 million」
>> #  0 => 「9」
>> #  1 => 「million」
>>}
>> }
>>
>> say '---';
>>
>> { # Moving the pattern to var which we interpolate into match
>>my $input = 'There are 9 million bicycles in beijing.';
>>my $pattern = rx{ (\d+) \s+ (\w+) };
>>if $input ~~ / <$pattern> / {
>>say $0.^name;  # Nil
>>say $0;# Nil
>>say $1.^name;  # Nil
>>say $1;# Nil
>>say $/;# 「9 million」
>>}
>> }
>>
>> In the second case, the match clearly works, but it behaves as
>> though the capture groups aren't there.
>>
>>
>>raku --version
>>
>>Welcome to 퐑퐚퐤퐮퐝퐨™ v2020.10.
>>Implementing the 퐑퐚퐤퐮™ programming language v6.d.
>>
>


Objects, TWEAK and return

2021-03-13 Thread mimosinnet
Hi,

When working with this week challenge for the PerlWeeklyChallenge
, I noticed this behaviour with TWEAK:

*This does not work:*
  submethod TWEAK {
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
)  });
  }

*This works:*
  submethod TWEAK {
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
)  });
return;
  }

It also works with other commands instead of 'return' (like assigning a
value to a variable). From the examples in the documentation, I am not
certain this is the expected behaviour.

Thanks for this extraordinary language,

Joan


P.S: This is the context where the command appears.  Apologies for the
messy-Raku,
--
use Test;

my $data = '1709363,"Les Miserables Episode 1: The Bishop (broadcast date:
1937-07-23)"
1723781,"Les Miserables Episode 2: Javert (broadcast date: 1937-07-30)"
1723781,"Les Miserables Episode 3: The Trial (broadcast date: 1937-08-06)"
1678356,"Les Miserables Episode 4: Cosette (broadcast date: 1937-08-13)"
1646043,"Les Miserables Episode 5: The Grave (broadcast date: 1937-08-20)"
1714640,"Les Miserables Episode 6: The Barricade (broadcast date:
1937-08-27)"
1714640,"Les Miserables Episode 7: Conclusion (broadcast date:
1937-09-03)"';

class Movies {

  has $.starttime;
  has $.currenttime;
  has $.filelist;
  has @!show; # ( [ time, show ] )

  submethod TWEAK {
# miliseconds -> seconds
$!filelist.lines».split(',').map( -> ($a, $b) { @!show.push: ( $a, $b
)  });
return;
  }

  method what-show() {
my $position =  ( $!currenttime - $!starttime ) % @!show[*;0].sum/1000;
my ($time, $show);
for @!show[*;0] -> $show-time {
  $time += $show-time;
  return @!show[$show++;1] if $time > $position;
}
  }
}

my $mv = Movies.new(
  starttime   => '1606134123',
  currenttime => '1614591276',
  filelist=> $data
);

is $mv.what-show, '"Les Miserables Episode 1: The Bishop (broadcast date:
1937-07-23)"';


Re: 'CALL-ME' Math problem?

2021-03-13 Thread Wenzel P. P. Peppmeyer

On 02/03/2021 09:12, ToddAndMargo via perl6-users wrote:


Math problem:
     x = 60÷5(7−5)

raku -e 'say 60÷5(7−5)'
No such method 'CALL-ME' for invocant of type 'Int'
   in block  at -e line 1

Seems raku does not like the ().  How do I fix this
and maintain the flow and look of the equation?

-T

The correct answer is 24


The correct answer can be found with the following code.

class SuperInt {
has $.left-factor is rw;
has $.right-factor is rw;
method new(\l, \r) {
my \SELF = self.CREATE;
SELF.left-factor = l;
SELF.right-factor = r;
SELF
}
}

multi sub infix:<÷>(Numeric:D \l, SuperInt:D \r) {
l ÷ r.left-factor * r.right-factor
}

Int.^add_method('CALL-ME', my method (\SELF: \v) { SuperInt.new(SELF, v) });
Int.^compose;

say 60÷5(7−5);

Thought, I do have the hunch that this might break with a slightly more
complex examle.

Have -Ofun

gfldex


Re: Please create a Raku community channel

2021-03-13 Thread Tom Browder
On Sat, Mar 13, 2021 at 08:12 Joseph Brenner  wrote:

> Richard Hainsworth  wrote:
>
> > I found out yesterday by the intervention of a regular participant in
> > the community that a new documentation website is being worked on.
>
> I should say, I was surprised to hear about that project also.  I knew
> about Richard Hainsworth's work, but not about what the other team was
> doing.
>
Same here, and I have a very vested interest since I contributed a working
solution to the pre-documentable doc site that kept the Languag sub-section
titles sorted which is very important IMHO for easier browsing.


Re: Please create a Raku community channel

2021-03-13 Thread Joseph Brenner
Richard Hainsworth  wrote:

> I found out yesterday by the intervention of a regular participant in
> the community that a new documentation website is being worked on.

I should say, I was surprised to hear about that project also.  I knew
about Richard Hainsworth's work, but not about what the other team was
doing.


Re: Please create a Raku community channel

2021-03-13 Thread JJ Merelo
This issue has been in the problem-solving repo for a long time
https://github.com/Raku/problem-solving/issues/246
So yes, we need something like this, if only to avoid confusion about what
plans/roadmaps there are, what's going to be done or simply to call for
elections.

El sáb, 13 mar 2021 a las 8:22, Richard Hainsworth ()
escribió:

> This is a request to the Raku Coordinating Council that was elected at
> the end of last year.
>
> Please name a channel where community wide plans or announcements are
> made. Or may be establish one.
>
> I found out yesterday by the intervention of a regular participant in
> the community that a new documentation website is being worked on.
>
> I joined a conversation on the raku-dev IRC and discovered that the
> plans are quite far established. Since I have been working full-time for
> three months on a project that could (not should!!) serve as the
> infra-structure of a new site, I was really quite surprised and I am
> sure many of you will understand it was jarring.
>
> I follow all the conversations on this email list. I have found it very
> difficult (due to my own technical incompetence relating to github) to
> set up my github preferences to get regular notification about issues. I
> have also found that the IRC chats are streams of consciousness that are
> difficult for me to manage.
>
> It seems however, that it is my fault that I was taken by surprise  by
> the news of a different documentation website and that I should have
> been following all the issues on the documentation repo or the problem
> solving repo.
>
> It *IS* reasonable for Raku developers and community organisers to make
> it the responsibility of a participant to follow conversations, but I
> would suggest that the current scattering of conversations, on the IRC
> chat, various github repositories, this email list, is not *optimal* for
> the development of a coherent Raku community. It is also - I would
> suggest - a waste of human resources if the same objectives are pursued
> by multiple enthusiasts without any coordination or communication.
>
> If the Raku Council were to designate some channel, whether its an email
> list, an IRC chat, or a github repo, or maybe a discord or slack or
> other channel as the main community resource, then I would make sure I
> could read all the messages there and stay in touch with what is happening.
>
> Hence my request to the Raku council to consider improving communication
> between developers and the wider Raku community.
>
> Regards
>
> Richard Hainsworth
>
> aka finanalyst
>
>
>

-- 
JJ


Re: Please create a Raku community channel

2021-03-13 Thread Darren Duncan
I agree, I would also like to know of this official channel and join it. -- 
Darren Duncan


On 2021-03-12 11:21 p.m., Richard Hainsworth wrote:
This is a request to the Raku Coordinating Council that was elected at the end 
of last year.


Please name a channel where community wide plans or announcements are made. Or 
may be establish one.


I found out yesterday by the intervention of a regular participant in the 
community that a new documentation website is being worked on.


I joined a conversation on the raku-dev IRC and discovered that the plans are 
quite far established. Since I have been working full-time for three months on a 
project that could (not should!!) serve as the infra-structure of a new site, I 
was really quite surprised and I am sure many of you will understand it was 
jarring.


I follow all the conversations on this email list. I have found it very 
difficult (due to my own technical incompetence relating to github) to set up my 
github preferences to get regular notification about issues. I have also found 
that the IRC chats are streams of consciousness that are difficult for me to 
manage.


It seems however, that it is my fault that I was taken by surprise  by the news 
of a different documentation website and that I should have been following all 
the issues on the documentation repo or the problem solving repo.


It *IS* reasonable for Raku developers and community organisers to make it the 
responsibility of a participant to follow conversations, but I would suggest 
that the current scattering of conversations, on the IRC chat, various github 
repositories, this email list, is not *optimal* for the development of a 
coherent Raku community. It is also - I would suggest - a waste of human 
resources if the same objectives are pursued by multiple enthusiasts without any 
coordination or communication.


If the Raku Council were to designate some channel, whether its an email list, 
an IRC chat, or a github repo, or maybe a discord or slack or other channel as 
the main community resource, then I would make sure I could read all the 
messages there and stay in touch with what is happening.


Hence my request to the Raku council to consider improving communication between 
developers and the wider Raku community.


Regards

Richard Hainsworth

aka finanalyst