Re: perl6 with Rakudobrew

2020-06-13 Thread Vadim Belman

With regard to 'built and installed' – yes, it is. But the purpose of 
rakudobrew is to build and install many different versions of rakudo and switch 
between them. The way it implements the task is by installing rakudo in a 
location which is normally not accessible and then provide means to actually 
make it available to you depending on what version of rakudo you need at some 
point in time.

I'd very much recommend you carefully read rakudobrew or rakubrew documentation 
first because otherwise you won't be able to solve your problem. 

In either case, it is not necessary to have a Windows to test rakudobrew. I'm 
mostly positive that you'd get same result on a linux to what you get with 
appveyor.

Best regards,
Vadim Belman

> On Jun 13, 2020, at 5:34 PM, Richard Hainsworth  
> wrote:
> 
> Vadim,
> 
> Your response is like a whisper in a storm. Perhaps there is meaning to it, 
> but I have not the ears wherewith to hear it.
> 
> (a) I am trying to find a way to test a Module under Windows when I do not 
> have access to a Windows machine. So no I do not see how I could follow the 
> steps of the script manually. That is precisely why I am trying to use 
> appveyor. Not ideal. No.
> 
> And (b) your words are as perplexing to me as the error messages themselves. 
> If I were able to understand the error message, I would probably be able to 
> understand what you wrote, but I can't so I don't.
> 
> If you look at the error message from the Rakudobrew script, it says 'perl6 
> is not available'. But a few lines previously, there is the line:
> 
> `Rakudo has been built and installed.` 
> 
> And I understand that to mean that perl6 would be available. Note that 
> 'perl6' is not explicitly used anywhere in my script, so I don't know where 
> it is appearing.
> I appreciate the time you took to read and respond to my email, and I realise 
> I have made an error and that I truly do not understand entirely what I am 
> doing, 
> 
> but that is precisely why I have written for help.
> 
> Richard
> 
> On 13/06/2020 21:00, Vadim Belman wrote:
>> 
>> Did you ever tried to follow the steps of you script manually? I guess on a 
>> clean system without pre-installed rakudo you'd get the same result. Because 
>> `build` only builds a release. When it's ready one needs to `switch` to the 
>> built. So, no, these two are different.
>> 
>> Best regards,
>> Vadim Belman
>> 
>>> On Jun 13, 2020, at 4:57 AM, Richard Hainsworth >> > wrote:
>>> 
>>> Is the appveyor stanza (see the rakudobrew script below)
>>> 
>>>   - rakudobrew build moar %TEST_MOAR%
>>> the same as what you are suggesting?
>>> 
>>> Richard
>>> On 13/06/2020 02:53, Vadim Belman wrote:
 
 Not really sure about it, but don't you have to do 'rakudobrew switch 
 moar-%TEST_MOAR%' after building? rakudobrew doesn't immediately activates 
 a build.
 
 Best regards,
 Vadim Belman
 
> On Jun 12, 2020, at 4:03 PM, Richard Hainsworth  > wrote:
> 
> I have tried two different strategies on appveyor. (I also run a travis 
> test for the same Module that passes without a problem).
> 
> a) Copying from OpenSSL, which uses rakudo.git (see script below)
> 
> b) Copying from GTK::Simple, which uses Rakudobrew (see below)
> 
> Both failed for reasons I can't work out. (The final lines are below)
> 
> 
> Could someone suggest an install stanza that would use the latest 
> `rakudo-star-***.msi` installation package?
> 
> It would be good to have some samples in the raku documentation.
> 
> I can provide my travis script (I use JJ's docker image).
> 
> [Rakudobrew]
> 
> os: Visual Studio 2017
> 
> platform: x64
> 
> install:
>   - '"C:\Program Files (x86)\Microsoft Visual 
> Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"'
>   - appveyor-retry choco install strawberryperl --allow-empty-checksums
>   - SET 
> PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
>   - git clone https://github.com/tadzik/rakudobrew 
>  %USERPROFILE%\rakudobrew
>   - SET PATH=%USERPROFILE%\rakudobrew\bin;%PATH%
>   - rakudobrew build moar %TEST_MOAR%
>   - rakudobrew build zef
>   - cd %APPVEYOR_BUILD_FOLDER%
>   - echo "installing SSL so we can download the dll files"
>   - zef install IO::Socket::SSL
>   - zef --depsonly install .
>   - zef build .
> 
> build: off
> 
> test_script:
>   - prove -v -e "raku -Ilib" t/
>   - zef --debug install .
> 
> shallow_clone: true
> [ response from appveyor fail - last lines]
> ...
> Generating code
> Finished generating code
> Microsoft (R) Program Maintenance Utility Version 14.16.27035.0
> Copyright (C) Microsoft Corporation.  All rights reserved.
> +++ Checking 

Re: perl6 with Rakudobrew

2020-06-13 Thread Richard Hainsworth

Vadim,

Your response is like a whisper in a storm. Perhaps there is meaning to 
it, but I have not the ears wherewith to hear it.


(a) I am trying to find a way to test a Module under Windows when I do 
not have access to a Windows machine. So no I do not see how I could 
follow the steps of the script manually. That is precisely why I am 
trying to use appveyor. Not ideal. No.


And (b) your words are as perplexing to me as the error messages 
themselves. If I were able to understand the error message, I would 
probably be able to understand what you wrote, but I can't so I don't.


If you look at the error message from the Rakudobrew script, it says 
'perl6 is not available'. But a few lines previously, there is the line:


`Rakudo has been built and installed.`

And I understand that to mean that perl6 would be available. Note that 'perl6' 
is not explicitly used anywhere in my script, so I don't know where it is 
appearing.

I appreciate the time you took to read and respond to my email, and I 
realise I have made an error and that I truly do not understand entirely 
what I am doing,


but that is precisely why I have written for help.

Richard

On 13/06/2020 21:00, Vadim Belman wrote:


Did you ever tried to follow the steps of you script manually? I guess 
on a clean system without pre-installed rakudo you'd get the same 
result. Because `build` only builds a release. When it's ready one 
needs to `switch` to the built. So, no, these two are different.


Best regards,
Vadim Belman

On Jun 13, 2020, at 4:57 AM, Richard Hainsworth 
mailto:rnhainswo...@gmail.com>> wrote:


Is the appveyor stanza (see the rakudobrew script below)

   - rakudobrew build moar %TEST_MOAR%
the same as what you are suggesting?

Richard
On 13/06/2020 02:53, Vadim Belman wrote:


Not really sure about it, but don't you have to do 'rakudobrew 
switch moar-%TEST_MOAR%' after building? rakudobrew doesn't 
immediately activates a build.


Best regards,
Vadim Belman

On Jun 12, 2020, at 4:03 PM, Richard Hainsworth 
mailto:rnhainswo...@gmail.com>> wrote:


I have tried two different strategies on appveyor. (I also run a 
travis test for the same Module that passes without a problem).


a) Copying from OpenSSL, which uses rakudo.git (see script below)

b) Copying from GTK::Simple, which uses Rakudobrew (see below)

Both failed for reasons I can't work out. (The final lines are below)


Could someone suggest an install stanza that would use the latest 
`rakudo-star-***.msi` installation package?


It would be good to have some samples in the raku documentation.

I can provide my travis script (I use JJ's docker image).

[Rakudobrew]

os: Visual Studio 2017

platform: x64

install:
   -'"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' - appveyor-retry choco install strawberryperl --allow-empty-checksums

   - SET 
PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
   - git clonehttps://github.com/tadzik/rakudobrew  %USERPROFILE%\rakudobrew
   - SET PATH=%USERPROFILE%\rakudobrew\bin;%PATH%
   - rakudobrew build moar %TEST_MOAR%
   - rakudobrew build zef
   - cd %APPVEYOR_BUILD_FOLDER%
   - echo "installing SSL so we can download the dll files"
   - zef install IO::Socket::SSL
   - zef --depsonly install .
   - zef build .

build: off

test_script:
   - prove -v -e "raku -Ilib" t/
   - zef --debug install .

shallow_clone: true
[ response from appveyor fail - last lines]
...
Generating code
Finished generating code
Microsoft (R) Program Maintenance Utility Version 14.16.27035.0
Copyright (C) Microsoft Corporation.  All rights reserved.
+++ Checking for moar NQP version
+++ Creating installation directories
+++ Removing old files
+++ Installing files
+++ Preparing installation
 Installed 13 core modules in 24.63815875 seconds!
+++ MOAR BACKEND INSTALLED
+++ Installing MOAR launchers
+++ Creating Raku executable alias
+++ Rakudo installed succesfully!
Rakudo has been built and installed.
Updating shims
Done, moar-2020.05.1 built
rakudobrew build zef
Cloning into 'zef'...
Your branch is up to date with 'origin/master'.
rakudobrew: perl6: command not found
Command exited with code 1

[Rakudo.git]
os: Visual Studio 2017

platform: x64

install:
   -'"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' - appveyor-retry choco install strawberryperl --allow-empty-checksums

   - SET 
PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
   - appveyor-retry git clonehttps://github.com/rakudo/rakudo.git  
%APPVEYOR_BUILD_FOLDER%\..\rakudo
   - cd %APPVEYOR_BUILD_FOLDER%\..\rakudo
   - perl Configure.pl --gen-moar --gen-nqp --backends=moar
   - nmake install
   - SET PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\bin;%PATH%
   - SET 
PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\share\perl6\site\bin;%PATH%
   - cd %APPVEYOR_BUILD_FOLDER%
   - echo "installing SSL so we can download the 

Re: perl6 with Rakudobrew

2020-06-13 Thread Vadim Belman

Did you ever tried to follow the steps of you script manually? I guess on a 
clean system without pre-installed rakudo you'd get the same result. Because 
`build` only builds a release. When it's ready one needs to `switch` to the 
built. So, no, these two are different.

Best regards,
Vadim Belman

> On Jun 13, 2020, at 4:57 AM, Richard Hainsworth  
> wrote:
> 
> Is the appveyor stanza (see the rakudobrew script below)
> 
>   - rakudobrew build moar %TEST_MOAR%
> the same as what you are suggesting?
> 
> Richard
> On 13/06/2020 02:53, Vadim Belman wrote:
>> 
>> Not really sure about it, but don't you have to do 'rakudobrew switch 
>> moar-%TEST_MOAR%' after building? rakudobrew doesn't immediately activates a 
>> build.
>> 
>> Best regards,
>> Vadim Belman
>> 
>>> On Jun 12, 2020, at 4:03 PM, Richard Hainsworth >> > wrote:
>>> 
>>> I have tried two different strategies on appveyor. (I also run a travis 
>>> test for the same Module that passes without a problem).
>>> 
>>> a) Copying from OpenSSL, which uses rakudo.git (see script below)
>>> 
>>> b) Copying from GTK::Simple, which uses Rakudobrew (see below)
>>> 
>>> Both failed for reasons I can't work out. (The final lines are below)
>>> 
>>> 
>>> Could someone suggest an install stanza that would use the latest 
>>> `rakudo-star-***.msi` installation package?
>>> 
>>> It would be good to have some samples in the raku documentation.
>>> 
>>> I can provide my travis script (I use JJ's docker image).
>>> 
>>> [Rakudobrew]
>>> 
>>> os: Visual Studio 2017
>>> 
>>> platform: x64
>>> 
>>> install:
>>>   - '"C:\Program Files (x86)\Microsoft Visual 
>>> Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"'
>>>   - appveyor-retry choco install strawberryperl --allow-empty-checksums
>>>   - SET 
>>> PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
>>>   - git clone https://github.com/tadzik/rakudobrew 
>>>  %USERPROFILE%\rakudobrew
>>>   - SET PATH=%USERPROFILE%\rakudobrew\bin;%PATH%
>>>   - rakudobrew build moar %TEST_MOAR%
>>>   - rakudobrew build zef
>>>   - cd %APPVEYOR_BUILD_FOLDER%
>>>   - echo "installing SSL so we can download the dll files"
>>>   - zef install IO::Socket::SSL
>>>   - zef --depsonly install .
>>>   - zef build .
>>> 
>>> build: off
>>> 
>>> test_script:
>>>   - prove -v -e "raku -Ilib" t/
>>>   - zef --debug install .
>>> 
>>> shallow_clone: true
>>> [ response from appveyor fail - last lines]
>>> ...
>>> Generating code
>>> Finished generating code
>>> Microsoft (R) Program Maintenance Utility Version 14.16.27035.0
>>> Copyright (C) Microsoft Corporation.  All rights reserved.
>>> +++ Checking for moar NQP version
>>> +++ Creating installation directories
>>> +++ Removing old files
>>> +++ Installing files
>>> +++ Preparing installation
>>> Installed 13 core modules in 24.63815875 seconds!
>>> +++ MOAR BACKEND INSTALLED
>>> +++ Installing MOAR launchers
>>> +++ Creating Raku executable alias
>>> +++ Rakudo installed succesfully!
>>> Rakudo has been built and installed.
>>> Updating shims
>>> Done, moar-2020.05.1 built
>>> rakudobrew build zef
>>> Cloning into 'zef'...
>>> Your branch is up to date with 'origin/master'.
>>> rakudobrew: perl6: command not found
>>> Command exited with code 1
>>> 
>>> [Rakudo.git]
>>> os: Visual Studio 2017
>>> 
>>> platform: x64
>>> 
>>> install:
>>>   - '"C:\Program Files (x86)\Microsoft Visual 
>>> Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"'
>>>   - appveyor-retry choco install strawberryperl --allow-empty-checksums
>>>   - SET 
>>> PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
>>>   - appveyor-retry git clone https://github.com/rakudo/rakudo.git 
>>>  %APPVEYOR_BUILD_FOLDER%\..\rakudo
>>>   - cd %APPVEYOR_BUILD_FOLDER%\..\rakudo
>>>   - perl Configure.pl --gen-moar --gen-nqp --backends=moar
>>>   - nmake install
>>>   - SET PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\bin;%PATH%
>>>   - SET 
>>> PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\share\perl6\site\bin;%PATH%
>>>   - cd %APPVEYOR_BUILD_FOLDER%
>>>   - echo "installing SSL so we can download the dll files"
>>>   - zef install IO::Socket::SSL
>>>   - zef --depsonly install .
>>>   - zef build .
>>> 
>>> build: off
>>> 
>>> test_script:
>>>   - prove -v -e "raku -Ilib" t/
>>>   - zef --debug install .
>>> 
>>> shallow_clone: true
>>> [rakudo.git - avveyor failure. last lines]
>>> 
>>> +++ MOAR BACKEND INSTALLED
>>> +++ Installing MOAR launchers
>>> +++ Creating Raku executable alias
>>> +++ Rakudo installed succesfully!
>>> SET PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\bin;%PATH%
>>> SET 
>>> PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\share\perl6\site\bin;%PATH%
>>> cd %APPVEYOR_BUILD_FOLDER%
>>> echo "installing SSL so we can download the dll files"
>>> "installing SSL so we can download the dll files"
>>> zef install IO::Socket::SSL
>>> 

Re: regex interpolation of array

2020-06-13 Thread William Michels via perl6-users
Thank you so much for explaining what's going on here, Brad. You gave
a good example--just one that I misinterpreted. I think I understand
now: inside a regex Richard has to enclose his code within "<{ ... }>"
for it to be properly interpreted as a 'match objective' (I hope I
said that correctly).

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> my @W = ;
[perl weekly challenge with some extra things]
> my $S = 'perlchallengeextrathingswithweeklysome' ; # randomly concatenate the 
> words without spaces
perlchallengeextrathingswithweeklysome
> say $/ if $S ~~ / $=( { @W[3] } ) /;
「」
 sol => 「」
> say $/ if $S ~~ /  $ = <{ @W[3] }> /;
「with」
 sol => 「with」
> say $;
「with」
> my $sol = @W[3]; # with
with
> say $/ if $S ~~ / $=( $sol ) /;
「with」
 sol => 「with」
> say $;
「with」
>

Also, I took the liberty of looking at your (Brad's) boolean code with
and without the :global adverb. I think it makes sense, however I do
see the REPL occasionally return "#" when using the
:global adverb.

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> say $/ if 'TrueFalse' ~~ m:g/ <{ Bool.pick }> /
()
> say $/ if 'TrueFalse' ~~ m:g/ <{ Bool.pick }> /
#
> my @a = 
[True False]
> say $/ if @a ~~ / <{ Bool.pick }> /
「True」
> say $/ if @a ~~ / <{ Bool.pick }> /
()
> say $/ if @a ~~ m:g/ <{ Bool.pick }> /
#
> say $/ if @a ~~ m:g/ <{ Bool.pick }> /
()
>

Thanks, Bill.



On Sat, Jun 13, 2020 at 10:21 AM Brad Gilbert  wrote:
>
> That was just a dumb example.
> An incredibly dumb example.
>
> So what happens is that `Bool.pick` chooses The Bool values of either `True` 
> or `False`.
> It does this at every position in the string.
>
> 'TrueFalse' ~~ / <{ Bool.pick }>
>
> Let's say that initially `Bool.pick` chooses `False`.
> That value then gets temporarily inserted into the regex.
> Obviously { "True" ne "False" } so it fails at the first position.
>
> So then the regex tries to match at the second position.
> `Bool.pick` gets run again, and picks one of the values.
> Neither "True" nor "False" can match here so it doesn't matter which is 
> chosen.
>
> It keeps doing that until it finally matches or reaches the end of the string.
>
> Let's take a look at what happens at the fifth position.
> We obviously didn't match `True` at the start, because otherwise we would get 
> this far.
> You may be expecting it to match `False` then.
> The only thing is that the code inside of <{ }> gets run again.
> This time it picks `True`.
> { "True" ne "False" } so it fails again.
>
> It then keeps trying to find a match, only we've gotten so far into the 
> string that there are no matches left.
> So then it just fails.
>
> ---
>
> There is a 50% chance that it will return "True" if `Bool.pick` chooses 
> `True` the first time.
> A 25% chance that it will return "False" if it picks `False` at the fifth 
> position.
> And another 25% chance it will fail to match anything.
>
> You can play around with the odds by changing the string your matching 
> against.
> There will always be a chance that it will fail to match though.
>
> On Sat, Jun 13, 2020 at 11:54 AM William Michels  
> wrote:
>>
>> Hi,
>>
>> I seem to be having some problems with Brad's code. The 'boolean pick'
>> code seems far too clever for me to have intuited it on my own, so
>> (to expand my Raku/Perl6 vocabulary), I played around with matching
>> extra 'True' or 'False' values--as well as played around with seeing
>> if similar 'boolean elems' code would work. However the code (even
>> Brad's code) returned 'Nil' with alarming frequency (all code below
>> tested in the Raku/Perl6 REPL):
>>
>> mbook:~ homedir$ perl6
>> To exit type 'exit' or '^D'
>> > 'TrueFalse' ~~ / <{ Bool.pick }> /
>> 「False」
>> > 'FalseTrueFalse' ~~ / <{ Bool.pick }> /
>> 「False」
>> > 'TrueFalseTrue' ~~ / <{ Bool.pick }> /
>> Nil
>> > 'TrueFalseTrue' ~~ / <{ Bool.elems }> /
>> Nil
>> > 'TrueFalse' ~~ / <{ Bool.elems }> /
>> Nil
>> > 'TrueFalse' ~~ / <{ Bool.pick }> /
>> Nil
>> > 'TrueFalse' ~~ / <{ Bool }> /
>> Cannot resolve caller INTERPOLATE_ASSERTION(Match:D: Bool:U, BOOTInt,
>> BOOTInt, BOOTInt, BOOTInt, PseudoStash:D); none of these signatures
>> match:
>> (Match: Associative:D, $, $, $, $, $, *%_)
>> (Match: Iterable:D \var, int \im, int \monkey, int \s, $, \context, *%_)
>> (Match: Mu:D \var, int \im, int \monkey, $, $, \context, *%_)
>>   in block  at  line 1
>>
>> > 'TrueFalse' ~~ / <{ Bool.say }> /
>> (Bool)
>> > say $*VM
>> moar (2020.02.1)
>> > exit
>> mbook:~ homedir$ perl6 --version
>> This is Rakudo version 2020.02.1..1 built on MoarVM version 2020.02.1
>> implementing Raku 6.d.
>> mbook:~ homedir$
>>
>> Any help appreciated, Bill.
>>
>>
>> On Sat, Jun 13, 2020 at 6:42 AM Brad Gilbert  wrote:
>> >
>> > Inside of a regex `{…}` will just run some regular Raku code.
>> > Code inside of it will most likely have no effect on what the regex 
>> > matches.
>> >
>> > What you should have written was:
>> >
>> > $ = "@W[3]"
>> >
>> > The thing you were thinking of was:
>> >
>> 

Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
On Sat, Jun 13, 2020 at 1:27 PM Sean McAfee  wrote:

> On Sat, Jun 13, 2020 at 10:21 AM Brad Gilbert  wrote:
>
>> That was just a dumb example.
>> An incredibly dumb example.
>>
>> So what happens is that `Bool.pick` chooses The Bool values of either
>> `True` or `False`.
>> It does this at every position in the string.
>>
>> 'TrueFalse' ~~ / <{ Bool.pick }>
>>
>
> I saw this and figured that maybe a state variable could help:
>
> 'TrueFalse' ~~ /<{ $ //= Bool.pick }>/
>
> ...but it doesn't.  I suppose that means the bracketed code is not
> compiled just once, like an anonymous subroutine, but is fully re-evaluated
> on every match attempt.  Is that the intended behavior?
>

`state` variables act like they were declared in the next outer lexical
scope.

{   {   state $v;  $v++   }   }
{   my $v;   {   $v++   }   }

The next outer lexical scope that we see for `<{ }>` is the regex itself;

/ <{   $   //= Bool.pick   }> /
/ <{  (state $v)  //= Bool.pick }> /

That last one is almost like this:

/ :my $v;  <{  $v //= Bool.pick }> /

Almost.

It really acts like there is a scope defined by the <> and a separate one
defined by the {}.

(This may be just an implementation detail that is leaking out.)

---

At any rate the right way to fix it is to actually run `Bool.pick` exactly
once at the beginning.

/ :my $to-match = ~Bool.pick;  <{ $to-match }> /
/ :my $to-match = ~Bool.pick;  "$to-match" /


Re: regex interpolation of array

2020-06-13 Thread Sean McAfee
On Sat, Jun 13, 2020 at 10:21 AM Brad Gilbert  wrote:

> That was just a dumb example.
> An incredibly dumb example.
>
> So what happens is that `Bool.pick` chooses The Bool values of either
> `True` or `False`.
> It does this at every position in the string.
>
> 'TrueFalse' ~~ / <{ Bool.pick }>
>

I saw this and figured that maybe a state variable could help:

'TrueFalse' ~~ /<{ $ //= Bool.pick }>/

...but it doesn't.  I suppose that means the bracketed code is not compiled
just once, like an anonymous subroutine, but is fully re-evaluated on every
match attempt.  Is that the intended behavior?


Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
That was just a dumb example.
An incredibly dumb example.

So what happens is that `Bool.pick` chooses The Bool values of either
`True` or `False`.
It does this at every position in the string.

'TrueFalse' ~~ / <{ Bool.pick }>

Let's say that initially `Bool.pick` chooses `False`.
That value then gets temporarily inserted into the regex.
Obviously { "True" ne "False" } so it fails at the first position.

So then the regex tries to match at the second position.
`Bool.pick` gets run again, and picks one of the values.
Neither "True" nor "False" can match here so it doesn't matter which is
chosen.

It keeps doing that until it finally matches or reaches the end of the
string.

Let's take a look at what happens at the fifth position.
We obviously didn't match `True` at the start, because otherwise we would
get this far.
You may be expecting it to match `False` then.
The only thing is that the code inside of <{ }> gets run again.
This time it picks `True`.
{ "True" ne "False" } so it fails again.

It then keeps trying to find a match, only we've gotten so far into the
string that there are no matches left.
So then it just fails.

---

There is a 50% chance that it will return "True" if `Bool.pick` chooses
`True` the first time.
A 25% chance that it will return "False" if it picks `False` at the fifth
position.
And another 25% chance it will fail to match anything.

You can play around with the odds by changing the string your matching
against.
There will always be a chance that it will fail to match though.

On Sat, Jun 13, 2020 at 11:54 AM William Michels 
wrote:

> Hi,
>
> I seem to be having some problems with Brad's code. The 'boolean pick'
> code seems far too clever for me to have intuited it on my own, so
> (to expand my Raku/Perl6 vocabulary), I played around with matching
> extra 'True' or 'False' values--as well as played around with seeing
> if similar 'boolean elems' code would work. However the code (even
> Brad's code) returned 'Nil' with alarming frequency (all code below
> tested in the Raku/Perl6 REPL):
>
> mbook:~ homedir$ perl6
> To exit type 'exit' or '^D'
> > 'TrueFalse' ~~ / <{ Bool.pick }> /
> 「False」
> > 'FalseTrueFalse' ~~ / <{ Bool.pick }> /
> 「False」
> > 'TrueFalseTrue' ~~ / <{ Bool.pick }> /
> Nil
> > 'TrueFalseTrue' ~~ / <{ Bool.elems }> /
> Nil
> > 'TrueFalse' ~~ / <{ Bool.elems }> /
> Nil
> > 'TrueFalse' ~~ / <{ Bool.pick }> /
> Nil
> > 'TrueFalse' ~~ / <{ Bool }> /
> Cannot resolve caller INTERPOLATE_ASSERTION(Match:D: Bool:U, BOOTInt,
> BOOTInt, BOOTInt, BOOTInt, PseudoStash:D); none of these signatures
> match:
> (Match: Associative:D, $, $, $, $, $, *%_)
> (Match: Iterable:D \var, int \im, int \monkey, int \s, $, \context,
> *%_)
> (Match: Mu:D \var, int \im, int \monkey, $, $, \context, *%_)
>   in block  at  line 1
>
> > 'TrueFalse' ~~ / <{ Bool.say }> /
> (Bool)
> > say $*VM
> moar (2020.02.1)
> > exit
> mbook:~ homedir$ perl6 --version
> This is Rakudo version 2020.02.1..1 built on MoarVM version 2020.02.1
> implementing Raku 6.d.
> mbook:~ homedir$
>
> Any help appreciated, Bill.
>
>
> On Sat, Jun 13, 2020 at 6:42 AM Brad Gilbert  wrote:
> >
> > Inside of a regex `{…}` will just run some regular Raku code.
> > Code inside of it will most likely have no effect on what the regex
> matches.
> >
> > What you should have written was:
> >
> > $ = "@W[3]"
> >
> > The thing you were thinking of was:
> >
> > $ = <{ @W[3] }>
> >
> > Which could have been written as:
> >
> > 
> >
> > ---
> >
> > To have the result of regular Raku code have an effect on the match, it
> has to have <…> around it
> >
> > 'TrueFalse' ~~ / <{ Bool.pick }> /
> >
> > I think it is better if you use "…" if you are just interpolating a
> variable, because that is something you might do outside of a regex as well.
> >
> > ---
> >
> > The reason your code matched is that an empty regex always matches.
> >
> > 'abc' ~~ / "" /
> > 'abc' ~~ / {} /
> > 'abc' ~~ / {'def'} / # still an empty regex as far as the regex
> engine is concerned
> >
> > On Sat, Jun 13, 2020 at 5:35 AM Richard Hainsworth <
> rnhainswo...@gmail.com> wrote:
> >>
> >> I was playing with a regex and array interpolation.
> >>
> >> From the documentation I thought the following comparisons would be the
> same, but they are not.
> >>
> >> What am I missing?
> >>
> >> my @W = ;
> >> my $S = 'perlchallengeextrathingswithweeklysome' ; # randomly
> concatenate the words without spaces
> >> say 'yes' if $S ~~ / $=( { @W[3] } ) /;
> >> say $;
> >> my $sol = @W[3]; # with
> >> say 'yes' if $S ~~ / $=( $sol ) /;
> >> say $;
> >>
> >> 
> >> yes
> >> 「」
> >> yes
> >> 「with」
> >>
> >>
> >>
>


Re: regex interpolation of array

2020-06-13 Thread William Michels via perl6-users
Hi,

I seem to be having some problems with Brad's code. The 'boolean pick'
code seems far too clever for me to have intuited it on my own, so
(to expand my Raku/Perl6 vocabulary), I played around with matching
extra 'True' or 'False' values--as well as played around with seeing
if similar 'boolean elems' code would work. However the code (even
Brad's code) returned 'Nil' with alarming frequency (all code below
tested in the Raku/Perl6 REPL):

mbook:~ homedir$ perl6
To exit type 'exit' or '^D'
> 'TrueFalse' ~~ / <{ Bool.pick }> /
「False」
> 'FalseTrueFalse' ~~ / <{ Bool.pick }> /
「False」
> 'TrueFalseTrue' ~~ / <{ Bool.pick }> /
Nil
> 'TrueFalseTrue' ~~ / <{ Bool.elems }> /
Nil
> 'TrueFalse' ~~ / <{ Bool.elems }> /
Nil
> 'TrueFalse' ~~ / <{ Bool.pick }> /
Nil
> 'TrueFalse' ~~ / <{ Bool }> /
Cannot resolve caller INTERPOLATE_ASSERTION(Match:D: Bool:U, BOOTInt,
BOOTInt, BOOTInt, BOOTInt, PseudoStash:D); none of these signatures
match:
(Match: Associative:D, $, $, $, $, $, *%_)
(Match: Iterable:D \var, int \im, int \monkey, int \s, $, \context, *%_)
(Match: Mu:D \var, int \im, int \monkey, $, $, \context, *%_)
  in block  at  line 1

> 'TrueFalse' ~~ / <{ Bool.say }> /
(Bool)
> say $*VM
moar (2020.02.1)
> exit
mbook:~ homedir$ perl6 --version
This is Rakudo version 2020.02.1..1 built on MoarVM version 2020.02.1
implementing Raku 6.d.
mbook:~ homedir$

Any help appreciated, Bill.


On Sat, Jun 13, 2020 at 6:42 AM Brad Gilbert  wrote:
>
> Inside of a regex `{…}` will just run some regular Raku code.
> Code inside of it will most likely have no effect on what the regex matches.
>
> What you should have written was:
>
> $ = "@W[3]"
>
> The thing you were thinking of was:
>
> $ = <{ @W[3] }>
>
> Which could have been written as:
>
> 
>
> ---
>
> To have the result of regular Raku code have an effect on the match, it has 
> to have <…> around it
>
> 'TrueFalse' ~~ / <{ Bool.pick }> /
>
> I think it is better if you use "…" if you are just interpolating a variable, 
> because that is something you might do outside of a regex as well.
>
> ---
>
> The reason your code matched is that an empty regex always matches.
>
> 'abc' ~~ / "" /
> 'abc' ~~ / {} /
> 'abc' ~~ / {'def'} / # still an empty regex as far as the regex engine is 
> concerned
>
> On Sat, Jun 13, 2020 at 5:35 AM Richard Hainsworth  
> wrote:
>>
>> I was playing with a regex and array interpolation.
>>
>> From the documentation I thought the following comparisons would be the 
>> same, but they are not.
>>
>> What am I missing?
>>
>> my @W = ;
>> my $S = 'perlchallengeextrathingswithweeklysome' ; # randomly concatenate 
>> the words without spaces
>> say 'yes' if $S ~~ / $=( { @W[3] } ) /;
>> say $;
>> my $sol = @W[3]; # with
>> say 'yes' if $S ~~ / $=( $sol ) /;
>> say $;
>>
>> 
>> yes
>> 「」
>> yes
>> 「with」
>>
>>
>>


Re: regex interpolation of array

2020-06-13 Thread Richard Hainsworth

Understood. Thankyou.

The " quotes is what I missed. So $ = "@W[3]" worked as I would expect.

The other two variations, eg. $ =<{ @W[3] }>, gave Nil responses, 
indicating match failure.


On 13/06/2020 14:41, Brad Gilbert wrote:

Inside of a regex `{…}` will just run some regular Raku code.
Code inside of it will most likely have no effect on what the regex 
matches.


What you should have written was:

    $ = "@W[3]"

The thing you were thinking of was:

    $ = <{ @W[3] }>

Which could have been written as:

    

---

To have the result of regular Raku code have an effect on the match, 
it has to have <…> around it


    'TrueFalse' ~~ / <{ Bool.pick }> /

I think it is better if you use "…" if you are just interpolating a 
variable, because that is something you might do outside of a regex as 
well.


---

The reason your code matched is that an empty regex always matches.

    'abc' ~~ / "" /
    'abc' ~~ / {} /
    'abc' ~~ / {'def'} / # still an empty regex as far as the regex 
engine is concerned


On Sat, Jun 13, 2020 at 5:35 AM Richard Hainsworth 
mailto:rnhainswo...@gmail.com>> wrote:


I was playing with a regex and array interpolation.

From the documentation I thought the following comparisons would
be the same, but they are not.

What am I missing?

my @W = ;
my $S = 'perlchallengeextrathingswithweeklysome' ; #randomly concatenate 
the words without spaces say 'yes' if $S ~~ /
$=( {@W[3] }) /;
say $;
my $sol = @W[3]; # with
say 'yes' if $S ~~ / $=( $sol ) /;
say $;


yes
「」
yes
「with」





Re: regex interpolation of array

2020-06-13 Thread Brad Gilbert
Inside of a regex `{…}` will just run some regular Raku code.
Code inside of it will most likely have no effect on what the regex matches.

What you should have written was:

$ = "@W[3]"

The thing you were thinking of was:

$ = <{ @W[3] }>

Which could have been written as:



---

To have the result of regular Raku code have an effect on the match, it has
to have <…> around it

'TrueFalse' ~~ / <{ Bool.pick }> /

I think it is better if you use "…" if you are just interpolating a
variable, because that is something you might do outside of a regex as well.

---

The reason your code matched is that an empty regex always matches.

'abc' ~~ / "" /
'abc' ~~ / {} /
'abc' ~~ / {'def'} / # still an empty regex as far as the regex engine
is concerned

On Sat, Jun 13, 2020 at 5:35 AM Richard Hainsworth 
wrote:

> I was playing with a regex and array interpolation.
>
> From the documentation I thought the following comparisons would be the
> same, but they are not.
>
> What am I missing?
>
> my @W = ;my $S = 
> 'perlchallengeextrathingswithweeklysome' ; # randomly concatenate the words 
> without spacessay 'yes' if $S ~~ / $=( { @W[3] } ) /;say $;my $sol 
> = @W[3]; # withsay 'yes' if $S ~~ / $=( $sol ) /;say $;
>
> 
> yes
> 「」
> yes
> 「with」
>
>
>
>
>


regex interpolation of array

2020-06-13 Thread Richard Hainsworth

I was playing with a regex and array interpolation.

From the documentation I thought the following comparisons would be the 
same, but they are not.


What am I missing?

my @W = ;
my $S = 'perlchallengeextrathingswithweeklysome' ; #randomly concatenate the words 
without spaces say 'yes' if $S ~~ / $=( {@W[3] }) /;
say $;
my $sol = @W[3]; # with
say 'yes' if $S ~~ / $=( $sol ) /;
say $;


yes
「」
yes
「with」





Re: perl6 with Rakudobrew

2020-06-13 Thread Richard Hainsworth

Is the appveyor stanza (see the rakudobrew script below)

  - rakudobrew build moar %TEST_MOAR%
the same as what you are suggesting?

Richard

On 13/06/2020 02:53, Vadim Belman wrote:


Not really sure about it, but don't you have to do 'rakudobrew switch 
moar-%TEST_MOAR%' after building? rakudobrew doesn't immediately 
activates a build.


Best regards,
Vadim Belman

On Jun 12, 2020, at 4:03 PM, Richard Hainsworth 
mailto:rnhainswo...@gmail.com>> wrote:


I have tried two different strategies on appveyor. (I also run a 
travis test for the same Module that passes without a problem).


a) Copying from OpenSSL, which uses rakudo.git (see script below)

b) Copying from GTK::Simple, which uses Rakudobrew (see below)

Both failed for reasons I can't work out. (The final lines are below)


Could someone suggest an install stanza that would use the latest 
`rakudo-star-***.msi` installation package?


It would be good to have some samples in the raku documentation.

I can provide my travis script (I use JJ's docker image).

[Rakudobrew]

os: Visual Studio 2017

platform: x64

install:
   -'"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' - appveyor-retry choco install strawberryperl --allow-empty-checksums

   - SET 
PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
   - git clonehttps://github.com/tadzik/rakudobrew  %USERPROFILE%\rakudobrew
   - SET PATH=%USERPROFILE%\rakudobrew\bin;%PATH%
   - rakudobrew build moar %TEST_MOAR%
   - rakudobrew build zef
   - cd %APPVEYOR_BUILD_FOLDER%
   - echo "installing SSL so we can download the dll files"
   - zef install IO::Socket::SSL
   - zef --depsonly install .
   - zef build .

build: off

test_script:
   - prove -v -e "raku -Ilib" t/
   - zef --debug install .

shallow_clone: true
[ response from appveyor fail - last lines]
...
Generating code
Finished generating code
Microsoft (R) Program Maintenance Utility Version 14.16.27035.0
Copyright (C) Microsoft Corporation.  All rights reserved.
+++ Checking for moar NQP version
+++ Creating installation directories
+++ Removing old files
+++ Installing files
+++ Preparing installation
 Installed 13 core modules in 24.63815875 seconds!
+++ MOAR BACKEND INSTALLED
+++ Installing MOAR launchers
+++ Creating Raku executable alias
+++ Rakudo installed succesfully!
Rakudo has been built and installed.
Updating shims
Done, moar-2020.05.1 built
rakudobrew build zef
Cloning into 'zef'...
Your branch is up to date with 'origin/master'.
rakudobrew: perl6: command not found
Command exited with code 1

[Rakudo.git]
os: Visual Studio 2017

platform: x64

install:
   -'"C:\Program Files (x86)\Microsoft Visual 
Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' - appveyor-retry choco install strawberryperl --allow-empty-checksums

   - SET 
PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
   - appveyor-retry git clonehttps://github.com/rakudo/rakudo.git  
%APPVEYOR_BUILD_FOLDER%\..\rakudo
   - cd %APPVEYOR_BUILD_FOLDER%\..\rakudo
   - perl Configure.pl --gen-moar --gen-nqp --backends=moar
   - nmake install
   - SET PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\bin;%PATH%
   - SET 
PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\share\perl6\site\bin;%PATH%
   - cd %APPVEYOR_BUILD_FOLDER%
   - echo "installing SSL so we can download the dll files"
   - zef install IO::Socket::SSL
   - zef --depsonly install .
   - zef build .

build: off

test_script:
   - prove -v -e "raku -Ilib" t/
   - zef --debug install .

shallow_clone: true
[rakudo.git - avveyor failure. last lines]
+++ MOAR BACKEND INSTALLED
+++ Installing MOAR launchers
+++ Creating Raku executable alias
+++ Rakudo installed succesfully!
SET PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\bin;%PATH%
SET 
PATH=%APPVEYOR_BUILD_FOLDER%\..\rakudo\install\share\perl6\site\bin;%PATH%

cd %APPVEYOR_BUILD_FOLDER%
echo "installing SSL so we can download the dll files"
"installing SSL so we can download the dll files"
zef install IO::Socket::SSL
'zef' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 1

[end]

On 12/06/2020 20:15, Vadim Belman wrote:

I'm still using rakudobrew for myself, it is not a problem. Besides, we still 
install perl6.

What I'd look for is if correct PATH is setup; and check if rakudobrew is been 
used properly. Note that different modes (env or shim) would need different 
handling. To my understanding, in a container shims are preferable over env.

Best regards,
Vadim Belman


On Jun 12, 2020, at 2:40 PM, Elizabeth Mattijsen  wrote:

It is my understanding that rakudobrew has been renamed to 
rakubrew:https://rakubrew.org   Could the be the issue?


On 12 Jun 2020, at 14:59, Richard Hainsworth  wrote:

I ran into this error using Rakudobrew on appveyor (see after )

I'm new at using appveyor, so maybe my script is wrong. But I wonder whether 
its because of a name change to raku