Re: 2020.07 just hit

2020-07-21 Thread daniel
> $ raku --version
> This is Rakudo version 2020.07 built on MoarVM version 2020.07
> implementing Raku 6.d.
> Whats is new??

Release notes are at 
https://github.com/rakudo/rakudo/blob/master/docs/announce/2020.07.md

I'm most excited for new the Unicode operators, ≡ and ≢ (though the 
permutations speedup 
is pretty cool too).


Re: Baby steps to create a dataframe structure

2020-07-21 Thread Aureliano Guedes
Then, a native call to R may be better cus bring us dataframe an a lot of
statistical functions natively without other R's package.

But the idea is to implement cooperatively those tools.

On Tue, Jul 21, 2020 at 10:33 PM Tom Browder  wrote:

> On Tue, Jul 21, 2020 at 20:00 Warren Pang  wrote:
>
>> I have the same feeling. Perl5 has PDL which we have been using for data
>> analysis. While Raku seems to lack this.
>>
>
> I haven't looked into how it might work, but Raku does have the NativeCall
> interface as well as Inline::Perl5 which may help.
>
> I have had a lot of success with using CPAN's Perl modules with Raku
> programs.
>
> Best regards,
>
> -Tom
>
>

-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: Baby steps to create a dataframe structure

2020-07-21 Thread Tom Browder
On Tue, Jul 21, 2020 at 20:00 Warren Pang  wrote:

> I have the same feeling. Perl5 has PDL which we have been using for data
> analysis. While Raku seems to lack this.
>

I haven't looked into how it might work, but Raku does have the NativeCall
interface as well as Inline::Perl5 which may help.

I have had a lot of success with using CPAN's Perl modules with Raku
programs.

Best regards,

-Tom


Re: Baby steps to create a dataframe structure

2020-07-21 Thread Warren Pang
I have the same feeling. Perl5 has PDL which we have been using for data
analysis. While Raku seems to lack this.

Regards.


On Wed, Jul 22, 2020 at 7:42 AM Aureliano Guedes 
wrote:

> Hi all,
>
> I'd like to learn Raku deep enough to build a data structure. I have
> experience with Perl5, Python, R, and even C/C++, then I get boring
> feelings to learn something new from the beginning. Also, I prefer learning
> a new language by applying f to something.
>
> Since I work with data analysis and data science, I'd like to try to
> develop a data structure to dataframe in pure Raku. And if I do a basic but
> useful thing capable to load a field delimited file (as CSV or TSV) into a
> dataframe, I'll transform in a package and upload it to GitHub to
> comparatively enhance the package.
> What I need is suggestions for how do I start it.
> - How I define a data structure: an array of arrays?
> - Given the raku itself (and maybe some already existing packages) what
> the structures and functions I may use.
>
> I got these ideas to start:
>
> The dataframe should support columns name to be called as:
>
> df.column1
>
> and it should return a list of values on this column.
> Also, when it read the delim file it should check each column type.
>
>
> All suggestions are welcome.
>
>
>
> --
> Aureliano Guedes
> skype: aureliano.guedes
> contato:  (11) 94292-6110
> whatsapp +5511942926110
>


Re: I cannot install any lib with Zef

2020-07-21 Thread William Michels via perl6-users
Hello Aureliano,

What happens if you try either of the lines below (without the quotes
or version number):

$ zef install Digest::SHA256::Native
$ zef upgrade Digest::SHA256::Native

Additionally, we may need some more information from you--specifically
which operating system you're on. I recently solved a Mac-specific
issue with LibCurl thanks to a timely update from Curt Tilmes. If
you're interested, the LibCurl issue is below, and also I've included
a link to a long discussion/issue below from the zef Github repo on how zef
finds native libraries, see:

https://github.com/CurtTilmes/raku-libcurl/issues/16
https://github.com/ugexe/zef/issues/356

Other than that, you may need to open an issue with the
Digest::SHA256::Native module's author, at the Github repo below:

https://github.com/bduggan/p6-digest-sha256-native

HTH, Bill.



On Mon, Jul 20, 2020 at 11:15 AM Aureliano Guedes
 wrote:
>
> Thanks, I checked it out.
> now it is working
>
> But now I'm getting issues to install  zef install Jupyter::Kernel, the issue 
> itself is on Digest::SHA256::Native:ver<0.03> installation.
>
> $ zef install "Digest::SHA256::Native:ver<0.03>" --force-build --force-test
>>
>> ===> Searching for: Digest::SHA256::Native:ver<0.03>
>> ===> Building: Digest::SHA256::Native:ver<0.03>
>> [Digest::SHA256::Native] /usr/bin/ld: cannot find -lffi
>> [Digest::SHA256::Native] /usr/bin/ld: cannot find -ltommath
>> [Digest::SHA256::Native] /usr/bin/ld: cannot find -latomic_ops
>> [Digest::SHA256::Native] /usr/bin/ld: cannot find -luv
>> [Digest::SHA256::Native] collect2: error: ld returned 1 exit status
>> [Digest::SHA256::Native] make: *** 
>> [/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so]
>>  Error 1
>> [Digest::SHA256::Native] The spawned command 'make' exited unsuccessfully 
>> (exit code: 2)
>> [Digest::SHA256::Native]   in method build at 
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/Build.pm
>>  line 14
>> [Digest::SHA256::Native]   in block  at -e line 1
>> ===> Building [FAIL]: Digest::SHA256::Native:ver<0.03>
>> [Digest::SHA256::Native] Failed to build, but continuing with --force-build
>> ===> Testing: Digest::SHA256::Native:ver<0.03>
>> [Digest::SHA256::Native] Cannot locate native library 
>> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
>>  
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
>>  cannot open shared object file: No such file or directory
>> [Digest::SHA256::Native]   in method setup at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> line 290
>> [Digest::SHA256::Native]   in method CALL-ME at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> line 577
>> [Digest::SHA256::Native]   in sub sha256-hex at 
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
>>  (Digest::SHA256::Native) line 19
>> [Digest::SHA256::Native]   in sub sha256-hex at 
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
>>  (Digest::SHA256::Native) line 9
>> [Digest::SHA256::Native]   in block  at t/01-basic.t line 6
>> [Digest::SHA256::Native] Cannot locate native library 
>> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
>>  
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
>>  cannot open shared object file: No such file or directory
>> [Digest::SHA256::Native]   in method setup at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> line 290
>> [Digest::SHA256::Native]   in method CALL-ME at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> line 577
>> [Digest::SHA256::Native]   in sub sha256-hex at 
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
>>  (Digest::SHA256::Native) line 19
>> [Digest::SHA256::Native]   in block  at t/02-blob.t line 7
>> [Digest::SHA256::Native] Cannot locate native library 
>> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
>>  
>> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
>>  cannot open shared object file: No such file or directory
>> [Digest::SHA256::Native]   in method setup at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> line 290
>> [Digest::SHA256::Native]   in method CALL-ME at 
>> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) 
>> 

Baby steps to create a dataframe structure

2020-07-21 Thread Aureliano Guedes
Hi all,

I'd like to learn Raku deep enough to build a data structure. I have
experience with Perl5, Python, R, and even C/C++, then I get boring
feelings to learn something new from the beginning. Also, I prefer learning
a new language by applying f to something.

Since I work with data analysis and data science, I'd like to try to
develop a data structure to dataframe in pure Raku. And if I do a basic but
useful thing capable to load a field delimited file (as CSV or TSV) into a
dataframe, I'll transform in a package and upload it to GitHub to
comparatively enhance the package.
What I need is suggestions for how do I start it.
- How I define a data structure: an array of arrays?
- Given the raku itself (and maybe some already existing packages) what the
structures and functions I may use.

I got these ideas to start:

The dataframe should support columns name to be called as:

df.column1

and it should return a list of values on this column.
Also, when it read the delim file it should check each column type.


All suggestions are welcome.



-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: I cannot install any lib with Zef

2020-07-21 Thread Timo Paulssen
I would assume the ffi, tommath, atomic_ops, and uv linker flags come
straight from moarvm's linker flags, probably because the build script
of Digest::SHA256::Native uses the flags used to compile moarvm itself.
If you've compiled your moarvm yourself, this is a safe bet; these
libraries are guaranteed to exist unless you've uninstalled them in the
mean time. If you get the stuff from a package instead, that's not quite
as sensible …

On 20/07/2020 20:15, Aureliano Guedes wrote:
> Thanks, I checked it out. 
> now it is working
>
> But now I'm getting issues to install  zef install Jupyter::Kernel,
> the issue itself is on Digest::SHA256::Native:ver<0.03> installation.
>
> $ zef install "Digest::SHA256::Native:ver<0.03>" --force-build
> --force-test
>
> ===> Searching for: Digest::SHA256::Native:ver<0.03>
> ===> Building: Digest::SHA256::Native:ver<0.03>
> [Digest::SHA256::Native] /usr/bin/ld: cannot find -lffi
> [Digest::SHA256::Native] /usr/bin/ld: cannot find -ltommath
> [Digest::SHA256::Native] /usr/bin/ld: cannot find -latomic_ops
> [Digest::SHA256::Native] /usr/bin/ld: cannot find -luv
> [Digest::SHA256::Native] collect2: error: ld returned 1 exit status
> [Digest::SHA256::Native] make: ***
> 
> [/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so]
> Error 1
> [Digest::SHA256::Native] The spawned command 'make' exited
> unsuccessfully (exit code: 2)
> [Digest::SHA256::Native]   in method build at
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/Build.pm
> line 14
> [Digest::SHA256::Native]   in block  at -e line 1
> ===> Building [FAIL]: Digest::SHA256::Native:ver<0.03>
> [Digest::SHA256::Native] Failed to build, but continuing with
> --force-build
> ===> Testing: Digest::SHA256::Native:ver<0.03>
> [Digest::SHA256::Native] Cannot locate native library
> 
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> [Digest::SHA256::Native]   in sub sha256-hex at
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 9
> [Digest::SHA256::Native]   in block  at t/01-basic.t line 6
> [Digest::SHA256::Native] Cannot locate native library
> 
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> [Digest::SHA256::Native]   in block  at t/02-blob.t line 7
> [Digest::SHA256::Native] Cannot locate native library
> 
> '/home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so':
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/resources/libraries/libsha256.so:
> cannot open shared object file: No such file or directory
> [Digest::SHA256::Native]   in method setup at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 290
> [Digest::SHA256::Native]   in method CALL-ME at
> /usr/lib/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03
> (NativeCall) line 577
> [Digest::SHA256::Native]   in sub sha256-hex at
> 
> /home/acpguedes/.zef/store/Digest-SHA256-Native-0.03.tar.gz/Digest-SHA256-Native-0.03/lib/Digest/SHA256/Native.pm6
> (Digest::SHA256::Native) line 19
> 

Re: 2020.07 just hit

2020-07-21 Thread Aureliano Guedes
$ raku --version
This is Rakudo version 2020.07 built on MoarVM version 2020.07
implementing Raku 6.d.

Whats is new??


On Tue, Jul 21, 2020 at 6:21 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> GetRaku   new update downloaded  2020.06 --> 2020.07
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


2020.07 just hit

2020-07-21 Thread ToddAndMargo via perl6-users

GetRaku   new update downloaded  2020.06 --> 2020.07


Re: BUILD and TWEAK

2020-07-21 Thread Vadim Belman


Oh, and the thing I forgot to mention: contrary to BUILD and TWEAK, DESTROY is 
invoked by underlying backend VM. I.e. by MoarVM, or JVM, or JS because only 
the VM knows when exactly an object cease to exists.

Best regards,
Vadim Belman

> On Jul 21, 2020, at 4:53 AM, Richard Hainsworth  
> wrote:
> 
> Trying to update the documentation on submethod TWEAK - there is nothing.
> 
> But the documentation should be accurate and not confusing. So some questions:
> 
> In a loop or program, things like BUILD or LEAVE or FIRST are called 
> 'phasers'.
> 
> By analogy, during the 'build' process of instantiating an object from a 
> class, two 'submethod's can be called, viz.
> 
> submethod BUILD and submethod TWEAK.
> 
> 1) Should these submethods be considered 'phasers' to be consistent with 
> other BUILD, LEAVE etc usages?
> 
> 2) What actually calls these submethods?
> 
> The documentation says 'bless' indirectly calls submethod BUILD. But the 
> documentation seems to indicate that 'bless' is not needed to create an 
> object.
> 
> So what calls the submethods?
> 
> 3) Is it correct to say that TWEAK can access all the attributes of the 
> object?
> 
> 4) How to describe the way the TWEAK of a subclass accesses attributes in the 
> parent?
> 
> eg
> 
> class A { has $.thing }
> 
> class B is A { submethod TWEAK { #do something to $.thing in A } }
> 


Re: BUILD and TWEAK

2020-07-21 Thread Vadim Belman


> On Jul 21, 2020, at 4:53 AM, Richard Hainsworth  
> wrote:
> 
> Trying to update the documentation on submethod TWEAK - there is nothing.
> 
> But the documentation should be accurate and not confusing. So some questions:
> 
> In a loop or program, things like BUILD or LEAVE or FIRST are called 
> 'phasers'.

s/BUILD/BEGIN/

BUILD is a constructor. Same applies to TWEAK. Both are invoked at construction 
time but have different semantics. BUILD must take care of attribute 
initialization. If not installed, the core installs one for you. TWEAK is 
invoked at the last stage of construction is is able to tweak object state, as 
the name suggests.

> 
> By analogy, during the 'build' process of instantiating an object from a 
> class, two 'submethod's can be called, viz.
> 
> submethod BUILD and submethod TWEAK.
> 
> 1) Should these submethods be considered 'phasers' to be consistent with 
> other BUILD, LEAVE etc usages?

No. A phaser something responsible for a phase in code execution. BUILD, TWEAK, 
and DESTROY are responsible for  object life cycle.

BTW, there was once a discussion about a common name for all of them. But I 
don't remember if there was any consensus reached. In either case, 
'constructors' and 'destructors' terms are commonplace.

> 
> 2) What actually calls these submethods?

With some level of simplification I can say that BUILD and TWEAK are invoked by 
method new. There is some indirection level though.

> 
> The documentation says 'bless' indirectly calls submethod BUILD. But the 
> documentation seems to indicate that 'bless' is not needed to create an 
> object.

'bless' is kind of a simplified version of 'new'. You can find them in Rakudo 
src/core.c/Mu.pm.

> 
> 3) Is it correct to say that TWEAK can access all the attributes of the 
> object?

TWEAK can access all attributes of its class and public attributes of parent 
classes. BEGIN and TWEAK can't use `$.attribute` notation though, only 
`$!attribute` or `self.attribute`.

> 
> 4) How to describe the way the TWEAK of a subclass accesses attributes in the 
> parent?

It's done same way as accessing any parent method, as described above.

Best regards,
Vadim Belman


Re: Pod6 examples

2020-07-21 Thread Parrot Raiser
Thanks, Richard and daniel.

On 7/21/20, Richard Hainsworth  wrote:
> How about:
>
> https://github.com/Raku/doc/tree/master/doc/Language/pod.pod6
>
> which is the pod source of https://docs.raku.org/language/pod
>
> Also try the other sources under the
> https://github.com/Raku/doc/tree/master/doc directory.
>
> Richard
>
> On 21/07/2020 15:40, Parrot Raiser wrote:
>> Can anyone point me at examples of pod6 in use? I'm trying to relate
>> the syntax shown in https://docs.raku.org/language/pod to actual
>> results. Concise would be nice, tutorial even better.
>


Re: Pod6 examples

2020-07-21 Thread JJ Merelo
El mar., 21 jul. 2020 a las 17:23, Richard Hainsworth (<
rnhainswo...@gmail.com>) escribió:

> How about:
>
> https://github.com/Raku/doc/tree/master/doc/Language/pod.pod6
>
> which is the pod source of https://docs.raku.org/language/pod


This page is also intended as a tutorial. If there's something you miss
there, we'd be happy to get an issue about it (or a PR).

Cheers

JJ


Re: Pod6 examples

2020-07-21 Thread daniel
> Can anyone point me at examples of pod6 in use?… Concise would be nice,

One concise example I've found useful is the Pod::Load script, 
https://modules.raku.org/dist/Pod::Load:cpan:JMERELO/lib/Pod/Load.pm6
This short script shows pod6 used both as a more full-featured 
documentation format (the text between `=begin pod` and `=end pod`)
and for inline "docstring"-like function documentation – which is then 
available at runtime via the `WHY` method – (the comments starting with
`#|`.

> tutorial even better.

I'm not aware of any tutorials, but I wouldn't be surprised if some exist
– there have been a lot of Raku blog posts over the years.  Maybe someone
else will know of one.


Re: Pod6 examples

2020-07-21 Thread Richard Hainsworth

How about:

https://github.com/Raku/doc/tree/master/doc/Language/pod.pod6

which is the pod source of https://docs.raku.org/language/pod

Also try the other sources under the 
https://github.com/Raku/doc/tree/master/doc directory.


Richard

On 21/07/2020 15:40, Parrot Raiser wrote:

Can anyone point me at examples of pod6 in use? I'm trying to relate
the syntax shown in https://docs.raku.org/language/pod to actual
results. Concise would be nice, tutorial even better.


Pod6 examples

2020-07-21 Thread Parrot Raiser
Can anyone point me at examples of pod6 in use? I'm trying to relate
the syntax shown in https://docs.raku.org/language/pod to actual
results. Concise would be nice, tutorial even better.


Re: subs and the type system

2020-07-21 Thread Theo van den Heuvel
Given that the signature is going to be more complex, it would be 
helpful if I do not need to repeat it for every member of the Walkable 
class. I tried using a constant to represent the signature so that I can 
create new Walkables without having to spell it out. Here is my code 
attempt (not working)



use v6;

class WalkData {
  has Str $.xyzzy;
}

constant \sgn-walkable = :(WalkData $d --> Any);

subset Walkable of Callable where { .signature ~~ sgn-walkable };

sub walk(Walkable $task) {
  do-something($task, 17);
}

sub do-something(Walkable $task, Int $a) {
  $task($a);
  say $a;
}

my Walkable $xyzzify = -> :sgn-walkable { say $d.xyzzy };

walk($xyzzify);


I get this error.
===SORRY!===
Expression needs parens to avoid gobbling block
at /.../walkable.pl6:10
--> ble where { .signature ~~ sgn-walkable }⏏;
Missing block (apparently claimed by expression)
at /.../walkable.pl6:21
--> my Walkable $xyzzify = ⏏-> :sgn-walkable { say $d.xyzzy };


I tried to use the scalar sigil instead of the sigilless constant. To no 
avail.


I am hoping for a form that allows me to define Walkables as such.


Thanks,
Theo van den Heuvel


Tobias Boege schreef op 2020-07-20 14:00:

On Mon, 20 Jul 2020, Theo van den Heuvel wrote:

Hi gurus,

after looking at the documentation on Sub, Signature and the raku type
system I find myself unable to constrain the types of functions in the 
way I

think I need.

The situation: I have a function, let's call in 'walker', whose first
parameter is a callback.
I wish to express that only callbacks with a certain Signature and 
return

type are acceptable.
Let's say the callback should follow :(Numeric $n --> Numeric). My 
callback

is going to be more complicated, but for simplicity sake.

I was hoping to be able to use a named type of function with this 
signature.

I know I can say

my $sig =  :(Numeric $n --> Numeric);

but my attempts to use $sig fail. I found no example of an application
beyond smartmatching.

[...]

but I was hoping for an explicit type, maybe using class, or subset or
roles.
I hope to say soemething like

sub walker(Walkable , ...)

What am I missing here?



You said that you know how to check signatures via smartmatching.
Smartmatching is great, there isn't much to know beyond it. The way
to shoehorn smartmatching into the type system is `subset`:

  subset Walkable of Callable where {
  .signature ~~ :(Numeric --> Numeric)
  };

If your callback signature is more complicated, all the more reason to
give it a name via subset. You can use it now almost like you wanted:

  sub walker (Walkable $w) {
  say $w($_) for 1..10
  }

  walker(-> Numeric $x --> Numeric { $x.sqrt });  # WORKS
  walker(-> $x { $x.sqrt });  # DOESN'T

You cannot write `Walkable ` in the signature of  because the
combination of a type and the &-sigil apparently means that `` should
be Callable and return a Walkable. That's why I use the $-sigil. [*]

Note that if you constrain the signature of a Callable, then you have
to provide the appropriate signature statically, as demonstrated.

Best,
Tobias

[*] N.B. I failed to find a reference for this in the documentation.
I discovered it by writing `sub walker (Int )` and provoking a type
checking error which told me that it was expecting `Callable[Int]`.
(That was also my gut feeling.) According to source code, Callable is
a parametric role in Rakudo whose first parameter indeed is the return
type. This is all somewhat nebulous to me (how does the Callable-
parametric way to specify return type compare with smartmatching
against .signature, for example? They don't seem equivalent!), so
I stick with the $-sigil.


BUILD and TWEAK

2020-07-21 Thread Richard Hainsworth

Trying to update the documentation on submethod TWEAK - there is nothing.

But the documentation should be accurate and not confusing. So some 
questions:


In a loop or program, things like BUILD or LEAVE or FIRST are called 
'phasers'.


By analogy, during the 'build' process of instantiating an object from a 
class, two 'submethod's can be called, viz.


submethod BUILD and submethod TWEAK.

1) Should these submethods be considered 'phasers' to be consistent with 
other BUILD, LEAVE etc usages?


2) What actually calls these submethods?

The documentation says 'bless' indirectly calls submethod BUILD. But the 
documentation seems to indicate that 'bless' is not needed to create an 
object.


So what calls the submethods?

3) Is it correct to say that TWEAK can access all the attributes of the 
object?


4) How to describe the way the TWEAK of a subclass accesses attributes 
in the parent?


eg

class A { has $.thing }

class B is A { submethod TWEAK { #do something to $.thing in A } }


Re: recent perl6 book

2020-07-21 Thread Warren Pang
Thank you a lot JJ.

On Tue, Jul 21, 2020 at 3:11 PM JJ Merelo  wrote:

> I would obviously suggest my own book
> https://www.apress.com/gp/book/9781484249550, Perl 6 Quick Syntax
> Reference, published last October.
> And we'll have to try and find a way to update that file...
>
> El mar., 21 jul. 2020 a las 4:02, Warren Pang ()
> escribió:
>
>> Greetings,
>>
>> Would you suggest a recent release of perl6 book?
>> I took a look here:
>> https://perl6book.com/
>>
>> They seem out of date, most were published before 2018.
>>
>> Thank you.
>>
>
>
> --
> JJ
>


Re: recent perl6 book

2020-07-21 Thread JJ Merelo
OK, it's right there, at the bottom https://github.com/moritz/perl6book-web

El mar., 21 jul. 2020 a las 9:11, JJ Merelo () escribió:

> I would obviously suggest my own book
> https://www.apress.com/gp/book/9781484249550, Perl 6 Quick Syntax
> Reference, published last October.
> And we'll have to try and find a way to update that file...
>
> El mar., 21 jul. 2020 a las 4:02, Warren Pang ()
> escribió:
>
>> Greetings,
>>
>> Would you suggest a recent release of perl6 book?
>> I took a look here:
>> https://perl6book.com/
>>
>> They seem out of date, most were published before 2018.
>>
>> Thank you.
>>
>
>
> --
> JJ
>


-- 
JJ


Re: recent perl6 book

2020-07-21 Thread JJ Merelo
I would obviously suggest my own book
https://www.apress.com/gp/book/9781484249550, Perl 6 Quick Syntax
Reference, published last October.
And we'll have to try and find a way to update that file...

El mar., 21 jul. 2020 a las 4:02, Warren Pang () escribió:

> Greetings,
>
> Would you suggest a recent release of perl6 book?
> I took a look here:
> https://perl6book.com/
>
> They seem out of date, most were published before 2018.
>
> Thank you.
>


-- 
JJ