Re: perl streaming framework

2020-07-15 Thread Shlomi Fish
Hi Warren!

On Wed, 15 Jul 2020 08:43:33 +0800
Warren Pang  wrote:

> Thank you all very much.
> 
> I have tried to search "perl discussion" and it brings me to perl6's list
> page.
> Yes for data analysis we primarily use classic perl5, which is smart enough
> especially the regex matching.
> There are "spark streaming", "flink streaming", "storm streaming", and a
> lot of others, but they don't support perl language well.
> So I expect the community, either perl6 or perl5, can make that a framework.

"Perl 6" is now called Raku and is not compatible with Perl 5.

Regarding "the community" making something - I recall a similar request (or was
it a demand?) on a Perl facebook group that we must have a
https://en.wikipedia.org/wiki/Massive_open_online_course (MOOC) for Perl. As
usual with FOSS, time consuming suggestions can be materialised either by
investing time, or by motivating contributors using money. Otherwise, they
often don't get materialised.

> We can't lose the capability in big data, cloud computing, AI, ML,
> streaming, these are the main features of current internet.

From what I know, not everyone is doing AI (which I was told requires a
relevant M.Sc and has a high barrier to entry) and "machine learning" is not
the only approach to AI:

https://fc-solve.shlomifish.org/faq.html#machine_learning

> Everyone today writes CGI with perl? NO.
> 

Not everyone today writes CGI scripts, or uses Perl for them, but some people
still do. These include me because I prefer to use shared web hosting, where,
for server side scripting, I can use either PHP (which I dislike, see:
https://www.shlomifish.org/open-source/anti/php/ ) or CGI scripts (in Perl or
Python or similar). So I still use two such scripts in Perl and one which I
translated from Perl to Python (not because I was unhappy with the Perl code,
but because I've been trying to learn Python better) along with many
generated static pages and assets here:

* https://www.shlomifish.org/meta/site-source/

I was once told that generated static HTML should be avoided because PHP is the
present and the future, but it seems they were proven wrong too:

*
https://github.com/shlomif/shlomif-tech-diary/blob/master/static-site-generators--despair.md

I'm not saying server-side-scripting is not useful, but generated static sites
are still of utility as well.

> Thanks.



-- 

Shlomi Fish   https://www.shlomifish.org/
My Photos - https://www.flickr.com/photos/shlomif/

“Stop reinventing wheels, start building space rockets.”
— The motto of the Comprehensive Perl Archive Network

Please reply to list if it's a mailing list post - https://shlom.in/reply .


Re: proto and multi

2020-07-15 Thread William Michels via perl6-users
Reviving this thread...

Synopsis: the previous discussion revolved around an error seen with a
whatever-star of the format  "{ * }"  (with spaces around the star). The
error was corrected by removing the spaces to use the whatever-star
"{*}"   format.

So why then does the Raku NativeLibs module say to use the "{ * }" format?
See:

https://github.com/salortiz/NativeLibs

>From the ReadMe.md:

use NativeLibs; # This also re-exports NativeCall :DEFAULTS for
conveniencemy $Lib; # To keep the reference
sub some_native_func() is native { * } # Note no library needed
… The rest of your module
INIT {
# Load the needed library
without $Lib = NativeLibs::Loader.load('libsomelib.so.4') {
.fail;
}
}
…


It seems that some of these tiny differences--such adding a space or
two--could end up being a very off-putting source of frustration for people
who are just starting out (and even for experienced programmers as well).

Best, Bill.

W. Michels, Ph.D.


On Mon, Jun 29, 2020 at 11:32 AM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> On Mon, Jun 29, 2020 at 8:22 PM Richard Hainsworth 
> wrote:
>
>> a) I don't understand why the white space matters, but clearly it does.
>> So the token is '{*}' and not braces around a Whatever-star.
>>
> For an explanation see the thread "Playing with protos and phasers" that I
> started here three days ago.
>
> b) Removing the space yields the following response.
>> in string
>> Cannot resolve caller handle(NewClass:D: List:D); none of these
>> signatures match:
>> (NewClass: Str $s, *%_)
>> (NewClass: Positional @s, *%_)
>>   in method handle at test.raku line 15
>>   in block  at test.raku line 30
>>
>> Not sure why the List:D is not being matched to Positional. Is the List:D
>> refering to the |c signature capture ??
>>
>> Since 'in string' was printed, one of the methods was reached. Confused.
>>
>> c) Writing out all the code in each method is what I already have. But
>> I'm looking for ways to factor out common code.
>>
>> Regards
>> On 29/06/2020 18:44, Fernando Santagata wrote:
>>
>> After deleting the spaces as suggested, there's a "Positional" too many.
>> I guess you can rewrite that method declaration as
>>
>> multi method handle(@s)
>>
>> or
>>
>> multi method handle(Positional $s)
>>
>> and adjust the method's body.
>>
>> On Mon, Jun 29, 2020 at 7:37 PM yary  wrote:
>>
>>> It looks like you have spaces in the token { * } can you try it without,
>>> using this {*} instead?
>>>
>>> On Mon, Jun 29, 2020, 1:29 PM Richard Hainsworth 
>>> wrote:
>>>
 I have several multi methods.

 All of them have the same first statement, then differ depending on the
 signature.

 proto seems to be a way to factor out the common statement, and there
 is a phrase in the Documentation that * can affect the dispatch, viz:

 "You can give the proto a function body, and place the {*} where you
 want the dispatch to be done. This can be useful when you have a "hole" in
 your routine that gives it different behavior depending on the arguments
 given:"

 The docs give and example proto, but unfortunately, not how this works
 with other multi's.

 So  I tried this:

 class NewClass {
 has $.debug is rw = False;
 has $.value is rw = 'Initial value';

 proto method handle( |c ) {
 note "value is $.value" if $.debug;
 { * }}
 multi method handle(Str $s) {
 $.value = $s;
 say 'in string'}
 multi method handle(Positional @s) {
 $.value = @s[0];
 say 'in positional'}
 }
 my NewClass $x .= new;
 $x.handle('hello world');$x.handle();$x.debug = 
 True;$x.handle('hello world');$x.handle();

 #raku test.raku
 #value is Initial value
 #value is Initial value

 I am wondering how to use proto and {*}


>>
>> --
>> Fernando Santagata
>>
>>
>
> --
> Fernando Santagata
>