Re: Playing with protos and phasers

2020-06-25 Thread Brad Gilbert
While {*} is only useful in a proto, the compiler detects it no matter
where you write it.

> my $block = {*};
===SORRY!=== Error while compiling:
{*} may only appear in proto
at line 2
--> ⏏

On Thu, Jun 25, 2020 at 3:48 PM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> On Thu, Jun 25, 2020 at 8:10 PM Brad Gilbert  wrote:
>
>> {*} is specially handled by the compiler as a term.
>>
>
> Thank you!
>
> I guess that handling is peculiar to proto, and maybe it's worth
> documenting it.
>
> --
> Fernando Santagata
>


Re: Playing with protos and phasers

2020-06-25 Thread Fernando Santagata
On Thu, Jun 25, 2020 at 8:10 PM Brad Gilbert  wrote:

> {*} is specially handled by the compiler as a term.
>

Thank you!

I guess that handling is peculiar to proto, and maybe it's worth
documenting it.

-- 
Fernando Santagata


Re: Playing with protos and phasers

2020-06-25 Thread Brad Gilbert
{*} is specially handled by the compiler as a term.

Let's say you have a class named Foo:

class Foo {…}

You wouldn't expect to be able to use it like this:

F o o.new()

It is the same thing with {*}.
The only difference is that {*} is meant to look like a Block { } combined
with a Whatever *.
It was meant to be both visually distinctive, and visually similar to how
you might think about it.

---

If you were allowed to add spaces to the {*} term, it would be annoying if
you wanted to create a lambda that returned a Whatever.

my $block = { * };

say $block.() ~~ Whatever; # True.

On Thu, Jun 25, 2020 at 2:47 AM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> Hi *,
> I was trying to see if one can delegate phasers to a proto, like this:
>
> proto sub foo(|) {
>   ENTER { say 'In' }
>   LEAVE { say 'Out' }
>   {*}
> }
> multi sub foo(Int $a) {
>   $a
> }
> multi sub foo(Str $a) {
>   $a
> }
>
> say foo(1);
> say foo('hello');
>
> Yes indeed, it outputs:
>
> In
> Out
> 1
> In
> Out
> hello
>
> But at first it didn't work, because I added a space on both sides of the
> '*':
>
> proto sub foo(|) {
>   ENTER { say 'In' }
>   LEAVE { say 'Out' }
>   { * }
> }
>
> It outputs:
>
> In
> Out
> *
> In
> Out
> *
>
> If I add a return:
>
> proto sub foo(|) {
>   ENTER { say 'In' }
>   LEAVE { say 'Out' }
>   return { * }
> }
>
> it outputs:
>
> In
> Out
> -> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346387904) ... }
> In
> Out
> -> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346388120) ... }
>
> Why are spaces significant in this case?
>
> If this behavior is intentional, can this be a trap worth being documented?
>
> --
> Fernando Santagata
>


Re: Access violation when creating class instance

2020-06-25 Thread WFB
Not reproducible with raku star 2020.05.1 \o/
Thanks for the help

On Thu, 25 Jun 2020 at 09:23, WFB  wrote:

> Uh, thanks Will!!
>
> On Thu, 25 Jun 2020 at 01:16, Will Coleda  wrote:
>
>> The download page requires an update. You can get 2020.05.1 here:
>>
>> https://rakudo.org/downloads/star/
>>
>> On Wed, Jun 24, 2020 at 6:11 AM WFB  wrote:
>> >
>> > Thanks JJ,
>> >
>> > I am using Rakudostar on Windows and 2020.01 is the current released
>> version so far.
>> > I will try to reduce the code a bit more but it is just one class
>> definition together with an instantiation. Not sure I can pack that in a
>> one liner, but will try.
>> >
>> > The access violation comes probably from C code handling some Windows
>> stuff.
>> >
>> > On Wed, 24 Jun 2020 at 10:13, JJ Merelo  wrote:
>> >>
>> >>
>> >>
>> >> El mié., 24 jun. 2020 a las 10:05, WFB ()
>> escribió:
>> >>>
>> >>> Hi all,
>> >>>
>> >>> I have an access violation on Windows for one of my classes and think
>> it is a bug, but not entirely sure about that.
>> >>>
>> >>> Every now and then creating a class instance ended my script with
>> error:
>> >>> Process finished with exit code -1073741819 (0xC005)
>> >>>
>> >>> The class looks like that:
>> >>>
>> >>> class KnowledgeKeeper::Note {
>> >>> has $.title is required;
>> >>> has $.data is required;
>> >>> has @.tags;
>> >>> has @.attachments;
>> >>> has DateTime $.creation-date = DateTime.now;
>> >>> has DateTime $.modification-date = DateTime.now;
>> >>> }
>> >>>
>> >>> I first recognized it when a test just ended without dieing. That
>> happens about in 50% of the test runs.
>> >>> But I could reproduce it with just a simple line in a script:
>> >>>
>> >>> #!/usr/bin/env perl6
>> >>> use KnowledgeKeeper::Note;
>> >>>
>> >>> my $note = KnowledgeKeeper::Note.new(title => "dasd", data =>
>> "adsad");
>> >>> say "OK";
>> >>>
>> >>> With this script it is not failing that much but at least
>> reproducible:
>> >>>
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>OK
>> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>>   PS C:\dev\repos\KnowledgeKeeper>
>> $LastExitCode
>> -1073741819
>> >>>
>> >>> OS: Windows 10 1909 x64
>> >>> Raku: This is Rakudo version 2020.01 built on MoarVM version
>> 2020.01.1 implementing Perl 6.d.
>> >>>
>> >>> Should I file a bug?
>> >>
>> >>
>> >> Definitely, yes. Please check first if it's still the same problem
>> with the latest released version. Also, try to golf it down to the minimal
>> amount of code that still produces the same result. Does the LastExitCode
>> make any sense?
>> >>
>> >> --
>> >> JJ
>>
>


Playing with protos and phasers

2020-06-25 Thread Fernando Santagata
Hi *,
I was trying to see if one can delegate phasers to a proto, like this:

proto sub foo(|) {
  ENTER { say 'In' }
  LEAVE { say 'Out' }
  {*}
}
multi sub foo(Int $a) {
  $a
}
multi sub foo(Str $a) {
  $a
}

say foo(1);
say foo('hello');

Yes indeed, it outputs:

In
Out
1
In
Out
hello

But at first it didn't work, because I added a space on both sides of the
'*':

proto sub foo(|) {
  ENTER { say 'In' }
  LEAVE { say 'Out' }
  { * }
}

It outputs:

In
Out
*
In
Out
*

If I add a return:

proto sub foo(|) {
  ENTER { say 'In' }
  LEAVE { say 'Out' }
  return { * }
}

it outputs:

In
Out
-> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346387904) ... }
In
Out
-> ;; $_? is raw = OUTER::<$_> { #`(Block|94038346388120) ... }

Why are spaces significant in this case?

If this behavior is intentional, can this be a trap worth being documented?

-- 
Fernando Santagata


Re: Access violation when creating class instance

2020-06-25 Thread WFB
Uh, thanks Will!!

On Thu, 25 Jun 2020 at 01:16, Will Coleda  wrote:

> The download page requires an update. You can get 2020.05.1 here:
>
> https://rakudo.org/downloads/star/
>
> On Wed, Jun 24, 2020 at 6:11 AM WFB  wrote:
> >
> > Thanks JJ,
> >
> > I am using Rakudostar on Windows and 2020.01 is the current released
> version so far.
> > I will try to reduce the code a bit more but it is just one class
> definition together with an instantiation. Not sure I can pack that in a
> one liner, but will try.
> >
> > The access violation comes probably from C code handling some Windows
> stuff.
> >
> > On Wed, 24 Jun 2020 at 10:13, JJ Merelo  wrote:
> >>
> >>
> >>
> >> El mié., 24 jun. 2020 a las 10:05, WFB ()
> escribió:
> >>>
> >>> Hi all,
> >>>
> >>> I have an access violation on Windows for one of my classes and think
> it is a bug, but not entirely sure about that.
> >>>
> >>> Every now and then creating a class instance ended my script with
> error:
> >>> Process finished with exit code -1073741819 (0xC005)
> >>>
> >>> The class looks like that:
> >>>
> >>> class KnowledgeKeeper::Note {
> >>> has $.title is required;
> >>> has $.data is required;
> >>> has @.tags;
> >>> has @.attachments;
> >>> has DateTime $.creation-date = DateTime.now;
> >>> has DateTime $.modification-date = DateTime.now;
> >>> }
> >>>
> >>> I first recognized it when a test just ended without dieing. That
> happens about in 50% of the test runs.
> >>> But I could reproduce it with just a simple line in a script:
> >>>
> >>> #!/usr/bin/env perl6
> >>> use KnowledgeKeeper::Note;
> >>>
> >>> my $note = KnowledgeKeeper::Note.new(title => "dasd", data => "adsad");
> >>> say "OK";
> >>>
> >>> With this script it is not failing that much but at least reproducible:
> >>>
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
>  OK
> >>> PS C:\dev\repos\KnowledgeKeeper> raku -Ilib .\bin\test.p6
> PS C:\dev\repos\KnowledgeKeeper>
> $LastExitCode
> -1073741819
> >>>
> >>> OS: Windows 10 1909 x64
> >>> Raku: This is Rakudo version 2020.01 built on MoarVM version 2020.01.1
> implementing Perl 6.d.
> >>>
> >>> Should I file a bug?
> >>
> >>
> >> Definitely, yes. Please check first if it's still the same problem with
> the latest released version. Also, try to golf it down to the minimal
> amount of code that still produces the same result. Does the LastExitCode
> make any sense?
> >>
> >> --
> >> JJ
>