Re: Issue #1 of the Science Perl Journal now on sale at Barnes & Noble

2024-10-16 Thread Elizabeth Mattijsen
*

> On 16 Oct 2024, at 16:53, William Michels via perl6-users 
>  wrote:
> 
> https://science.perlcommunity.org/spj/index
> 
> "About the Journal"
> 
> "The Science Perl Journal is a venue for submission of Perl and Raku related 
> papers and posters that relate to science, technology, engineering, and 
> mathematics."
> 
> https://science.perlcommunity.org/spj/about
> 
> 
>> On Oct 16, 2024, at 06:02, Elizabeth Mattijsen  wrote:
>> 
>> https://www.barnesandnoble.com/w/the-science-perl-journal-issue-1-marc-perry/1146395697
>>  states:
>> 
>> "The Science Perl Journal is sponsored by the Science Perl Committee of the 
>> Public Enrichment and Robotics Laboratories, the world's only 501(c)(3) 
>> nonprofit focused solely on Perl."
>> 
>> Note: "the world's only" and "solely on Perl".
>> 
>> The "Science Perl Committee of the Public Enrichment and Robotics 
>> Laboratories" consists of Brett Estrada and Will Braswell Jr, the editors of 
>> the Science Perl Journal.
>> 
>> https://science.perlcommunity.org/spj/about/editorialTeam
>> 
>> This is:
>> 
>> - a stab at TPRF, saying if you want to sponsor Perl, you need to be here, 
>> and not at TPRF
>> - an indication that they're *NOT* interested in Raku
>> 
>> So, no I don't think they welcome Raku submissions.
>> 
>> 
>>> On 16 Oct 2024, at 14:25, William Michels via perl6-users 
>>>  wrote:
>>> 
>>> I spoke to Brett Estrade and they welcome Raku submissions.
>>> 
>>> --B.
>>> 
>>>> On Oct 16, 2024, at 04:27, Todd Chester via perl6-users 
>>>>  wrote:
>>>> 
>>>> Perl 5?
>>> 
>> 
> 



Re: Issue #1 of the Science Perl Journal now on sale at Barnes & Noble

2024-10-16 Thread Elizabeth Mattijsen
https://www.barnesandnoble.com/w/the-science-perl-journal-issue-1-marc-perry/1146395697
 states:

"The Science Perl Journal is sponsored by the Science Perl Committee of the 
Public Enrichment and Robotics Laboratories, the world's only 501(c)(3) 
nonprofit focused solely on Perl."

Note: "the world's only" and "solely on Perl".

The "Science Perl Committee of the Public Enrichment and Robotics Laboratories" 
consists of Brett Estrada and Will Braswell Jr, the editors of the Science Perl 
Journal.

https://science.perlcommunity.org/spj/about/editorialTeam

This is:

- a stab at TPRF, saying if you want to sponsor Perl, you need to be here, and 
not at TPRF
- an indication that they're *NOT* interested in Raku

So, no I don't think they welcome Raku submissions.


> On 16 Oct 2024, at 14:25, William Michels via perl6-users 
>  wrote:
> 
> I spoke to Brett Estrade and they welcome Raku submissions.
> 
> --B.
> 
>> On Oct 16, 2024, at 04:27, Todd Chester via perl6-users 
>>  wrote:
>> 
>> Perl 5?
> 



Re: Issue #1 of the Science Perl Journal now on sale at Barnes & Noble

2024-10-16 Thread Elizabeth Mattijsen
> On 16 Oct 2024, at 13:27, Todd Chester via perl6-users  
> wrote:
> 
> Perl 5?

That publication is from a group of people who want to have nothing to do with 
Raku.

It is best ignored here.

Re: Problem using precompiled Physics::Measure objects

2024-07-31 Thread Elizabeth Mattijsen
> On 31 Jul 2024, at 14:14, Kevin Pye  wrote:
> We'll keep looking at other ways of defining the objects, but thanks anyway. 
> (And sorry for increasing the RakuAST work needed.)

No worries: what would help is a golf of the problem.  And make that an issue 
in the rakudo repo.



Liz

Re: Problem using precompiled Physics::Measure objects

2024-07-31 Thread Elizabeth Mattijsen
> On 31 Jul 2024, at 06:10, Kevin Pye  wrote:
> 
> I am trying to build a replacement for the existing Physics::Constants 
> module, but running into problems when loading the pre-compiled version. I 
> want to use code like:
> 
> unit module Physics::Constants;
> 
> use Physics::Unit;
> use Physics::Measure;
> 
> constant \avogadro-constant is export(:DEFAULT, :fundamental, 
> :avogadro-constant) = Measure.new(
>   value => 6.02214076e+23, 
>   error => 0, 
>   units => 'mol⁻¹',
> );
> 
> which compiles and runs quite well. However, when I try to run "mi6 test" 
> which will precompile and then load the code, I get the following output:
> 
> $ mi6 test
> ===SORRY!=== Error while compiling 
> /home/kevin/git/Physics-Constants/t/01-basic.rakutest
> ===SORRY!=== Error while compiling 
> /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
> (Physics::Constants)
> An exception X::Comp::AdHoc occurred while evaluating a constant:
> Cannot unbox a P6opaque (NQPMu) type object
> at /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
> (Physics::Constants):6
> Exception details:
>   ===SORRY!=== Error while compiling 
>   Cannot unbox a P6opaque (NQPMu) type object
>   at line 
> 
> at .../Physics-Constants/t/01-basic.rakutest:2
> t/01-basic.rakutest .. Dubious, test returned 1
> No subtests run
> 
> I am guessing that it can't deserialize the serialized Physics::Measure 
> object, but I could be quite wrong.

This appears to be an issue with resolving somewhere deep in the bowels.  In 
RakuAST, the error is slightly more clear:

===SORRY!===
Cannot look up attributes in a RakuAST::Resolver type object. Did you forget a 
'.new'?

I'm pretty sure we won't fix this in the legacy grammar.  I'll be looking at 
fixing this in RakuAST.  Meanwhile, I would also suggest making this an issue 
in the Physics::Measure repo https://github.com/librasteve/raku-Physics-Measure 
so that the author is alerted to this problem, and maybe can figure out what 
tickles it.


> Any ideas on how to make this work?

Put this in lib/Physics/Constants.rakumod:
=
use Physics::Unit;
use Physics::Measure;

my $avogadro-constant := Measure.new(
  value => 6.02214076e+23,
  error => 0,
  units => 'mol⁻¹',
);

sub EXPORT {
Map.new: (:$avogadro-constant)  # must have () to force positional Pair
}
=

And then run:

$ raku -Ilib -MConstants -e 'say avogadro-constant'
6.02214076e+23mol⁻¹ ±0

In other words: drop the module statement.  The namespace *from* which you 
export constants, is usually not important.  And use an EXPORT sub 
(https://docs.raku.org/syntax/sub%20EXPORT) to export whatever values that were 
created when the mainline of the module runs.

Disadvantages to this approach:
- you lose the standard capability to selective importing
- the constants are created at module load time, and not serialized


HTH,

Liz

Re: Array remove duplicates question

2024-05-06 Thread Elizabeth Mattijsen
$ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
[1 2 3 6 7 8]

https://docs.raku.org/type/Any#method_unique

> On 6 May 2024, at 04:35, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I have thought of how to do it and pretty sure
> it would work, but just in case Raku have one
> of those sweet utilities, does Raku have a
> utility that will take an array and remove all
> the duplicates and rearrange the cells back
> in order?
> 
> Many thanks,
> -T
> 
> 



Re: MAIN(*magic)

2024-03-15 Thread Elizabeth Mattijsen
> On 15 Mar 2024, at 03:57, Mark Devine  wrote:
> 
> Rakoons,
>  I keep running into a space with Raku where it would be nice to have some 
> magic to reduce boilerplate.  I often make roles & classes with interface 
> options that flow from a consuming script’s MAIN arguments, then the first 
> bit of code at the top the MAIN block, then into instantiation.  If a person 
> makes nice utility libraries with lots of options for the user & employs them 
> a lot, the time consumed typing out the boilerplate adds up & bloats the 
> code.  Is there any way to shorten this pattern?  I was thinking about a 
> ‘switchable’ trait for attributes (with the naivety of a schoolboy).
>  my class Output {
> has $.csv  is switchable;
> has $.html is switchable;
>   .
>   .
>   .
> has $.xml is switchable;
> }
>  my class Timer {
> has $.countis switchable;
> has $.expire   is switchable;
> has $.interval is switchable;
> }
>  sub MAIN (
> Output.switchables, #= switchables from Class 'Output'
> Timer.switchables,  #= switchables from Class 'Timer'
> ) {
> my Timer $t.= new: :$expire, :$interval, :$count;   # variables 
> magically appear in scope
> my Output $o   .= new: :$csv, :$html, … , :$xml;# variables 
> magically appear in scope
> }
>  I estimate 10-50 lines of boilerplate could be removed from most of my Raku 
> scripts with something like that.  Unfortunately, I don’t possess any dark 
> magic for such things or I’d put forward an attempt.

An interesting idea!

Unfortunately I don't see this happening in the legacy grammar.  And it may 
still be pretty hard to do in RakuAST.

If you'd want to have a solution now, I'd look at *generating* the boilerplate 
code where appropriate.  This approach is used in the core in several 
locations, most notably recently in the localization modules.


Liz



Re: pint: Elizabeth, sort list???

2024-03-03 Thread Elizabeth Mattijsen
> On 3 Mar 2024, at 03:32, ToddAndMargo via perl6-users  
> wrote:
> 
>> On 3/2/24 05:13, Elizabeth Mattijsen wrote:
>>> .sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)
> 
>> Hi Elizabeth,
>> It works perfectly.  Thank you!
>> I have no idea why, I will ask you in another post
> Would you take apart your sort piece by piece and explain
> each part?

Actually, the expression can be refined a bit:

say .sort(*.split(/\d+/, :v).map({ (try .Int) // $_}).List)

Sort works by using `cmp` semantics by default.

If `cmp` is called on two lists, it will `cmp` each element and return the 
result of the first comparison that did not produce `Same`.

If you call `sort` with a Callable that takes only one argument, it is taken as 
the producer of the actual values that will be compared, basically doing a 
Schwartzian transform under the hood.

A whatever code (which is what we specified here) produces a Callable with a 
single argument.  So we'll be doing a Schwartzian transform under the hood.

The `split` splits the value (each element in the list) on any set of Numeric 
characters (`\d+`), *but* also produces the strings that were split on (`:v`). 
(The previous version had .kv, but that just produces more identical entries in 
the list, which only will make comparisons slower).

The resulting values from the `split` are then mapped to an integer value (if 
possible: `(try .Int)` and if that fails, just returns the value (`// $_`).  
(The previous version had `.Numeric`, which will also work, but since `\d+` can 
only produce integers, it's an extra unnecessary step).

Then convert the `.Seq` that is produced by the `.map` to a `List`.  Otherwise 
we'd be comparing `Seq` objects, and the semantics of those are undefined.

So for `"afoo12" cmp "afoo2"`, we will be doing `("afoo", 12) cmp ("afoo", 2)`. 
 Which would do: `"afoo" cmp "afoo"`, which produces `Same`, and then do `12 
cmp 2`, which will return `More`, and thus will cause swapping the order of 
.


Hope that made sense!

Re: I need sorting help

2024-03-02 Thread Elizabeth Mattijsen
$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)
afoo2
afoo12


> On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};
> 
> gives me
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> I need it to say
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> What did I goof up, this time?
> 
> Many thanks,
> -T



Re: pm6 naming convention

2024-02-12 Thread Elizabeth Mattijsen
It's been marked as DEPRECATED since 2023.12 I believe.

> On 12 Feb 2024, at 20:34, ToddAndMargo via perl6-users  
> wrote:
> 
> 
>>> On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> I use AnyDesk for remoter customer support.  Work rather well.
>>> 
>>> The file transfer portion, which I adore, posts a Microsoft
>>> Office Publisher Icon (a big one) when it hits a .pm6 modules.
>>> 
>>> Is there a different naming convention I can use for my
>>> modules that does not mimic some other program?
>>> 
>>> Many thanks,
>>> -T
> 
> On 2/12/24 11:11, Elizabeth Mattijsen wrote:
> > .rakumod
> 
> 
> Thank you!
> 
> Is there a way to get raku to ignore pm (perl 5)
> module naming?
> 



Re: pm6 naming convention

2024-02-12 Thread Elizabeth Mattijsen
.rakumod

> On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I use AnyDesk for remoter customer support.  Work rather well.
> 
> The file transfer portion, which I adore, posts a Microsoft
> Office Publisher Icon (a big one) when it hits a .pm6 modules.
> 
> Is there a different naming convention I can use for my
> modules that does not mimic some other program?
> 
> Many thanks,
> -T
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: disable coercing?

2024-02-10 Thread Elizabeth Mattijsen
> On 10 Feb 2024, at 08:56, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there a switch to tell Raku to bomb out with a
> type mismatch rather than coercing the following?
> 
> > my uint16 $x = -1
> 65535

No, this is intentional behaviour on native integers.

Note that you can increment such a value without problems:

[0] > my uint16 $x = -1;
65535
[1] > ++$x
0

Re: -c question

2024-02-06 Thread Elizabeth Mattijsen
Do you have some "use lib 'foo'" setting in your program?

If so, use that on the command-line, e.g.:

$ raku -Ifoo -c bar.rakumod

> On 6 Feb 2024, at 17:52, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> Is there a way to syntax a module?  Sort of like the "-c"
>>> option on main programs?
>>> 
>>> Many thanks,
>>> -T
> 
> On 2/6/24 01:34, Elizabeth Mattijsen wrote:
> > $ raku -c foo.rakumod
> > Syntax OK
> >
> 
> $ raku -c WinMessageBox.pm6
> ===SORRY!=== Error while compiling /home/CDs/Windows/NtUtil/WinMessageBox.pm6
> Could not find NativeConvert in:
>/home/tony/.raku
>/opt/rakudo-pkg/share/perl6/site
>/opt/rakudo-pkg/share/perl6/vendor
>/opt/rakudo-pkg/share/perl6/core
>CompUnit::Repository::AbsolutePath<4639587332824>
>CompUnit::Repository::NQP<4639586267208>
>CompUnit::Repository::Perl5<4639586267248>
> at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50
> 
> $ which NativeConvert.pm6
> ./NativeConvert.pm6
> and three other pm.6's WinMessageBox imports.
> 
> I can only compile check my modules if I
> import them to a program and -c the program.
> 
> For example, the following program uses
> the above module:
>$ raku -c CobianWrapper.pl6
>Syntax OK
> 
> I just want to do a syntax check on my modules
> at time without the program.
> 
> :'(



Re: -c question

2024-02-06 Thread Elizabeth Mattijsen
$ raku -c foo.rakumod
Syntax OK

> On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there a way to syntax a module?  Sort of like the "-c"
> option on main programs?
> 
> Many thanks,
> -T
> 
> 
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: optimizer?

2024-01-07 Thread Elizabeth Mattijsen
$ raku --help

...
--optimize=level use the given level of optimization (0..3)
...

> On 7 Jan 2024, at 07:09, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there a switch on the command line to disable the code optimizer?
> 
> Many thanks,
> -T



Re: initializing Pointer

2023-12-20 Thread Elizabeth Mattijsen
Looking at the Pointer class code, it looks like you can either create it 
without arguments, or with an integer argument.  The fact that you can 
parameterize the Pointer class, only indicates the type of data the pointer is 
pointing at.

> On 20 Dec 2023, at 20:12, Marcel Timmerman  wrote:
> 
> Hi,
> 
> I would like to initialize a Pointer with some value but get an error. For 
> example;
> 
> my $a = Pointer[Str].new('text');
> 
> The error thrown:
> 
> Default constructor for 'NativeCall::Types::Pointer[Str]' only takes named 
> arguments
> 
> The way I can do it now is by creating a CArray and then do a nativecast 
> which is a bit cumbersome.
> The reason I would like to use Pointers is when there is only one object to 
> point to, not an array. Secondly, for the use of the deref() function to get 
> the value it points to.
> 
> Is there another way to solve this or is it a bug in the NativeCall::Types 
> module. I have noticed that there  are 3 new() methods defined accepting 
> positional arguments.
> 
> Regards,
> Marcel
> 
> 



Re: .contains question

2023-12-11 Thread Elizabeth Mattijsen
my $x="abc45def";
my @y=; say so $x.contains(any @y);

"so" will collapse the junction into a Bool.
"say" will append a \n for you, so you don't have to.

> On 11 Dec 2023, at 01:52, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" )  { print 
>>> "True\n"; } else { print "False\n" };
>>> True
>>> 
>>> Is there a way to tell .contains that you want to know
>>> if any of a sequence characters is in a string other that
>>> repeating || over and over.  Any [a..z] or [0..9] option?
>>> 
>>> Many thanks,
>>> -T
> 
> On 12/10/23 15:24, Elizabeth Mattijsen wrote:
> > my @letters = ;
> > if $x.contains(any @letters) {
> 
> 
> Hi Elizabeth,
> 
> Very interesting.  Problem: I was looking for one answer, not many
> 
> > my $x="abc45def";my @y=; print 
> > $x.contains(any @y) ~ "\n";
> True
> True
> True
> True
> True
> True
> False
> False
> False
> False
> False
> False
> False
> True
> True
> 
> 
> Many thanks,
> -T
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
> 



Re: .contains question

2023-12-10 Thread Elizabeth Mattijsen
my @letters = ;
if $x.contains(any @letters) {
...


> On 10 Dec 2023, at 21:36, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> my Str $x="abc3defg"; if $x.contains( "a" || "b" || "3" )  { print "True\n"; 
> } else { print "False\n" };
> True
> 
> Is there a way to tell .contains that you want to know
> if any of a sequence characters is in a string other that
> repeating || over and over.  Any [a..z] or [0..9] option?
> 
> Many thanks,
> -T



Re: A suitable task for Raku?

2023-11-28 Thread Elizabeth Mattijsen
> On 28 Nov 2023, at 20:33, Parrot Raiser <1parr...@gmail.com> wrote:
> 
> In  https://youtu.be/L2jnRk2GYwg?si=ffds1MWsyZaB09HR Cassie talks about 
> creating a language for prompting AI bots. Isn't creating specialised DSs a 
> Raku strong point?

Anton Antonov is on that!

https://rakuforprediction.wordpress.com/

https://raku.land/zef:antononcube

Re: Upcoming documentation meetings

2023-02-02 Thread Elizabeth Mattijsen
> On 2 Feb 2023, at 21:11, Ralph Mellor  wrote:
> My internet is flakey when humidity is around 80%+ and the weather
> forecast suggests it may be but with luck I'll be "there" 5pm UK time
> (noon EST, 9am US west coast time) Saturday Feb 11.

If you switch off your camera, you will reduce the needed bandwidth 
significantly.  But I guess I don't need to tell you that  :-)


Liz

Re: Upcoming documentation meetings

2023-02-02 Thread Elizabeth Mattijsen
> On 2 Feb 2023, at 07:10, Bruce Gray  wrote:
> Also, like Zoom and many other video conferencing services, Jitsi allows you 
> to call a phone number, to listen and speak (audio-only) on in the video 
> meeting room:

But if you have internet, you can also participate with audio-only in Jitsi.  
So I still don't understand the "must call a phone number" thing.


Liz



Re: Upcoming documentation meetings

2023-02-01 Thread Elizabeth Mattijsen
> On 2 Feb 2023, at 00:53, Ralph Mellor  wrote:
> I looked at Jitsi when vrurg suggested it for their Core class.
> It required an international phone call.

???  I've never had to make *any* phone call to be able to use Jitsi.  And the 
RSC uses it every 2 weeks or so.

Liz

Re: `lines.contains( / \h / )` returning True for input strings not containing horizonal whitespace

2023-01-28 Thread Elizabeth Mattijsen
lines.contains...  is really short for:  lines.Str.contains...

Do you then understand what's going on?

> On 28 Jan 2023, at 21:41, William Michels via perl6-users 
>  wrote:
> 
> Some more examples:
> 
> ~$ raku -e 'put "1\n2\n3";' | raku -e 'lines.contains(/ \h /).put;'
> True
> ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ \h /).put;'
> False
> ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ 12 /).put;'
> False
> ~$ raku -e 'put "1\02\03";' | raku -e 'lines.contains(/ "1 2" /).put;'
> False
> ~$
> 
> So what I don't understand is how`.contains` coerces  `\0` null-separated 
> strings to a `Str` without whitespace, but coerces  `\n` newline-separated 
> strings to a `Str` with whitespace. Furthermore, it seems that `\0` 
> null-separated strings are correctly processed so that concatenation 
> artifacts such as "12" string or "1 2" string are not produced. 
> 
> And if  `.contains` can coerce `\0` null-separated strings to a Str without 
> whitespace, can't it do the same for `\n` newline separated strings? What am 
> I missing?
> 
> Best Regards, Bill.
> 
> PS. Typo:  of course, that title should read 'horizontal', not 'horizonal'.
> 
> On Thu, Jan 26, 2023 at 3:40 PM William Michels  wrote:
> Thanks Sean.
> 
> Made some progress. I like this result better:
> 
> ~$ raku -e 'put "1\n2\n3";' | raku -e 'lines.map(*.contains(/ \h /)).put;'
> False False False
> 
> Thx, Bill.
> 
> On Thu, Jan 26, 2023 at 12:12 PM Sean McAfee  wrote:
> On Thu, Jan 26, 2023 at 12:05 PM William Michels via perl6-users 
>  wrote:
> ~$ raku -e 'put "1\n2\n3";' | raku -e 'put lines.contains(/ \h /) ?? True !! 
> False;'
> True
> 
> lines() returns a Seq.  The contains method for a Seq coerces its argument to 
> a Str and calls contains on that Str.  And:
> 
> $ raku -e 'put "1\n2\n3"' | raku -e 'put lines.Str'
> 1 2 3
> 
> There's your horizontal whitespace.
> 



Re: $/ not always set after a regex match?

2022-12-30 Thread Elizabeth Mattijsen
if $s ~~ /$=[\w+]/ -> $/ { say $ }

> On 30 Dec 2022, at 03:54, Vadim Belman  wrote:
> 
> Optimizations, yes... But then, how could we not use code like `if $s ~~ 
> /$=[\w+]/ { say $ }`?
> 
> Speaking of the subject itself, I don't remember how sequences are actually 
> implemented in details, but most likely the regex is processed inside the 
> sequence iterator which owns the $/ used by the regex eventually. 
> 
> Best regards,
> Vadim Belman
> 
>> On Dec 28, 2022, at 12:49 PM, Elizabeth Mattijsen  wrote:
>> 
>> That's because it at one time was decided that smart-match would set $/ in 
>> the caller's scope.  Which is a pain for implementation and optimizations.  
>> I would be very much in favour of getting rid of that "feature", fwiw.
>> 
>>> On 28 Dec 2022, at 18:45, Sean McAfee  wrote:
>>> 
>>> But if a sequence has its own $/, why does * ~~ /9/ set $/?
>>> 
>>> Actually it's not just sequences, as a little more experimentation showed:
>>> 
>>> [0] > first /9/, ^Inf
>>> 9
>>> [1] > $/
>>> Nil
>>> [2] > grep /9/, ^10
>>> (9)
>>> [3] > $/
>>> Nil
>>> 
>>> The * ~~ "trick" sets $/ in these cases too.
>>> 
>>> 
>>> On Wed, Dec 28, 2022 at 12:01 PM Elizabeth Mattijsen  
>>> wrote:
>>> This isn't specific to the REPL:
>>> 
>>> $ raku -e 'say 1 ... /9/; say $/'
>>> (1 2 3 4 5 6 7 8 9)
>>> Nil
>>> 
>>> I can only assume that the sequence has its own scope for $/, and thus 
>>> isn't visible outside of it.
>>> 
>>> 
>>> Liz
>>> 
>>>> On 28 Dec 2022, at 16:47, Sean McAfee  wrote:
>>>> 
>>>> In a fresh 2022.12 Raku REPL, when the endpoint of a sequence is a Regex, 
>>>> the $/ variable seems not to be set:
>>>> 
>>>> [0] > 1 ... /9/
>>>> (1 2 3 4 5 6 7 8 9)
>>>> [1] > $/
>>>> Nil
>>>> 
>>>> If I match more explicitly using a WhateverCode, it works:
>>>> 
>>>> [2] > 1 ... * ~~ /9/
>>>> (1 2 3 4 5 6 7 8 9)
>>>> [3] > $/
>>>> 「9」
>>>> 
>>>> Is this the intended behavior, or a bug?
>>>> 
>>> 
>> 
> 



Re: $/ not always set after a regex match?

2022-12-28 Thread Elizabeth Mattijsen
Yes, for that code it would have to.

But that code pattern is really from Perl, and predates `with`.

$ raku -e 'say .Str with 9 ~~ /9/'
9

And I think that is what we should be teaching people to use, rather than 
depend on the magic lexical $/.

Liz

> On 28 Dec 2022, at 21:37, William Michels  wrote:
> 
> Doesn't it have to? At least for the following case? 
> 
> [0] > #REPL
> Nil
> [0] > say $/.Str if 9 ~~ /9/;
> 9
> 
> Best regards. --B
> 
> On Wed, Dec 28, 2022, 09:49 Elizabeth Mattijsen  wrote:
> That's because it at one time was decided that smart-match would set $/ in 
> the caller's scope.  Which is a pain for implementation and optimizations.  I 
> would be very much in favour of getting rid of that "feature", fwiw.
> 
>> On 28 Dec 2022, at 18:45, Sean McAfee  wrote:
>> 
>> But if a sequence has its own $/, why does * ~~ /9/ set $/?
>> 
>> Actually it's not just sequences, as a little more experimentation showed:
>> 
>> [0] > first /9/, ^Inf
>> 9
>> [1] > $/
>> Nil
>> [2] > grep /9/, ^10
>> (9)
>> [3] > $/
>> Nil
>> 
>> The * ~~ "trick" sets $/ in these cases too.
>> 
>> 
>> On Wed, Dec 28, 2022 at 12:01 PM Elizabeth Mattijsen  wrote:
>> This isn't specific to the REPL:
>> 
>> $ raku -e 'say 1 ... /9/; say $/'
>> (1 2 3 4 5 6 7 8 9)
>> Nil
>> 
>> I can only assume that the sequence has its own scope for $/, and thus isn't 
>> visible outside of it.
>> 
>> 
>> Liz
>> 
>>> On 28 Dec 2022, at 16:47, Sean McAfee  wrote:
>>> 
>>> In a fresh 2022.12 Raku REPL, when the endpoint of a sequence is a Regex, 
>>> the $/ variable seems not to be set:
>>> 
>>> [0] > 1 ... /9/
>>> (1 2 3 4 5 6 7 8 9)
>>> [1] > $/
>>> Nil
>>> 
>>> If I match more explicitly using a WhateverCode, it works:
>>> 
>>> [2] > 1 ... * ~~ /9/
>>> (1 2 3 4 5 6 7 8 9)
>>> [3] > $/
>>> 「9」
>>> 
>>> Is this the intended behavior, or a bug?
>>> 
>> 
> 



Re: $/ not always set after a regex match?

2022-12-28 Thread Elizabeth Mattijsen
That's because it at one time was decided that smart-match would set $/ in the 
caller's scope.  Which is a pain for implementation and optimizations.  I would 
be very much in favour of getting rid of that "feature", fwiw.

> On 28 Dec 2022, at 18:45, Sean McAfee  wrote:
> 
> But if a sequence has its own $/, why does * ~~ /9/ set $/?
> 
> Actually it's not just sequences, as a little more experimentation showed:
> 
> [0] > first /9/, ^Inf
> 9
> [1] > $/
> Nil
> [2] > grep /9/, ^10
> (9)
> [3] > $/
> Nil
> 
> The * ~~ "trick" sets $/ in these cases too.
> 
> 
> On Wed, Dec 28, 2022 at 12:01 PM Elizabeth Mattijsen  wrote:
> This isn't specific to the REPL:
> 
> $ raku -e 'say 1 ... /9/; say $/'
> (1 2 3 4 5 6 7 8 9)
> Nil
> 
> I can only assume that the sequence has its own scope for $/, and thus isn't 
> visible outside of it.
> 
> 
> Liz
> 
> > On 28 Dec 2022, at 16:47, Sean McAfee  wrote:
> > 
> > In a fresh 2022.12 Raku REPL, when the endpoint of a sequence is a Regex, 
> > the $/ variable seems not to be set:
> > 
> > [0] > 1 ... /9/
> > (1 2 3 4 5 6 7 8 9)
> > [1] > $/
> > Nil
> > 
> > If I match more explicitly using a WhateverCode, it works:
> > 
> > [2] > 1 ... * ~~ /9/
> > (1 2 3 4 5 6 7 8 9)
> > [3] > $/
> > 「9」
> > 
> > Is this the intended behavior, or a bug?
> > 
> 



Re: $/ not always set after a regex match?

2022-12-28 Thread Elizabeth Mattijsen
This isn't specific to the REPL:

$ raku -e 'say 1 ... /9/; say $/'
(1 2 3 4 5 6 7 8 9)
Nil

I can only assume that the sequence has its own scope for $/, and thus isn't 
visible outside of it.


Liz

> On 28 Dec 2022, at 16:47, Sean McAfee  wrote:
> 
> In a fresh 2022.12 Raku REPL, when the endpoint of a sequence is a Regex, the 
> $/ variable seems not to be set:
> 
> [0] > 1 ... /9/
> (1 2 3 4 5 6 7 8 9)
> [1] > $/
> Nil
> 
> If I match more explicitly using a WhateverCode, it works:
> 
> [2] > 1 ... * ~~ /9/
> (1 2 3 4 5 6 7 8 9)
> [3] > $/
> 「9」
> 
> Is this the intended behavior, or a bug?
> 



Re: What is this "\t"?

2022-11-29 Thread Elizabeth Mattijsen
Perhaps it would make sense to export these to a separate Gnome::Constants 
module?

> On 29 Nov 2022, at 15:05, Marcel Timmerman  wrote:
> 
> On 29-11-2022 10:13, Francis Grizzly Smit wrote:
> 
> Hi Francis,
>> 
>> Personally I never use \name are I hate how it looks, and so far I have 
>> never needed it, so unless I can find something it can do that I cannot do 
>> any other way, I'll keep on not using it
>> 
> To show an example where I could use it I have defined a series of types in 
> the Gnome packages of mine and could then use it everywhere as a type. The 
> glib has several types defined which I wanted to use in my code so that I can 
> cut and paste the code from the C source into Raku source without much 
> changes.
> 
> There is a file defined in Gnome::N where a list of types is defined
> …
> constant \gbooleanis export = int32;
> constant \gchar   is export = int8;
> constant \gdouble is export = num64;
> constant \gfloat  is export = num32;
> constant \gintis export = int32;
> …
> 
> 
> And later in other modules I could then use these definitions, here for 
> example 'gint'.
> 
> …
> sub gtk_widget_add_events (
>   N-GObject $widget, gint $events
> ) is native(>k-lib)
>   { * }
> …
> 
> The types file is generated to cope with int sizes differing on several 
> implementations. E.g. a long int could be 32 or 64 bits depending on the 
> implementation or OS or chip or ….
> 



Re: regex: how to I pick out items in the middle?

2022-10-30 Thread Elizabeth Mattijsen


> Which brings me back to the other of my criticisms
> of the documentation.  The examples are high level
> users showing off their skills making for a totally
> useless example for beginners.  They should show a
> simple example and then work up to the show off stuff.

On that note, OOC, what do you think about the level of the "Don't fear the 
grepper!" blog series:

https://dev.to/lizmat/dont-fear-the-grepper-1-1k3e
https://dev.to/lizmat/dont-fear-the-grepper-2-4ki5
https://dev.to/lizmat/dont-fear-the-grepper-3-hfp
https://dev.to/lizmat/dont-fear-the-grepper-4-nki

?



Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread Elizabeth Mattijsen
/ 'literal string in target' /

> On 29 Oct 2022, at 23:28, ToddAndMargo via perl6-users  
> wrote:
> 
> 
>>> On 29 Oct 2022, at 22:02, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> I am trying to change
>>> 
>>> /
>>> 
>>> into
>>> 
>>> \\\
>>> 
>>> This works:
>>> 
>>> 
>>> $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ 
>>> "\n"'
>>> a\\\b\\\c\\\d
>>> 
>>> 
>>> But this does not:
>>> 
>>> $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|Q[\\\]|;print $x ~ 
>>> "\n"'
>>> aQ[\]bQ[\]cQ[\]d
>>> 
>>> 
>>> How do I put a literal string in the
>>> target of a regex?
>>> 
>>> Many thanks,
>>> -T
> 
> On 10/29/22 13:07, Elizabeth Mattijsen wrote:
> > $ echo "a/b/c/d" | raku -ne 'say .subst("/", Q/\\\/, :g)'
> >
> 
> Hi Elizabeth,
> 
> Thank you for the subst workaround!
> 
> Do you also know how to do a literal string in
> the target of the regex?
> 
> -T
> 



Re: how do I do a literal string in the target of a regex?

2022-10-29 Thread Elizabeth Mattijsen
$ echo "a/b/c/d" | raku -ne 'say .subst("/", Q/\\\/, :g)'

> On 29 Oct 2022, at 22:02, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I am trying to change
> 
> /
> 
> into
> 
> \\\
> 
> This works:
> 
> 
> $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|\\|;print $x ~ 
> "\n"'
> a\\\b\\\c\\\d
> 
> 
> But this does not:
> 
> $ echo "a/b/c/d" | raku -ne 'my $x=$_; $x~~s:g|$(Q[/])|Q[\\\]|;print $x ~ 
> "\n"'
> aQ[\]bQ[\]cQ[\]d
> 
> 
> How do I put a literal string in the
> target of a regex?
> 
> Many thanks,
> -T



Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen



> On 14 Oct 2022, at 22:23, Joseph Polanik  wrote:
> 
> On 10/14/22 4:15 PM, Elizabeth Mattijsen wrote:
> 
>> The script Run/run_SequenceHelper.raku contains only the following lines
>>> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib';
>>> use SequenceHelper :ALL;
>> OOC, what happens if you remove the :ALL here?
> 
> No change that I can see:
> 
> raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku

I hope you changed "dir-with-module" by the actual directory name.

> Undeclared routine:
> factorial used at line 23

Do you happen to have a subroutine called "EXPORT" in the module?


Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen



> On 14 Oct 2022, at 22:05, Joseph Polanik  wrote:
> 
> On 10/14/22 3:38 PM, Elizabeth Mattijsen wrote: 
>>> On 14 Oct 2022, at 21:15, Joseph Polanik  wrote: 
>>> Actually, I did create a factorial() sub, but that didn't get me out of my 
>>> present predicament. It works as expected when invoked from the command 
>>> line. However, when invoked from a test script (or the REPL) the error 
>>> message is "Undeclared routine". 
>> Could you please run that case with: 
>> 
>> $ raku --ll-exception -Idir-with-module test-script 
>> 
>> and post the output? 
> $ raku --ll-exception -Idir-with-module Run/run_SequenceHelper.raku 
> Undeclared routine: 
> factorial used at line 23 
> 
>at SETTING::src/core.c/Exception.pm6:64 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/runtime/CORE.c.setting.moarvm:throw)
>  
>  from gen/moar/Grammar.nqp:4517 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:cry_sorrows)
>  
>  from gen/moar/Grammar.nqp:838 
> (/home/jpolanik/rakudo-2022.07-01/bin/../share/perl6/lib/Perl6/Grammar.moarvm:comp_unit)

So, this is really the static optimizer complaining about the fact that 
"factorial" did not actually got exported.


> The script Run/run_SequenceHelper.raku contains only the following lines 
> 
> use lib '~/Documents/myRaku/gitHub/SequenceHelper/lib'; 
> use SequenceHelper :ALL;

OOC, what happens if you remove the :ALL here?


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
> On 14 Oct 2022, at 21:15, Joseph Polanik  wrote:
> Actually, I did create a factorial() sub, but that didn't get me out of my 
> present predicament. It works as expected when invoked from the command line. 
> However, when invoked from a test script (or the REPL) the error message is 
> "Undeclared routine".

Could you please run that case with:

$ raku --ll-exception -Idir-with-module test-script

and post the output?


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
> On 14 Oct 2022, at 20:35, Joseph Polanik  wrote:
> Each of these results is correct. So, the problem remains that some subs are 
> not found when invoked either from a test script or from the REPL.
> 
> Is there some cache that I must clear when changing a .rakumod file to 
> prevent my system from hanging on to old material?

No, that's the whole point of `use lib "foo"`: it will checksum all files in 
"foo" *and* its subdirectoroies, and will recompile if *any* file changed.


Liz

Re: Problem defining factorial operator in .rakumod file

2022-10-14 Thread Elizabeth Mattijsen
I cannot reproduce:

% cat lib/A.rakumod 
sub postfix: ($n) is export {
when $n == 0 {return 1}
default {$n * ($n - 1)!}
}
% raku -e 'use lib "lib"; use A; say 42!'
14050061177528798985431426062445115699363840
% raku -v
Welcome to Rakudo™ v2022.07-64-gce1af0fa0.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.07-16-g3ae8a31c1.

> On 14 Oct 2022, at 05:30, Joseph Polanik  wrote:
> 
> 
> On 10/13/22 9:19 PM, Ralph Mellor wrote:
>> On Fri, Oct 14, 2022 at 12:37 AM Joseph Polanik  wrote:
>>> I am trying to define '!' as the factorial operator. The following works
>>> in a .raku script file:
>>> 
>>>sub postfix: ($n) is export {
>>>  when $n == 0 {return 1}
>>>  default {$n * ($n - 1)!}
>>>}
>>> 
>>> However when I tried to move this sub to a .rakumod file,
>>> it produces an error: Negation metaoperator not followed
>>> by valid infix.
>> That's because Raku isn't picking up your `sub`.
>> 
>> I don't know why. It works for me. (v2022.02)
>> 
>> Are you sure you're `use`ing it correctly and the `sub`
>> has the `is export`?
> 
> Yes, the sub that defines the factorial operator is marked with 'is export' 
> and the script that invokes my module (SequenceHelper) has a 'use' statement.
> 
> The script is able to invoke other methods marked 'is export'; for example, 
> the simple ver() and a method that generates an integer sequence:
> 
>   sub genSeq_IndexOps($limit, $f) is export {
> my @a = ();
> for (0...^$limit) -> $n {
>   @a.push($f($n));
> }
> return @a;
>   }
> 
> So the module is being found and used. It seems as if certain methods aren't 
> being found.
> 
> I am not convinced that the problem I'm having is unrelated to the issue 
> raised concerning the REPL. When I use the REPL, the results are the same.
> 
> [0] > use SequenceHelper;
> Nil
> [1] > say ver();
> v0.0.1
> [1] > say 4!;
> ===SORRY!=== Error while compiling:
> Negation metaoperator not followed by valid infix
> [1] > put genSeq_IndexOps(15, -> $x {3**$x + 5**$x + 6**$x});
> 3 14 70 368 2002 11144 63010 360248 2076802 12050504 70290850 411802328 
> 2421454402 14282991464 84472462690
> 
> Regards,
> 
> Joe
> 



Re: JPEG meta-data timestamps

2022-10-08 Thread Elizabeth Mattijsen
Are there any in Perl?  If so, maybe you can use them with Inline::Perl5 ?

> On 8 Oct 2022, at 22:20, rir  wrote:
> 
> Are there any Raku modules for extracting meta-data from
> JPEG files?  I have looked but not found.
> 
> At this point, I just want to extract dates to re-timestamp
> the files.  Later, I might use the fix in the pictures to
> map to personally defined places.
> 
> Rob
> 
> 
> 
> 
> 
> 



Re: Using Inline::Python

2022-09-09 Thread Elizabeth Mattijsen
Sorry to hear that.  I'm afraid then you'd need to invest more time to go along 
this avenue.  I know that Inline::Python hasn't nearly gotten the TLC that 
Inline::Perl5 has had by Stefan Seifert.  And that Inline::Python basically 
needs an additional maintainer.

> On 9 Sep 2022, at 21:08, Sean McAfee  wrote:
> 
> Good enough reason to try!  I got the 2022.07 release from brew.  Then zef 
> install -v Inline::Python --exclude=python3 (the same incantation I used 
> before) failed with:
> 
> ===> Searching for: Inline::Python
> ===> Found: Inline::Python:ver<0.5>:auth [via 
> Zef::Repository::LocalCache]
> ===> Building: Inline::Python:ver<0.5>:auth
> [Inline::Python] Command: /usr/local/Cellar/rakudo-star/2022.07/bin/rakudo 
> -MMONKEY-SEE-NO-EVAL -e exit((require 
> ::(q|Distribution::Builder::MakeFromJSON|)).new(:meta(EVAL($*IN.slurp(:close.build(q|/Users/seanmcafee/.zef/store/Inline-Python-0.5.tar.gz/Inline-Python-0.5|)??0!!1)
> ===> Building [FAIL]: Inline::Python:ver<0.5>:auth
> Aborting due to build failure: Inline::Python:ver<0.5>:auth (use 
> --force-build to override)
> 
> Not much there to tell me what's wrong.  I gamely added --force-build and 
> tried again.  This time the unit tests for Inline::Python failed (eg. 
> "SystemError: frame does not exist" (looks like a Python error), "This 
> container does not reference a native unsigned integer").  It looks like this 
> somewhat old but unaddressed open issue: 
> https://github.com/niner/Inline-Python/issues/44.  There was a suggestion to 
> add --force-test to override.  I tried that and returned to the previous 
> status quo: empty array, "instance has no attribute 'sql'".
> 
> 
> On Fri, Sep 9, 2022 at 11:48 AM Elizabeth Mattijsen  wrote:
> Well, if you would like people to look into possible core issues, then it 
> would help using the latest released version (aka 2022.07).  Especially since 
> 2021.04 is from before the new-disp work being merged, so it is not 
> completely unlikely it functions better now.
> 
> > On 9 Sep 2022, at 20:44, Sean McAfee  wrote:
> > 
> > I still see the same behavior.  That is, if I do say spark.sql('select 
> > 1+1'); twice, the first time prints an empty array, and the second produces 
> > the "instance has no attribute 'sql'" error message.
> > 
> > I forgot to mention, this is on a somewhat old version of Raku, 2021.04.  
> > But then, Inline::Python seems to be mostly even older.
> > 
> > 
> > On Fri, Sep 9, 2022 at 11:35 AM Elizabeth Mattijsen  wrote:
> > To rule out any REPL artefacts, do you see the same thing if you put the 
> > code in a script and run the script?
> > 
> > > On 9 Sep 2022, at 20:17, Sean McAfee  wrote:
> > > 
> > > Hello--
> > > 
> > > I recently started playing around with PySpark.  It soon occurred to me 
> > > that it would be a lot more fun to work in Raku instead of Python, and I 
> > > recalled that it's supposed to be possible to get handles to Python 
> > > objects from Raku and call methods on them seamlessly, so I tried to make 
> > > it happen.  I got pretty far, but now I'm stymied.  Here are the steps I 
> > > can take in the Raku interpreter:
> > > 
> > > > use Inline::Python
> > > Nil
> > > > my \python = Inline::Python.new
> > > Inline::Python.new
> > > 
> > > Self-explanatory.
> > > 
> > > > python.run('from pyspark.sql import SparkSession')
> > > (Any)
> > > 
> > > No errors, that looks promising...
> > > 
> > > > my \spark = python.run('SparkSession.builder.getOrCreate()', :eval)
> > > ... spam from initialization of Spark session deleted...
> > > Inline::Python::PythonObject.new(ptr => 
> > > NativeCall::Types::Pointer.new(4461193984), python => Inline::Python.new)
> > > 
> > > Now we're getting somewhere!  (I had to source-dive to guess that I 
> > > needed that :eval; without it, an Any is returned.)
> > > 
> > > > my \sql = spark.sql('select 1+1')
> > > []
> > > 
> > > Uh...what?  I was expecting to get another Python object back, a 
> > > DataFrame.  (I think; I'm much more familiar with the Scala interface to 
> > > Spark.)  Instead I have an empty array.
> > > 
> > > Even more puzzlingly, if I re-run that last statement, I get an error: 
> > > "instance has no attribute 'sql'".  If I re-run the statement over and 
> > > over, the response alternates between an empty array and that error.
> > > 
> > > Does anyone have any insight into what's going on?
> > > 
> > 
> 



Re: Using Inline::Python

2022-09-09 Thread Elizabeth Mattijsen
Well, if you would like people to look into possible core issues, then it would 
help using the latest released version (aka 2022.07).  Especially since 2021.04 
is from before the new-disp work being merged, so it is not completely unlikely 
it functions better now.

> On 9 Sep 2022, at 20:44, Sean McAfee  wrote:
> 
> I still see the same behavior.  That is, if I do say spark.sql('select 1+1'); 
> twice, the first time prints an empty array, and the second produces the 
> "instance has no attribute 'sql'" error message.
> 
> I forgot to mention, this is on a somewhat old version of Raku, 2021.04.  But 
> then, Inline::Python seems to be mostly even older.
> 
> 
> On Fri, Sep 9, 2022 at 11:35 AM Elizabeth Mattijsen  wrote:
> To rule out any REPL artefacts, do you see the same thing if you put the code 
> in a script and run the script?
> 
> > On 9 Sep 2022, at 20:17, Sean McAfee  wrote:
> > 
> > Hello--
> > 
> > I recently started playing around with PySpark.  It soon occurred to me 
> > that it would be a lot more fun to work in Raku instead of Python, and I 
> > recalled that it's supposed to be possible to get handles to Python objects 
> > from Raku and call methods on them seamlessly, so I tried to make it 
> > happen.  I got pretty far, but now I'm stymied.  Here are the steps I can 
> > take in the Raku interpreter:
> > 
> > > use Inline::Python
> > Nil
> > > my \python = Inline::Python.new
> > Inline::Python.new
> > 
> > Self-explanatory.
> > 
> > > python.run('from pyspark.sql import SparkSession')
> > (Any)
> > 
> > No errors, that looks promising...
> > 
> > > my \spark = python.run('SparkSession.builder.getOrCreate()', :eval)
> > ... spam from initialization of Spark session deleted...
> > Inline::Python::PythonObject.new(ptr => 
> > NativeCall::Types::Pointer.new(4461193984), python => Inline::Python.new)
> > 
> > Now we're getting somewhere!  (I had to source-dive to guess that I needed 
> > that :eval; without it, an Any is returned.)
> > 
> > > my \sql = spark.sql('select 1+1')
> > []
> > 
> > Uh...what?  I was expecting to get another Python object back, a DataFrame. 
> >  (I think; I'm much more familiar with the Scala interface to Spark.)  
> > Instead I have an empty array.
> > 
> > Even more puzzlingly, if I re-run that last statement, I get an error: 
> > "instance has no attribute 'sql'".  If I re-run the statement over and 
> > over, the response alternates between an empty array and that error.
> > 
> > Does anyone have any insight into what's going on?
> > 
> 



Re: Using Inline::Python

2022-09-09 Thread Elizabeth Mattijsen
To rule out any REPL artefacts, do you see the same thing if you put the code 
in a script and run the script?

> On 9 Sep 2022, at 20:17, Sean McAfee  wrote:
> 
> Hello--
> 
> I recently started playing around with PySpark.  It soon occurred to me that 
> it would be a lot more fun to work in Raku instead of Python, and I recalled 
> that it's supposed to be possible to get handles to Python objects from Raku 
> and call methods on them seamlessly, so I tried to make it happen.  I got 
> pretty far, but now I'm stymied.  Here are the steps I can take in the Raku 
> interpreter:
> 
> > use Inline::Python
> Nil
> > my \python = Inline::Python.new
> Inline::Python.new
> 
> Self-explanatory.
> 
> > python.run('from pyspark.sql import SparkSession')
> (Any)
> 
> No errors, that looks promising...
> 
> > my \spark = python.run('SparkSession.builder.getOrCreate()', :eval)
> ... spam from initialization of Spark session deleted...
> Inline::Python::PythonObject.new(ptr => 
> NativeCall::Types::Pointer.new(4461193984), python => Inline::Python.new)
> 
> Now we're getting somewhere!  (I had to source-dive to guess that I needed 
> that :eval; without it, an Any is returned.)
> 
> > my \sql = spark.sql('select 1+1')
> []
> 
> Uh...what?  I was expecting to get another Python object back, a DataFrame.  
> (I think; I'm much more familiar with the Scala interface to Spark.)  Instead 
> I have an empty array.
> 
> Even more puzzlingly, if I re-run that last statement, I get an error: 
> "instance has no attribute 'sql'".  If I re-run the statement over and over, 
> the response alternates between an empty array and that error.
> 
> Does anyone have any insight into what's going on?
> 



Re: BEGIN {} question

2022-09-02 Thread Elizabeth Mattijsen
> On 2 Sep 2022, at 22:52, ToddAndMargo via perl6-users  
> wrote:
> 
> On 9/2/22 00:13, ToddAndMargo via perl6-users wrote:
>> Found something interesting
>> $ raku -c GetUpdates.pl6
>> Syntax OK
>> Will execute the BEGIN {}, not just
>> syntax check it.
> 
> The guys on the chat line said this is normal
> as `BEGIN` runs a compile time

How short *is* your memory?

> From: Elizabeth Mattijsen 
> Subject: Re: BEGIN {} question
> Date: 29 August 2022 at 09:44:30 CEST
> To: ToddAndMargo via perl6-users 
> 
>> Question, would BEGIN go at the top or the bottom
>> of my code?  Seems the compiler would hit it first
>> at the top, but I do not know if it makes a full
>> pass of everything before firing off the BEGIN.
> 
> BEGIN runs at *compile* time.
> 
> This means that anything before the BEGIN statement in the code, is compiled 
> and known and can be referenced in the BEGIN block.
> 
> Anything *after* the BEGIN statement is still unknown to the compiler and can 
> therefore *not* be referenced.
> 
> 
> Liz



Re: Ping Larry Wall: excessive compile times

2022-08-29 Thread Elizabeth Mattijsen
> Since you wrote both Perl 5 and Perl 6, is there some
> reason beyond my limited understanding of how these
> things work as to why your Perl 5 is so much faster to
> compile that your Perl 6?

You clearly understand the situation!

What can I say?


Ah, I know.  *PLONK*


Liz


Re: BEGIN {} question

2022-08-29 Thread Elizabeth Mattijsen
> Question, would BEGIN go at the top or the bottom
> of my code?  Seems the compiler would hit it first
> at the top, but I do not know if it makes a full
> pass of everything before firing off the BEGIN.

BEGIN runs at *compile* time.

This means that anything before the BEGIN statement in the code, is compiled 
and known and can be referenced in the BEGIN block.

Anything *after* the BEGIN statement is still unknown to the compiler and can 
therefore *not* be referenced.


Liz

Re: I can't 'zef uninstall' old versions of modules anymore

2022-08-09 Thread Elizabeth Mattijsen



> On 9 Aug 2022, at 15:10, Fernando Santagata  wrote:
> 
> On Tue, Aug 9, 2022 at 2:13 PM Elizabeth Mattijsen  wrote:
> > On 9 Aug 2022, at 13:53, Fernando Santagata  
> > wrote:
> > 
> > Hello,
> > 
> > I'm trying to uninstall old versions of some modules; it looks like it's 
> > working but in reality it isn't. For example, but it's not limited to just 
> > this module:
> > 
> > $ zef list --installed|grep CBOR
> > ===> Found via /opt/rakudo-pkg/share/perl6/core
> > ===> Found via /home/nando/.raku
> > CBOR::Simple:ver<0.1.1>:auth:api<0>
> > CBOR::Simple:ver<0.1.2>:auth
> > 
> > $ zef uninstall 'CBOR::Simple:ver<0.1.1>:auth:api<0>'
> > ===> Uninstalled from /home/nando/.raku
> > CBOR::Simple:ver<0.1.1>:auth:api<0>
> 
> What does
> 
> raku -e 'use CBOR::Simple:ver<0.1.1>:auth:api<0>'
> 
> say after you've done this?   Does it still load, or does it give an error?
> 
> $ raku -e 'use CBOR::Simple:ver<0.1.1>:auth:api<0>'
> ===SORRY!=== Error while compiling -e
> Could not open 
> /home/nando/.raku/sources/983E0FAFB758220B170D33A30493A316F0805F75. Failed to 
> stat file: no such file or directory
> 
> at -e:1
> 
> You're right, the listing is incorrect. Besides, trying to uninstall the 
> module doesn't return any error.

Actually, no.  If the module would have been truly uninstalled, the error would 
have been something like:

% r 'use CBOR::Simple:ver<0.1.1>'
===SORRY!=== Error while compiling -e
Could not find CBOR::Simple:ver<0.1.1> in:
/Users/liz/.raku
/Users/liz/Github/rakudo/install/share/perl6/site
/Users/liz/Github/rakudo/install/share/perl6/vendor
/Users/liz/Github/rakudo/install/share/perl6/core
CompUnit::Repository::AbsolutePath<2276199768160>
CompUnit::Repository::NQP<2276123351056>
CompUnit::Repository::Perl5<2276123351096>

So it looks like the source is gone, but the "short" info might still be there.


> > It started when I was using Rakudo v2022.06, but I hoped that upgrading to 
> > the next version would solve the problem. Alas, no luck.
> 
> Did you create an issue for it?  If not, how would anybody be able to know of 
> your problem?
> 
> I thought it was a local problem and I wanted to investigate it further, but 
> so far had no chance to do it, so I tried and see if it was a known issue.
> I've just submitted an issue.

Thanks!


Liz

Re: I can't 'zef uninstall' old versions of modules anymore

2022-08-09 Thread Elizabeth Mattijsen
> On 9 Aug 2022, at 13:53, Fernando Santagata  wrote:
> 
> Hello,
> 
> I'm trying to uninstall old versions of some modules; it looks like it's 
> working but in reality it isn't. For example, but it's not limited to just 
> this module:
> 
> $ zef list --installed|grep CBOR
> ===> Found via /opt/rakudo-pkg/share/perl6/core
> ===> Found via /home/nando/.raku
> CBOR::Simple:ver<0.1.1>:auth:api<0>
> CBOR::Simple:ver<0.1.2>:auth
> 
> $ zef uninstall 'CBOR::Simple:ver<0.1.1>:auth:api<0>'
> ===> Uninstalled from /home/nando/.raku
> CBOR::Simple:ver<0.1.1>:auth:api<0>

What does

raku -e 'use CBOR::Simple:ver<0.1.1>:auth:api<0>'

say after you've done this?   Does it still load, or does it give an error?


> $ zef list --installed|grep CBOR
> ===> Found via /opt/rakudo-pkg/share/perl6/core
> ===> Found via /home/nando/.raku
> CBOR::Simple:ver<0.1.1>:auth:api<0>
> CBOR::Simple:ver<0.1.2>:auth

If the above gave an error, then the listing is incorrect.


> $ raku --version
> Welcome to Rakudo™ v2022.07.
> Implementing the Raku® Programming Language v6.d.
> Built on MoarVM version 2022.07.
> $ zef --version
> v0.13.8
> 
> It started when I was using Rakudo v2022.06, but I hoped that upgrading to 
> the next version would solve the problem. Alas, no luck.

Did you create an issue for it?  If not, how would anybody be able to know of 
your problem?


> All I can say is that when I install a new Rakudo version I always run 
> cleanup-precomp . I don't know whether this might alter the local zef DB so 
> that I can't uninstall modules anymore.

cleanup-precomp only removes precompiled bytecode files.  It doesn't touch 
anything else.  In the worst case, some modules would need to be precompiled 
again, causing some delay.


> Has anyone had the same problem?

FWIW, I cannot reproduce the problem locally  :-(


Liz



Re: CompUnit::Repository::Perl5 ???

2022-08-09 Thread Elizabeth Mattijsen
Good chance it will if:

a. that works in plain Perl
b. you have Inline::Perl5 installed
c. you do "use Net::FTP:from"
d. you change -> to .

> On 9 Aug 2022, at 11:46, ToddAndMargo via perl6-users  
> wrote:
> 
> On 8/9/22 00:56, Elizabeth Mattijsen wrote:
>>> On 9 Aug 2022, at 09:24, ToddAndMargo via perl6-users 
>>>  wrote:
>>>>> On 9 Aug 2022, at 06:19, ToddAndMargo via perl6-users 
>>>>>  wrote:
>>>>> 
>>>>> $ raku -Msigpipe -e 'loop { say "y"}' | sed 3q
>>>>> ===SORRY!=== Error while compiling -e
>>>>> Could not find sigpipe in:
>>>>>/home/tony/.raku
>>>>>/opt/rakudo-pkg/share/perl6/site
>>>>>/opt/rakudo-pkg/share/perl6/vendor
>>>>>/opt/rakudo-pkg/share/perl6/core
>>>>>CompUnit::Repository::AbsolutePath<71837872>
>>>>>CompUnit::Repository::NQP<63797000>
>>>>>CompUnit::Repository::Perl5<63797040>
>>>>> at -e:1
>>>>> 
>>>>> 
>>>>> Why are we looking in perl 5?
>>> 
>>> 
>>> On 8/8/22 23:52, Elizabeth Mattijsen wrote:
>>>> So that you can transparently say "use DBI:from"
>>>> 
>>> 
>>> Makes sense.
>>> 
>>> Would you mind throwing up a simple
>>> example off a call to a perl 5 module?
>> $ perl -MTest::More -e 'ok 42, "foo"; done_testing'
>> ok 1 - foo
>> 1..1
>> $ raku -e 'use Test::More:from; ok 42, "foo"; done_testing'
>> ok 1 - foo
>> 1..1
> 
> 
> This this support something written in Perl 5's OOP?
> 
> use Net::FTP;
> 
> # Open a new FTP connnector
> 
> $ftp = Net::FTP->new("$FtpServer", Passive=>1 )
> 
>  or die "Cannot connect to $FtpServer: $@";
> 
> 
> 
> # Log on to the FTP site  
> 
> $ftp->login("$Username", "$Password")
> 
>  or die "Cannot login ", $ftp->message;
> 
> 
> 
> # if $BkRoot does not exist, create it
> 
> if ( not Exists ( "/", $BkRoot ) ) { $ftp->mkdir ( $BkRoot ); }
> 
> 
> 
> ...
> 
> 
> $ftp->quit;
> 
> 
> 
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: CompUnit::Repository::Perl5 ???

2022-08-09 Thread Elizabeth Mattijsen
> On 9 Aug 2022, at 09:24, ToddAndMargo via perl6-users  
> wrote:
>>> On 9 Aug 2022, at 06:19, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> $ raku -Msigpipe -e 'loop { say "y"}' | sed 3q
>>> ===SORRY!=== Error while compiling -e
>>> Could not find sigpipe in:
>>>/home/tony/.raku
>>>/opt/rakudo-pkg/share/perl6/site
>>>/opt/rakudo-pkg/share/perl6/vendor
>>>/opt/rakudo-pkg/share/perl6/core
>>>CompUnit::Repository::AbsolutePath<71837872>
>>>CompUnit::Repository::NQP<63797000>
>>>CompUnit::Repository::Perl5<63797040>
>>> at -e:1
>>> 
>>> 
>>> Why are we looking in perl 5?
> 
> 
> On 8/8/22 23:52, Elizabeth Mattijsen wrote:
> > So that you can transparently say "use DBI:from"
> >
> 
> Makes sense.
> 
> Would you mind throwing up a simple
> example off a call to a perl 5 module?

$ perl -MTest::More -e 'ok 42, "foo"; done_testing'
ok 1 - foo
1..1

$ raku -e 'use Test::More:from; ok 42, "foo"; done_testing'
ok 1 - foo
1..1

Re: CompUnit::Repository::Perl5 ???

2022-08-08 Thread Elizabeth Mattijsen
So that you can transparently say "use DBI:from"

> On 9 Aug 2022, at 06:19, ToddAndMargo via perl6-users  
> wrote:
> 
> $ raku -Msigpipe -e 'loop { say "y"}' | sed 3q
> ===SORRY!=== Error while compiling -e
> Could not find sigpipe in:
>/home/tony/.raku
>/opt/rakudo-pkg/share/perl6/site
>/opt/rakudo-pkg/share/perl6/vendor
>/opt/rakudo-pkg/share/perl6/core
>CompUnit::Repository::AbsolutePath<71837872>
>CompUnit::Repository::NQP<63797000>
>CompUnit::Repository::Perl5<63797040>
> at -e:1
> 
> 
> Why are we looking in perl 5?
> 
> 



Re: something between run and qx() ?

2022-08-04 Thread Elizabeth Mattijsen
> On 4 Aug 2022, at 14:38, Marc Chantreux  wrote:
> It would be nice to define a backtrick operator (like in rc) so we
> could write
> 
>   my @installed-files =
>   grep *.IO.f,
>   map *.trim,
>   `< dpkg-query -f ${db-fsys:Files} -W gnuplot* >;
> 
> insead of
> 
>   my @installed-files =
>   grep *.IO.f,
>   map *.trim,
>   ( run :out, < dpkg-query -f ${db-fsys:Files} -W gnuplot* > ).out.lines;

sub prefix:<`>(*@a) { (run @a, :out).out.lines }

dd ` ;
("Changes", "LICENSE", "META6.json", "README.md", "bin", "dist.ini", "lib", 
"releases", "resources", "run-tests", "t").Seq


Liz

Re: something between run and qx() ?

2022-08-04 Thread Elizabeth Mattijsen
> On 4 Aug 2022, at 10:35, Marc Chantreux  wrote:
> 
> hello people,
> 
> I found myself choosing between
> 
> raku -e '
>   (run :out, <
>   dpkg-query -f ${db-fsys:Files} -W gnuplot*
>   > ).out>>.lines>>.trim>>.grep(*.IO.f)>>.say'
> 
> and
> 
> raku -e '
>   qx<
>   dpkg-query -f \${db-fsys:Files} -W gnuplot\*
>   >.lines.trim>>.grep(*.IO.f)>>.say'
> 
> I really love the qx syntax but
> 
> * it runs an extra useless sh processus
> * I need to quote the shell symbols
> 
> I read the Proc documentation and tried to see if there was another
> command or an adverb to the qx construction (something like :r for run).
> 
> What I really would like to write is:
> 
> raku -e ' qx:r< dpkg-query -f ${db-fsys:Files} -W gnuplot* 
> >.lines>>.grep(*.IO.f)>>.say '

I believe you could use App::Rak for that:


$ zef install App::Rak
$ dpkg-query -f ${db-fsys:Files} -W gnuplot* | rak '*.trim.IO.f' 
--/show-line-number


Liz

Re: Rakudoc - make the naming consistent

2022-07-19 Thread Elizabeth Mattijsen
> On 19 Jul 2022, at 20:49, ToddAndMargo via perl6-users  
> wrote:
> As an aside, Raku still reads my Perl 5 ".pm"
> modules before reading my Raku ".pm6" modules.
> Raku default to ".pm" before ".pm6".  The
> compiler wags its finger at me a lot!
> 
> So I have to segregate my ".pm6" modules
> into a special directory , which I
> call "p6mod".  ("p5lib" for Perl 5.)
> 
> I wonder if there is a way to get Raku
> to stop reading ".pm" altogether?

Making it stop reading altogether, will probably take some time still to avoid 
breaking current production environments.


However, I have just verified:  If you have:

- lib
   |- A.rakumod
   |- A.pm6
   |- A.pm

and you do a:

$ raku -Ilib -MA -e ''

it *will* load the A.rakumod file.  And if you remove that, it will load the 
A.pm6 file.  Only if there's only a A.pm file in the "lib" directory, will it 
load that.

You should realize that *if* a repository *can* satisfy a request for a module, 
then it will.

Could it be that you have a "Foo.pm" in an "earlier" directory and a "Foo.pm6" 
in a later directory in the $*REPO chain?



Liz

Re: Using fez

2022-07-12 Thread Elizabeth Mattijsen
That is correct.

> On 12 Jul 2022, at 03:52, Darren Duncan  wrote:
> 
> On 2022-07-10 10:56 a.m., Elizabeth Mattijsen wrote:
>> Fez (aka https://360.zef.pm) will provide *all* versions.
> 
> The above url just displays a big data structure when visiting it in a web 
> browser, and not a normal website, is that correct? -- Darren Duncan



Re: Using fez

2022-07-10 Thread Elizabeth Mattijsen
Ah, indeed I did.  Using App::Mi6 is so ingrained in me (and before that 
"cpan-upload"), that it is hard for me to imagine any other situation  :-)


Liz

> On 10 Jul 2022, at 21:41, Vadim Belman  wrote:
> 
> Hi,
> 
> Liz has probably missed the point of your question. Yes, you must do fez 
> upload for each new release. It means each time you'd need to do some 
> pre-release preparations to create an archive, etc... The fastest way is to 
> switch to App::Mi6 for building distributions. My approach is a makefile plus 
> helper scripts I include as a submodule for nearly each project I develop 
> because mi6 doesn't cover my needs.
> 
> Best regards,
> Vadim Belman
> 
>> On Jul 10, 2022, at 11:38 AM, Richard Hainsworth  
>> wrote:
>> 
>> I have begun uploading modules to fez.
>> 
>> Suppose a module is in active development. And I have v0.7.1, then v0.7.2 
>> etc. Do I need to upload each version, or will fez automatically provide the 
>> most updated module?
>> 
>> When p6c was the main ecosystem, the reference was to github. So, the latest 
>> version on github was used, and zef would use whatever was on github.
>> 
>> 
> 



Re: Using fez

2022-07-10 Thread Elizabeth Mattijsen
> On 10 Jul 2022, at 17:38, Richard Hainsworth  wrote:
> I have begun uploading modules to fez.

Good to hear!

If that is a module that was on the p6c ecosystem before, please let me know, 
so that we can remove it from the p6c ecosystem.


> Suppose a module is in active development. And I have v0.7.1, then v0.7.2 
> etc. Do I need to upload each version, or will fez automatically provide the 
> most updated module?

Fez (aka https://360.zef.pm) will provide *all* versions.  When you install a 
module with zef without version specification, it will install the highest 
numbered one.  Should you wish to install v0.7.1 for some reason, you can have 
zef install that by specifying the version (zef install 'Foo:ver<0.7.1>')


> When p6c was the main ecosystem, the reference was to github. So, the latest 
> version on github was used, and zef would use whatever was on github.

Yes, and that was fine originally, but it isn't anymore.  The biggest issue is 
that someone can change the contents of a module *without* updating the version 
information, thus creating different distributions in the wild that share the 
same version.

When you upload to fez (or CPAN for that matter), you can only upload each 
version once.


Hope this helps!


Liz

Re: Easier way to load a buffer?

2022-06-10 Thread Elizabeth Mattijsen



> On 10 Jun 2022, at 23:28, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-us...@perl.org>> wrote:
>>>Hi All,
>>>I am looking for an easier way to load a buffer.
>>>I know about this way
>>>[4] > my Buf $b=Buf.new(0x2A, 0x54, 0xFF, 0x53);
>>>Buf:0x<2A 54 FF 53>
>>>I would like to do it on one big blast:
>>>my Buf $b=Buf.new(0x2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78);
>>>Cannot unbox 170 bit wide bigint into native integer
>>>But do not know the proper syntax.
>>>Any words of wisdom?  Am I stuck with the hard way?
>>>Many thanks,
>>>-T
> 
> On 6/10/22 08:36, Simon Proctor wrote:
>> So Buf is expecting a list of integers. If' you've got one long one in a 
>> string like "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78" you want to split 
>> it into smaller values so something like this?
>> my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
>> my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
>> Which does the trick I think.
> 
> 
> [0] > my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
> 2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78
> [1] > my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
> ===SORRY!=== Error while compiling:
> Calling comb(Int) will never work with signature of the proto ($, $, $?, *%)
> --> my Buf $b=Buf.new(⏏comb(2).map( *.parse-base(16) ));
> [1] >

You could think: what does "comb(2)" do?  Perhaps look at the documentation?  
And then maybe realize that Simon forgot that the comb(2) should be a method on 
$hex?  Otherwise, how would it know what to parse?

I know it is hard to think when you're in a hurry.  But you should really learn 
to be able to read code, instead of copying examples only and not understanding 
*how* they work.

Re: Easier way to load a buffer?

2022-06-10 Thread Elizabeth Mattijsen



> On 10 Jun 2022, at 22:47, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On Fri, 10 Jun 2022 at 15:49, ToddAndMargo via perl6-users 
>>> mailto:perl6-us...@perl.org>> wrote:
>>>Hi All,
>>>I am looking for an easier way to load a buffer.
>>>I know about this way
>>>[4] > my Buf $b=Buf.new(0x2A, 0x54, 0xFF, 0x53);
>>>Buf:0x<2A 54 FF 53>
>>>I would like to do it on one big blast:
>>>my Buf $b=Buf.new(0x2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78);
>>>Cannot unbox 170 bit wide bigint into native integer
>>>But do not know the proper syntax.
>>>Any words of wisdom?  Am I stuck with the hard way?
>>>Many thanks,
>>>-T
> 
> On 6/10/22 08:36, Simon Proctor wrote:
>> So Buf is expecting a list of integers. If' you've got one long one in a 
>> string like "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78" you want to split 
>> it into smaller values so something like this?
>> my $hex = "2A54FF53A5F1D36F1CEA7E61FC37A20D54A77FE7B78";
>> my Buf $b=Buf.new(comb(2).map( *.parse-base(16) ));
>> Which does the trick I think.
> 
> What does the * i *.parse-base do?

*.parse-base(16) is an example of a WhateverCode object.

It is basically syntactic sugar for easy creation of Callable blocks.  In this 
case,
it created  -> $_ { .parse-base(16) }

The * is interpreted in the Raku Grammar as a sign to create a WhateverCode 
object: it basically
represents the $_ in the signature of the created Block, and of course the $_ 
inside that block.:

Re: Dual Buf and Str question

2022-06-10 Thread Elizabeth Mattijsen
> On 10 Jun 2022, at 11:20, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> I can easily  get away with this in Modula2, but
>>> how can I do this with Raku?
>>> 
>>> I wish to create a single variable that can be
>>> manipulated in two ways:
>>> 
>>> 1) as a fixed length string (Str)
>>> 
>>> 2) as a fixed length buffer (Buf)
>>> 
>>> I can think of ways to do this, but it would
>>> require separate variable and conversions routines
>>> back and forth.
>>> 
>>> Any words of Raku wisdom?
>>> 
>>> Many thanks,
>>> -T
> 
> On 6/10/22 01:23, Elizabeth Mattijsen wrote:
>> Perhaps https://raku.land/zef:raku-community-modules/Pythonic::Str is what 
>> you're after?
> 
> No really.
> 
> Maybe if I was to tell you what I am trying to do.
> 
> I am trying to do a bitwise XOR on each byte
> against another Buf.  Then I want it to act
> like a string again.
> 
> I want the variable to act as both an array
> of characters and a binary array of bytes.

Convert a string to a Buf:  say "abc".encode.Buf;  # Buf:0x<61 62 63>
Convert a Buf to a Str: say Buf.new(97,98,99).decode;  # abc

Technically, I think the .encode is enough for what you want:

say "abc".encode.does(Blob);  # True

Re: Dual Buf and Str question

2022-06-10 Thread Elizabeth Mattijsen
Perhaps https://raku.land/zef:raku-community-modules/Pythonic::Str is what 
you're after?

> On 10 Jun 2022, at 07:54, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I can easily  get away with this in Modula2, but
> how can I do this with Raku?
> 
> I wish to create a single variable that can be
> manipulated in two ways:
> 
> 1) as a fixed length string (Str)
> 
> 2) as a fixed length buffer (Buf)
> 
> I can think of ways to do this, but it would
> require separate variable and conversions routines
> back and forth.
> 
> Any words of Raku wisdom?
> 
> Many thanks,
> -T
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: Help with promises, supplies and channels.

2022-04-07 Thread Elizabeth Mattijsen
Fixed with 
https://github.com/rakudo/rakudo/commit/5658f4da07b44d492a3d35d57fa76939822d2c66

Thanks for the report!

> On 7 Apr 2022, at 11:28, David Emanuel da Costa Santiago  
> wrote:
> 
> 
> Thanks for the information!
> 
> I opened a bug in rakudo:
> 
> https://github.com/rakudo/rakudo/issues/4853
> 
> 
> Regards,
> David Santiago
> 
> 
> Às 05:27 de 07/04/22, yary escreveu:
>> For what it's worth, I'm on a mac, promise_test.raku hangs for me once in a 
>> while also.
>> Welcome to Rakudo(tm) v2021.04.
>> Implementing the Raku(tm) programming language v6.d.
>> Built on MoarVM version 2021.04.
>> Trying to reduce it, I would like to find a program that reliably tickles 
>> this bug and hangs every time... this variation does not crash for me (I ran 
>> it 100x)
>> ### close_much.raku ###
>> my Channel $ch .= new;
>> my @proms = (1..2000).map: {
>> start react {
>>whenever $ch.closed { done }
>> }
>> };
>> $ch.close;
>> await Promise.allof(@proms);
>> say $*VM;
>> ###
>> this does not crash for me
>> ### supply_to_many.raku ###
>> my Channel $ch .= new;
>> my $p1 = Supply.interval(3);
>> my @proms = (1..2000).map: {
>> start react {
>> whenever $p1 { $ch.close }
>>whenever $ch.closed { done }
>> }
>> };
>> await Promise.allof(@proms);
>> say $*VM;
>> ###
>> This gives a sensible error "Cannot send a message on a closed channel"
>> ### close_then_send.raku ###
>> my Channel $ch .= new;
>> # Close first, send next
>> $ch.close;
>> $ch.send("Hi!");
>> ###
>> This does not crash for me, for different combinations of $senders & 
>> $receivers (1000,1) (1,1000) (1000,1000)
>> ### config_send_recv.raku ###
>> my Channel $ch .= new;
>> my Supply $p1 .= interval(1);
>> my ($senders, $receivers) = (2000,2);
>> my Int $count = 0;
>> my @sends = (1..$senders).map: {
>>   start react {
>>   whenever $p1 -> $interval {
>>  $ch.send($_);
>>  $ch.close if ++$count == $senders;
>>   }
>>whenever $ch.closed { done }
>>   }
>> };
>> my @proms = (1..$receivers).map: {
>>   start react {
>>  whenever $ch.closed {
>>  done;
>>  }
>>  whenever $ch -> $data {
>>  print "$_=$data|";
>>  }
>>   }
>> };
>> await Promise.allof(@proms,@sends);
>> say $*VM;
>> ###
>> I didn't succeed - fun to try!
>> -y
>> On Tue, Apr 5, 2022 at 3:55 PM William Michels via perl6-users 
>> mailto:perl6-us...@perl.org>> wrote:
>>Thanks for the bash loop. I'm seeing a few hangs, also some errors
>>returned saying:
>>"Unhandled exception in code scheduled on thread 4"
>>(MacOS 11.11)
>>On Tue, Apr 5, 2022 at 12:47 PM David Emanuel da Costa Santiago
>>mailto:deman...@gmail.com>> wrote:
>>Hi William,
>>when it fails or hangs it doesn't print the last line.
>>Please check attached file for output of the stack.
>>Since the failures are random, it's easier to invoke it in a loop:
>>bash$ for i in $(seq 100); do raku test.raku; done
>>If nothing is wrong with the code, i'll open a bug in the github.
>>Regards,
>>David Santiago
>>Às 21:37 de 05/04/22, William Michels escreveu:
>> > No problems so far.
>> >
>> > say $*VM; #add as last line, returns:
>> > moar (2021.06)
>> >
>> > On Tue, Apr 5, 2022 at 11:06 AM David Emanuel da Costa Santiago
>> > mailto:deman...@gmail.com>
>>>> wrote:
>> >
>> > Hi,
>> >
>> >
>> >
>> > I'm trying to learn about promises, supplies and
>>channels. So i made
>> > this code:
>> >
>> > """
>> >
>> > my $p1 = Supply.interval(5);
>> > my $p2 = Supply.interval(2);
>> > my Channel $ch = Channel.new;
>> >
>> > my $prom = start react {
>> >   whenever $p1 -> $interval {
>> >   say "5";
>> >   }
>> >
>> >   whenever $p2 -> $interval {
>> >   say 2;
>> >   }
>> >
>> >   whenever $ch.closed {
>> >   done;
>> >   }
>> >
>> >   whenever $ch -> $data {
>> >   say "Data: $data";
>> >   }
>> > }
>> >
>> > my $prom2 = start react {
>> >   whenever $p1 -> $interval {
>> >   $ch.send("5.2");
>> >   $ch.close;
>> >   }
>> >   whenever $ch.closed {
>> >   done;
>> >   }
>> > }
>> >
>> > my @proms = ($prom, $prom2);
>> > await Promise.allof(@proms);
>> >
>> > """
>> >
>> >
>> >
>> > I don't see anything wrong with this but most of the
>>   

Re: coercion

2022-02-11 Thread Elizabeth Mattijsen
It is being tested in Roast, so I'd say it's not really that experimental 
anymore  :-)

> On 11 Feb 2022, at 15:20, Marcel Timmerman  wrote:
> 
> Hi,
> 
> I stumbled over a discussion between Raku developers on 
> "Raku/proplem-solving" issue 227 "Coercion reconsidered and unified" and I 
> saw something interesting about coercion. Without much knowledge I started to 
> experiment with a method called COERCE(). This ended successful and can now 
> write, for example, something like
> 
> my Gnome::Gdk3::Visual() $visual = $button.get-visual;
> 
> which feels more natural instead of
> 
> my Gnome::dtk3::Visual $visual .= new(:native-object($button.get-visual));
> 
> I can also restrict the coercion like so,
> 
> my Gnome::Gdk3::Visual(N-GObject) $visual = …;
> 
> The .get-visual() example returns a native object which must be encapsulated 
> into the Visual type to access the Visual methods. In the Gnome::* libraries 
> are many such calls returning native structures which needs to be handled 
> like above to be able to do something with it.
> 
> 
> The question now is that I can't find anything about COERCE in the 
> documentation. Although I have checked the Raku source code and have seen 
> that it is used there, I wonder if this is still experimental Raku code and 
> subject to changes.
> 
> Regards,
> Marcel



Re: show all drive letters and labels

2022-02-10 Thread Elizabeth Mattijsen
> On 10 Feb 2022, at 11:10, ToddAndMargo via perl6-users  
> wrote:
> That is an interesting module.  I am not sure what
> I would use it for though.  Maybe in the future.
> It is a method of find out what a drive is.
> 
> What I was after was finding the drive letter that
> corresponded to a logical volume label.   The drive
> letter will vary from computer to computer, so I
> did not want to hard code the drive letter.
> 
> >wmic logicaldisk get DeviceID,VolumeName
> 
> got me there.
> 
> 
> use WinMessageBox :MessageBox;
> use WinMount :ListLogicalVolumes;
> 
> sub GetDriveLetter()  {
>   # extract the drive letter in the format of "A:\" from logical volume name
> 
>   my $SubName = &?ROUTINE.name;
> 
>   for ListLogicalVolumes() -> $Volume  {
>  # print "$Volume\n";
>  if not $Volume  { next; }
> 
>  if $Volume.Str eq "Icedrive"  {
>  $IceDrive = $Volume.Str;
>  last;
>  } # if
>   }# for
>   # print "Drive letter <" ~ $IceDrive ~ ">\n";
> 
>   if not $IceDrive  {
>   MessageBox( $IAm ~ ": " ~ $SubName, "Unable to locate Icedrive label", 
> MB_ICONERROR, MB_OK );
>   }
> 
>   return $IceDrive;
> }
> 
> 
> Thank you for the help!

This seems like functionality that could well live in the ecosystem.

Have you considered giving back to the community by putting this into a module 
(as well as the WinMessageBox and WinMount modules that it refers to, which I 
assume to be your private modules) and uploading it to the ecosystem?

Even if nobody else would use it, your future self will probably find it very 
useful!


Liz

Re: show all drive letters and labels

2022-02-10 Thread Elizabeth Mattijsen
> So I was really hoping for a built in system32 call.
> I really, really don't care for the the trouble
> associated with using the "C" interface to call
> system 32 dll's, but I may have to.

One of the things that Raku tries to do, is to be ignorant about the underlying 
OS.

Having a system32 DLL call built in, would be very Windows specific, would it 
not?

A lot of Linux specific functionality lives in the ecosystem: 
https://raku.land/?q=Linux

Oddly enough a search for Win32 on raku.land yields:

  https://raku.land/github:ramiroencinas/Win32::DrivesAndTypes

Perhaps what you are looking for.  And something you should have been able to 
find with a little more work than just writing an email.


Liz

Re: show all drive letters and labels

2022-02-09 Thread Elizabeth Mattijsen
What would you use on a command-line to get that information?

Then look at https://docs.raku.org/routine/run

Liz

> On 9 Feb 2022, at 12:37, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Windows 7,10,11
> 
> Do we have a command/function that will show all drive
> letter and their labels?
> 
> Many thanks,
> -T
> 
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: probably worth a bug report ?

2022-01-02 Thread Elizabeth Mattijsen
Maybe first explain why the error:

When you specify a Pair as such as an argument, it is interpreted as a *named* 
argument.


$ raku -e 'sub a(|c) { dd c }; a b => 42'
\(:b(42))

So thus you can see why the error is thrown: you passed 0 positional arguments 
to the subroutine, and it never gets to report the fact that you passed one 
unexpected named argument.

There's several ways to fix the problem:

xxx Pair.new("key","value");  # be explicit about sending a Pair

xxx (key => "value"); # add parentheses to break the syntactic 
sugar for named arguments

The latter option also shows that whitespace *can* be significant in Raku:

xxx(key => "value");   # same error

In Raku, an identifier directly followed by a parens open, means calling that 
object of that identifier, with the arguments specified.   And then you know 
that "xxx foo" is really syntactic sugar for "xxx(foo)".


Again, it is all about *reading* the error message.  Is there room for 
improvement?  There always is!

> On 2 Jan 2022, at 08:34, Marc Chantreux  wrote:
> 
> hello rakoons,
> 
> I got this error message
> 
>   Too few positionals passed; expected 1 argument but got 0
> in sub xxx at - line 1
> in block  at - line 2
>   
>   Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.09.
>   Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
>   Built on MoarVM version 2021.09.
> 
> by running this:
> 
>   <<\-. raku; raku -v
>   sub xxx ( Pair $test ) { $test.raku.say }
>   xxx key => 'value';
> 
> and i think it's worth a bug: i don't know if
> 
>   xxx key => 'value'
> 
> should parse but at least it deserve a less
> confusing message, don't you think ?
> 
> regards
> marc



Re: Should I start learning Perl?

2022-01-01 Thread Elizabeth Mattijsen
If you're looking for Perl, you're probably on the wrong mailing list: I 
suggest you try "perl.beginners".

> On 1 Jan 2022, at 10:42, Turritopsis Dohrnii Teo En Ming 
>  wrote:
> 
> Subject: Should I start learning Perl?
> 
> Good day from Singapore,
> 
> I am thinking of learning Perl. May I know if Perl is still in vogue?
> Should I start learning Perl?
> 
> I am looking forward to your replies.
> 
> Thank you very much.
> 
> Regards,
> 
> Mr. Turritopsis Dohrnii Teo En Ming
> Targeted Individual in Singapore
> 1st Jan 2022 Saturday



Re: file format extensions

2021-12-30 Thread Elizabeth Mattijsen
+1 from me.  Shouldn't that be a .rakudoc file ?  :-)

> On 30 Dec 2021, at 12:20, Richard Hainsworth  wrote:
> 
> I'm revising how I name files that are included in my modules. With the name 
> change to Raku, the file extensions also changed for script and module files.
> 
> In addition Jonathan has defined some format extensions for Cro files, and I 
> am sure there would be other developers who would like to claim unique 
> extension names for files.
> 
> This is not a post intended to start a war about file extensions, that is 
> whether they should exist in a modern file system. For whatever reason they 
> came into being, a significant number of users, such as myself, find them 
> useful, if only as a mnemonic for their files' probable contents.
> 
> It seems to me a short page in the docs.raku.org would be useful with the 
> various file extensions, and so if a developer wanted for a custom file 
> extension to be primarily applied to some new module, the way to do would be 
> to create a PR on the documentation file.
> 
> If this post gets some positive responses, then I'll write the POD6 file for 
> inclusion in docs.raku.org and create a PR for inclusion.
> 
> [Another naming question would be the name of the markup language - as 
> distinct from the file extension - for documentation. For Perl it is POD, for 
> Perl6 it was natural to use POD6. POD stands for Plain Old Documentation, but 
> I think that POD6 is neither Plain, nor Old. How about RDM for Raku 
> documentation markup? ]
> 
> There is a wrinkle in that Raku best practice has evolved in line with the 
> evolution of perl6 into Raku. So it seems reasonable to have previous file 
> formats listed as well.
> 
> The following are what I think are the current best practices. Since I have 
> been out of circulation for a while, the list is likely not exhaustive and 
> may be wrong. I am certain there are other file types I have not included.
> 
> For each file type, extensions on the left are earlier, and the extension of 
> the far right (after the TAB) is considered best practice
> 
> Perl6 / Raku script: .pl, .pl6,  .raku
> 
> Perl6 / Raku Module: .pm, .pm6,  .rakumod
> 
> Perl6 / Raku Standalone Documentation (POD6 can be included in a script or 
> module file): .pm, .pm6, .pod, .pod6,  .rakudoc
> 
> NQP file:  .nqp
> 
> Cro template:  .crotmp
> 
> 
> 
> 
> 
> 



Re: is 'use v6' still a thing?

2021-12-28 Thread Elizabeth Mattijsen
Personally, I don't add it anywhere anymore.  Especially in files with the 
.raku, .rakumod and .rakutest extensions :-)

> On 28 Dec 2021, at 17:59, Marc Chantreux  wrote:
> 
> hello people,
> 
> long time ago, there was this 'use v6' line so perl should be v6 and
> still run v5.* things.
> 
> I just took a look to https://raku.land/github:JJ/SDL2 and seen
> 
>use v6;
> 
> Does it still makes sense?
> 
> Regards.
> 
> -- 
> Marc Chantreux
> Direction du numérique de l'Université de Strasbourg
> Pôle de Calcul et Services Avancés à la Recherche (CESAR)
> http://annuaire.unistra.fr/p/20200



Re: Merry Xmas day

2021-12-21 Thread Elizabeth Mattijsen
Planned are:

- more optimizations based on new-disp
- the RakuAST branch will land, bringing better composability and full-blown 
macros
- the next language version will be released: probably called "6.e"

Non-core developments I see:

- support for Raku Ecosystem Archive integrated into zef
- IRC logs server going live
- more services based on Cro
- more PR / visibility effort for Raku once 6.e has landed

> On 21 Dec 2021, at 12:39, JJ Merelo  wrote:
> 
> Merry Xmas for you too! I wish I knew. There's no fixed roadmap, and I, for 
> one, do not really know what's going to happen. We'll probably get closer to 
> 6.e, and there are wonderful things in the core by the crafty and wonderful 
> core developers.
> 
> Cheers
> 
> El mar, 21 dic 2021 a las 12:09, yonghua () escribió:
> Merry Xmas and happy new year every one.
> May I know what's the plan for raku development in the new year 2022?
> 
> Thanks.
> 
> 
> -- 
> JJ



Re: Date.new("2024-02-29").later( :1year)

2021-12-13 Thread Elizabeth Mattijsen
> On 13 Dec 2021, at 05:23, rir  wrote:
> 
> 
> REPL says:
>> Date.new("2024-02-29").later( :1year);
>2025-02-28
> 
> Is the following some standard?

I'm not sure...

Basically when moving by month / year, it just basically moves that field in 
the date, and then checks for validity of the resulting date, and then adapts 
(within the given month) to the first legal date.

Since you're moving by month / year, it felt as the way for the least surprise.



Liz

Re: Phasers Suggestions

2021-12-12 Thread Elizabeth Mattijsen
I suggest making this a problem-solving issue: 
https://github.com/raku/problem-solving

> On 11 Dec 2021, at 05:48, Timothy Nelson  wrote:
> 
> Hi all.  
> 
> I've been lurking on this list for years (and once won an "oldest resurrected 
> conversation" award).  I've loved Raku conceptually since the start, but have 
> only recently been putting it to much use.  Mostly, the reality is as good as 
> the promises, but there are two areas I have been liking a bit less.  One of 
> these is Phasers.  The idea is a great one, but after going to them numerous 
> times and often not finding what I want, I've come to the conclusion that 
> they need some remodelling.  
> 
> That's a big step in a language that's been around for a while like Raku has. 
>  Maybe this is a discussion for the Raku 2.0 standard (if there will be such 
> a thing), or maybe it's something that can be introduced over time (or as a 
> Slang, or something).  Anyway, after thinking about them for a while, and 
> having my thoughts coalesce into a document over the last few days, I thought 
> I'd post the document to this mailing list and see what people think.  I have 
> put in a number of hours today trying to make it more readable, but still may 
> not have gotten the ordering right.  
> 
> I'm fully aware that there may be drawbacks that I haven't thought of, but if 
> one useful idea comes from this document, then that's a step in the right 
> direction.  
> 
> Thanks all,
> 



Re: Delegation

2021-11-26 Thread Elizabeth Mattijsen
By the way: if you override an operator, you can still access the original one 
using CORE::

sub infix:<+>($,$) { 42 }
say 200 + 300;  # 42
say infix:<+>(200,300); # 42
say &CORE::infix:<+>(200,300);  # 500

> On 26 Nov 2021, at 20:30, rir  wrote:
> 
> Wow, that was a surprise.  Thanks.
> 
> But I was on this path:
> 
>class Not-really-real {
>has Real $value handles &infix:<=>;
>}
> 
> Rob
> 
> 
> On Fri, Nov 26, 2021 at 03:15:32PM +0100, Elizabeth Mattijsen wrote:
>> You mean like:
>> 
>>   say &infix:<+>(has 42,137);  # 179
>> ??  If so, by referring to its full name  :-)
>> 
>>> On 26 Nov 2021, at 15:07, rir  wrote:
>>> 
>>> Is it possible to to delegate plain or overridden operators?  If so,
>>> what does the syntax look like?
>>> 
>>> Rob
>> 



Re: Delegation

2021-11-26 Thread Elizabeth Mattijsen
You mean like:

   say &infix:<+>(has 42,137);  # 179

??  If so, by referring to its full name  :-)

> On 26 Nov 2021, at 15:07, rir  wrote:
> 
> Is it possible to to delegate plain or overridden operators?  If so,
> what does the syntax look like?
> 
> Rob



Re: junctions with given/when

2021-11-05 Thread Elizabeth Mattijsen
If this pull request is merged:

  https://github.com/rakudo/rakudo/pull/4620

you will get a deprecation notice at the end of your program of the locations 
in your code that need changing.


Liz

> On 5 Nov 2021, at 19:54, Joseph Brenner  wrote:
> 
> Yes, this feels like natural Raku code to a lot of us:
> 
>given any( $o1, $o2 ) { when  { ... } }
> 
> If there's some rule like, "don't use junctions
> on the left hand side of a smartmatch" that
> hasn't been made clear, and there's certainly no
> roast tests that check this, so consequently the
> behavior has drifted around.
> 
> The latest word from Jonathan Worthington seems
> to be that the current behavior should probably
> be reverted *for now*, but a later language
> version of Raku will change it again, albeit more
> consistently.
> 
> So if you were serious about writing Raku code
> (and not just playing around with it, as I mostly am)
> you'd need to have a list in mind of these things
> that are kinda-sorta-deprecated. Otherwise, you'd
> just have to expect breakage on upgrade in the future.
> 
> 
> On 11/4/21, yary  wrote:
>> and I realize that what I just typed doesn't help a whole lot, what if you
>> have a junction of things and you want to tell if any/one/all/none
>> smartmatch the same thing... OK..
>> 
>> -y
>> 
>> 
>> On Thu, Nov 4, 2021 at 6:38 PM yary  wrote:
>> 
>>> Something that helps me reason about this is thinking of how regular
>>> expressions match against strings, to remember that which goes on which
>>> side is important...
>>> 
 "this has a Q in it" ~~ / 'Q' /  # of course this works
>>> 
>>> 「Q」
>>> 
 / 'Q' / ~~ "this has a Q in it" # of course this breaks
>>> 
>>> Regex object coerced to string ...
>>> 
>>> 
 say do given "this has a Q in it" { when / 'Q' / {"has a Q"}; default
>>> {"no match"}}
>>> 
>>> has a Q
>>> 
 say do given / 'Q' / { when "this has a Q in it" {"has a Q"}; default
>>> {"no match"}}
>>> 
>>> Regex object coerced to string ...
>>> 
>>> I did have a place in the earlier discussion. I eventually realized that
>>> if I thought of junctions as analogous to regular expressions, then it
>>> was
>>> easier to remember which side of the smartmatch or given/when to put it.
>>> 
>>> -y
>>> 
>>> 
>>> On Thu, Nov 4, 2021 at 3:31 PM Joseph Brenner  wrote:
>>> 
> ... we'd need to go
> through detailed, calm, measured discussion if we're to minimize
> the pain it seems we'll inevitably endure pain to dig ourselves out
> of the hole we'd be in.
 
 Yes, this could be a bad one.
 
>>> 
>> 



Re: can u suggest a beginner book for perl6?

2021-09-29 Thread Elizabeth Mattijsen
Perhaps Think Raku: https://greenteapress.com/wp/think-perl-6/ ?

> On 29 Sep 2021, at 14:18, Walt CH  wrote:
> 
> I have some ruby programming experience, and some JS.
> can you suggest a book for newbie of perl6?
> 
> Thanks



Re: ^mro_unhidden

2021-08-21 Thread Elizabeth Mattijsen
> On 21 Aug 2021, at 20:03, Joseph Brenner  wrote:
> 
> Given and example like this:
> 
>  class A {}
>  class B is A {}
>  class D is B {}
> 
>  say D.^parents(); # ((B) (A))
>  say D.^parents( :all ); # ((B) (A) (Any) (Mu))
> 
> So, I conclude that Any and Mu are "hidden" as far as ^parents is concerned.
> 
> According to the documentation, ^mro_unhidden does this:
> 
>  "Returns a list of types in method resolution order, excluding
>  those that are marked with is hidden."
> 
> And yet, what I see is:
> 
>  say D.^mro_unhidden; # ((D) (B) (A) (Any) (Mu))
> 
> So why does this include Any/Mu?

Good question, I don't have an answer handy.


> A somewhat related question:  How do you check whether a trait is set
> on something?
> Can you get a list of all traits?

No.

A trait is nothing else than a piece of code that gets executed at compile time 
with the object to which it is applied as the parameter (and the value 
specified with the trait).  Whatever the code of that trait actually does, is 
up to that trait.  Most traits mix in a role into the object, but not all.

For instance, the "is hidden-from-backtrace" trait on subroutines and methods, 
mixes in a role:

multi sub trait_mod:(Routine:D $r, :$hidden-from-backtrace!) {
$r.^mixin( role is-hidden-from-backtrace {
method is-hidden-from-backtrace(--> True) { }
}) if $hidden-from-backtrace;
}

But others, like the "is rw" trait on an attribute, just calls a method on the 
Attribute object.

multi sub trait_mod:(Attribute:D $attr, :rw($)!) {
$attr.set_rw();
warn "useless use of 'is rw' on $attr.name()" unless $attr.has_accessor;
}

So there is no generic way to tell what traits have been applied to an object.



Liz

Re: Depreciated code????

2021-07-27 Thread Elizabeth Mattijsen
Point taken.

So the deprecation logic is pointing at the wrong line.

Where does this RunNoShellLib.pm6 live?  It's must be something inside that.

> On 27 Jul 2021, at 21:15, ToddAndMargo via perl6-users  
> wrote:
> 
> 
>>> On 7/26/21 5:21 PM, ToddAndMargo via perl6-users wrote:
>>>> Hi All,
>>>> $ raku -v
>>>> Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.07.
>>>> Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
>>>> Built on MoarVM version 2021.07.
>>>> After upgrading from 2021.05, I am getting this:
>>>> Saw 1 occurrence of deprecated code.
>>>> 
>>>>  Sub RunNoShellAll (from RunNoShellLib) seen at:
>>>>   /home/linuxutil/p6lib/RunNoShellLib.pm6 (RunNoShellLib), line 148
>>>> Please use exitcode and/or signal methods (status is to be removed in 
>>>> 2022.06) instead.
>>>> 
>>>>  Please contact the author to have these occurrences of deprecated code
>>>> adapted, so that this message will disappear!
>>>> 148: ( $ReturnStr, $ReturnErr, $RtnCode ) = RunNoShellAll( $RunString, 
>>>> True, False, True );
>>>> Confused,
>>>> -T
> 
> 
>>> On 27 Jul 2021, at 02:29, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> The command that is triggering this in the main program is
>>> 
>>>exit;
>>> 
>>> ???
> 
> On 7/27/21 2:24 AM, Elizabeth Mattijsen wrote:
>> Read the error message!
>> "/home/linuxutil/p6lib/RunNoShellLib.pm6 (RunNoShellLib), line 148"
>> What does that line say?
> 
> Hi Elizabeth
> 
> Please re-read my original post.  Look for the line
> that starts with "148:"
> 
> -T
> 



Re: Depreciated code????

2021-07-27 Thread Elizabeth Mattijsen
Read the error message!

"/home/linuxutil/p6lib/RunNoShellLib.pm6 (RunNoShellLib), line 148"

What does that line say?

> On 27 Jul 2021, at 02:29, ToddAndMargo via perl6-users  
> wrote:
> 
> On 7/26/21 5:21 PM, ToddAndMargo via perl6-users wrote:
>> Hi All,
>> $ raku -v
>> Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2021.07.
>> Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
>> Built on MoarVM version 2021.07.
>> After upgrading from 2021.05, I am getting this:
>> Saw 1 occurrence of deprecated code.
>> 
>>  Sub RunNoShellAll (from RunNoShellLib) seen at:
>>   /home/linuxutil/p6lib/RunNoShellLib.pm6 (RunNoShellLib), line 148
>> Please use exitcode and/or signal methods (status is to be removed in 
>> 2022.06) instead.
>> 
>>  Please contact the author to have these occurrences of deprecated code
>> adapted, so that this message will disappear!
>> 148: ( $ReturnStr, $ReturnErr, $RtnCode ) = RunNoShellAll( $RunString, True, 
>> False, True );
>> Confused,
>> -T
> 
> 
> The command that is triggering this in the main program is
> 
>exit;
> 
> ???
> 



Re: Why does .new initialize?

2021-07-19 Thread Elizabeth Mattijsen
> On 19 Jul 2021, at 05:49, Peter Scott  wrote:
> 
> I'm curious as to why Rat.new initializes instead of leaving as undefined:
> 
> > $*RAKU
> Raku (6.d)
> > my Rat $p
> (Rat)
> > put $p
> Use of uninitialized value $p of type Rat in string context.
> Methods .^name, .raku, .gist, or .say can be used to stringify it to 
> something meaningful.
>   in block  at  line 1
> > my $q = Rat.new
> 0
> > put $q
> 0

If .new wouldn't initialize a type to its basic instantiation, what would be 
the point of .new then?

FWIW, the same goes for:

dd Int.new;  # 0
dd Num.new;  # 0e0
dd Complex.new;  # <0+0i>
dd Str.new;  # ""

If you want to leave it undefined, don't call .new on it?

*confused*

Re: use lib and locations in a variable

2021-07-13 Thread Elizabeth Mattijsen
> On 13 Jul 2021, at 19:07, Joseph Brenner  wrote:
> Bruce Gray points out "constant" works also:
> 
> constant $lib_loc = $*PROGRAM.parent.add('../lib');

Yup.

constant $foo = 42;

is basically short for:

BEGIN my $foo := 42


Re: use lib and locations in a variable

2021-07-11 Thread Elizabeth Mattijsen
> On 12 Jul 2021, at 00:54, ToddAndMargo via perl6-users  
> wrote:
> I want the full stinkin' path, not a dot.

   ".".IO.full-stinkin-path;

ah, no, that should be:

   ".".IO.absolute

Re: use lib and locations in a variable

2021-07-11 Thread Elizabeth Mattijsen
> On 11 Jul 2021, at 01:11, Joseph Brenner  wrote:
> 
> I want my test files to be able to find the modules they're testing
> just using their relative locations, given the usual layout of "lib"
> and "t" locations in parallel inside the project directory.
> 
> I find that while this works:
> 
>   use lib $*PROGRAM.parent.add('../lib');
> 
> This doesn't work:
> 
>   my $lib_loc = $*PROGRAM.parent.add('../lib');
>   use lib "$lib_loc";
> 
> I get a compile time error
> 
>   Use of uninitialized value $lib_loc of type Any in string context.
>   ...
>   Repository specification can not be an empty string.  Did you mean
> 'use lib "."' ?

"use lib" is a compile time statement.

"my $lib_loc = ..." is a runtime statement, with a compile time component for 
the definition.

So what happens is that when the "use lib" is executed (at compile time), the 
$lib_loc variable *is* known, but it hasn't been initialized yet.  Which is 
basically what the error message says :-)

This can be easily fixed in Raku: the BEGIN statement can also be used as a 
prefix:

   BEGIN my $lib_loc = $*PROGRAM.parent.add('../lib');
   use lib "$lib_loc";

One note: I'm a bit surprised of the mixture of OS dependent (../) and OS 
independent (.parent) directory walking.  I guess you meant:

   $*PROGRAM.parent.parent.add("lib")

?

If so, you could shorten this with the "sibling" method to:

   $*PROGRAM.parent.sibling("lib")


> I thought that this would fix the problem, but I see the same
> compile time error with it:
> 
>   BEGIN {
> my $lib_loc = $*PROGRAM.parent.add('../lib');
> use lib "$lib_loc";
>   }

Inside the BEGIN block, it's just the same: the variable is defined, but not 
initialized yet when the "use lib" is executed at compile time *inside* the 
BEGIN block.  Yes, it's compile times all the way down  :-)


> Does that make sense to anyone?  It feels like a bug to me.

This is not a bug.

It's a misunderstanding of the phases through which a program goes when it is 
being compiled and run.  This is not different from Perl, BTW.  The only thing 
different from Perl (which is a very nice improvement, I'd say) is that you can 
use BEGIN as a prefix, so that it shares its scope with its surrounding scope.  
This allows you to define *and* initialize a variable at compile time and have 
it exist in the surrounding scope.




Liz

Re: array and class question

2021-07-04 Thread Elizabeth Mattijsen
my $x = UupDumpClass.new;

> On 4 Jul 2021, at 12:36, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> What I am doing wrong here?
> 
> > class UupDumpClass { has @.arry is rw; }
> (UupDumpClass)
> 
> > my $x = UupDumpClass;
> (UupDumpClass)
> 
> > $x.arry[0] = "zero";
> Cannot look up attributes in a UupDumpClass type object
>  in method arry at  line 1
>  in block  at  line 1
> 
> 
> Many thanks,
> -T
> 
> 
> -- 
> 
> If I had a dime every time I didn't know
> what was going on, I'd be like, "Why is
> everyone giving me all these dimes?"
> 



Re: Notes/Questions about Leon Timmermans's talk

2021-06-09 Thread Elizabeth Mattijsen
> On 9 Jun 2021, at 12:48, Marc Chantreux  wrote:
> 
> hello,
> 
> I just saw this and it's very good
> 
> https://www.youtube.com/watch?v=elalwvfmYgk
> 
> The features he picked are indeed things i really like in raku
> and i learned some interesting details. Other details are still
> bugging me so i have some questions there:
> 
> A. if x -> $y with //
> 
> For exemple, given a function Foo
> 
>   sub foo ( Int $x ) { 42 if $x > 5  }
> 
> this is awesome you can write
> 
>   if foo 7 -> $value { say $value }
> 
> and even
> 
>   if foo 7 { say $^value }
> 
> but is there a way (adverb?) to match if something is False but defined
> so given this
> 
>   sub foo ( Int $x ) { 0 if $x > 5 }
> 
> i would write something else than
> 
>   sub foo ( Int $x ) { 0 if $x > 5 }
>   sub hello {say "hello $^world"}
>   if defined my $value = foo 45 { hello $value }

   with foo 7 { say $^value }

or if you want to trigger on *not* defined:

   without foo 7 { say $^value }


> B. » vs map
> 
> Leon made this slide where i consider as equivalent
> 
>   @list».abs
>   @list.map(*.abs)
> 
> someone, some day, told me they are not and i shouldn't use » if
> i don't know what it means. I read the doc and came to the
> (incorrect?) conclusion that
> 
>   @list».abs
> 
> is actually
> 
>   @list.map(*.abs).hyper
> 
> which could have important overloads while creating an HyperSeq.
> 
> should i reconsider the whole thing and use » without fear?

You can use the » without fear if there aren't any side-effects.

Consider this:

   class Foo {
   my int $seen = 0;
   method bar() { ++$seen }  # side-effect
   }

and then doing:

   (Foo xx 1)».bar;

Because the ». *can* be spread over multiple threads, and prefix:<++> is not a 
thread-safe construct generally, you would probably *not* see the correct 
number of updates.

Another thing to remember is the order in which they are executed:

   ("a".."z")».&say;

is *not* guaranteed to say the letters of the alphabet in alphabetical order.



Hope this explains :-)



Liz

Re: Buf to Str

2021-06-09 Thread Elizabeth Mattijsen
> On 9 Jun 2021, at 06:34, Paul Procacci  wrote:
> 
> Hopefully a pretty quick question
> 
> GIven the following:
> 
> my Buf $b .= new([72, 105, 0, 32, 97, 103, 97, 105, 110, 0]);
> say $b.decode;
> 
> I would expect this to print 'Hi'.
> Instead it prints 'Hi again'.
> 
> https://docs.raku.org/type/Buf#(Blob)_method_decode 
> 
> The decode documentation for Buf only states that 'Applies an encoding to 
> turn the blob into a Str; the encoding will be UTF-8 by default.' 
>  
> 
> The zero (0) in that Buf should imply an end of string yet decode seems to 
> want to decode the number of elements instead.

That is an incorrect assumption carried over from C.  In the Raku Programming 
Language, a null byte is a valid grapheme, as it is in unicode.  A small change 
to your program:

my Buf $b .= new(72, 105, 0, 32, 97, 103, 97, 105, 110, 0);
.say for $b.decode.uninames;
#
LATIN CAPITAL LETTER H
LATIN SMALL LETTER I

SPACE
LATIN SMALL LETTER A
LATIN SMALL LETTER G
LATIN SMALL LETTER A
LATIN SMALL LETTER I
LATIN SMALL LETTER N



> Furthermore, If I 'say $b.decode.chars;' it counts the initial null as part 
> of Str.
> In my mind, that means Str doesn't really mean string.

I don't see an initial null in your example.

But yeah, the Str class in Raku is much more than a C-string.


> So the question, how does one ACTUALLY decode what's in a buffer to a string 
> where it adheres to the semantics of NULL termination for strings cleanly.

If you want to include the null byte in your final strings:

my @strings = $b.decode.comb(/ .*? "\0" /)

would be a way.



> Another question might be, should decode() follow null terminating semantics 
> instead of number of elements in a given Buf.

No.  The C-string semantics are what they are.  They are not the semantics used 
in the Raku Programming Language.



Liz

Re: Comparing Int and Num

2021-05-03 Thread Elizabeth Mattijsen
[16:37:23]  i'm not subscribed to the mailing list but maybe 
someone who is could chime in to this thread 
https://www.nntp.perl.org/group/perl.perl6.users/2021/04/msg9878.html  and 
mention that i believe the problem is in libtommath's mp_get_double and the gmp 
branch fixes it?

> On 14 Apr 2021, at 04:09, sisyphus  wrote:
> 
> Hi,
> 
> C:\>raku -e "say 1.8446744073709552e+19 == 18446744073709551615"
> True
> 
> I think I understand why raku deems this to be true.
> The LHS is 0x1p+64, which is identical to the double that the RHS rounds to.
> (AFAIK, it's the same with perl5 and C.)
> 
> Of course, for all $x in the Int range of  18446744073709551615 - 1023 to  
> 18446744073709551615, we find that "1.8446744073709552e+19 == $x" is True, 
> because each of those $x Int values round to 0x1p+64.
> I understand all of that (I think).
> 
> What I don't understand is the following:
> 
> C:\>raku -e "say 1.8446744073709552e+19 == (18446744073709551615 - 1024)"
> True
> 
> C:\>raku -e "say 1.8446744073709552e+19 == (18446744073709551615 - 1087)"
> True
> 
> For those particular Int values (and all Int values in between) the RHS 
> rounds to 0x1.fp+63,
> and the result should therefore be "False" ... but it is reported as "True".
> 
> It's not until we subtract at least 1088 that the behaviour I'm expecting 
> appears:
> 
> C:\>raku -e "say 1.8446744073709552e+19 == (18446744073709551615 - 1088)"
> False
> 
> Comparing the RHS Int values given in the last 2 one liners, I find they are 
> (respectively):
> 0.1000E64
> 0.10111011E64
> 
> It's not apparent to me how those 2 integer values can round to different 
> doubles.
> Those 2 integer values can also be written as (respectively):
> 18446744073709550528
> 18446744073709550527
> 
> On Windows, I have:
> C:\>raku --version
> This is Rakudo version 2020.05.1 built on MoarVM version 2020.05
> implementing Raku 6.d.
> 
> On Ubuntu, I have:
> $ raku --version
> Welcome to Rakudo(tm) v2021.03.
> Implementing the Raku(tm) programming language v6.d.
> Built on MoarVM version 2021.03.
> 
> It's the same behaviour on both systems.
> 
> Is this a bug that I ought to report ?
> 
> Cheers,
> Rob  
> 
> 
> 
> 
> 
> 



Re: too many file handles

2021-03-18 Thread Elizabeth Mattijsen
> On 17 Mar 2021, at 22:02, Richard Hainsworth  wrote:
> 
> After working at this, I finally found where it was happening, and a 
> work-around.
> 
> I was checking all 517 http/s links in the documentation to see whether they 
> are all live (not 404 and host found). For this I was using LibCurl::Easy.
> 
> The relevant bits of code was something like
> 
> for @links -> $link { # @links.elems = 517
> 
> my $http = LibCurl::HTTP.new;
> 
> try { $rv = $http.HEAD($link).perform.response-code }
> 
> if $! { $rv = $http.error }
> 
> }
> 
> I had assumed that as soon as the $http went out of scope, it would be 
> collected.
> 
> When I rewrote as
> 
> my $http = LibCurl::HTTP.new;
> 
> for @links -> link { ... }
> 
> then the program ran to completion without failing with 'too many file 
> handles.

Well, that appears to be a good thing to do anyway, not redoing things that 
don't need redoing unnecessarily.


> Now my question is this: Is this a problem with the LibCurl::Easy module, 
> where I can raise an issue.
> 
> Or is this a more general Raku problem with objects not being garbage 
> collected?

There is no reference counting in Raku.  Objects get garbage collected when 
they are garbage collected.  When that exactly happens, is indeterminate.

I've written a blog post about that a few years ago, now in the CCR repo: 
https://github.com/Raku/CCR/blob/main/Remaster/Elizabeth%20Mattijsen/Garbage-Collection-in-Raku.md


Liz

Re: too many file handles

2021-03-17 Thread Elizabeth Mattijsen
> On 17 Mar 2021, at 18:45, Richard Hainsworth  wrote:
> 
> I have been running into this error: "Too many open files"
> 
> Sorry for the lack of detail. The problem is that the error comes up in odd 
> places, so I have found it difficult to golf down into Raku program that 
> always fails with this error.
> 
> When I separate out the code that leads to the error, and create another 
> program, Raku handles it without difficulty. It seems to occur when there are 
> a lot of moving parts, so to speak.
> 
> I am not explicitly opening file handles, but the software I have written is 
> using the idiom
> 
> "some-filename.html".IO.spurt( $an-accumulated-string );
> 
> Obviously, filehandles are being opened under the hood. Having written a 
> file, there is no need to reference it again, so I could close the filehandle.
> 
> I have been told that because of the way garbage handling is implemented, 
> there is a problem with file handles.

That's should only happen if you specifically open a file to obtain an 
IO::Handle: if you don't close it yourself (e.g. via a LEAVE block like: LEAVE 
.close with $handle), *then* you run this risk, as the IO::Handle.DESTROY 
method *will* close the handle, but you cannot be sure as to when 
IO::Handle.DESTROY gets called.


> If so, what is a safer idiom to use in place of and IO on a string, so that 
> the handle can be closed immediately after use?

The "filelame".IO.spurt($string)" is the exact idiom to ensure that file 
handles are getting closed for you automatically.  And I've just checked the 
code: the OS file handle *is* specifically getting closed with an 
nqp::closefh($!PIO).  Specifically, the sequence is:

my $PIO := nqp::open($path,$mode);
nqp::writefh($PIO,nqp::decont(data));
nqp::closefh($PIO);

Now, you can't get more succinct than that: it doesn't even open an IO::Handle 
at all!

The only thing I can think of at this moment, is that somehow nqp::closefh() is 
leaking?  Perhaps creating an issue for this, is in order!


Liz



Re: Module Documentation

2021-03-16 Thread Elizabeth Mattijsen
> On 16 Mar 2021, at 04:22, Matthew Stuckwisch  wrote:
> 
> So here's my 2¢, which will probably be followed up with some actual 
> development of stuff (I do put my money where my mouth is… although it might 
> take me a while to save up to spend it ha).  Some of the minor details could, 
> of course, easily be adjusted, so don't fixate too much on them.
> 
> Right now, it is true that many of us use README.md for github.  Some people 
> write this one by hand (I'm guilty of it), others (lizmat, for instance) 
> generate this from their *.rakumod file.

A little clarification about that: I don't do anything special for that.  
Generating the README.md is a standard feature when using App::Mi6.  So my 
workflow is basically:

- build module
- write tests
- run "mi6 release"

Well, perhaps some intermediate checks to see if everything worked, such as 
"mi6 build", which will actually build the README.md, and "mi6 test" to run the 
tests.


Liz





Re: documentation of internals

2021-03-07 Thread Elizabeth Mattijsen
> On 7 Mar 2021, at 00:16, Joseph Brenner  wrote:
> 
> Is there anything like an equivalent of "man perlguts" for Raku/rakudo?
> 
> There are things like this, but they seem to be very out-of-date:
> 
>  https://github.com/rakudo/rakudo/blob/master/docs/architecture.html

That is indeed severely out of date, some parts by almost a decade now.

I don't think it is worthwile to update this, as things will change again when 
the RakuAST branch lands.

I think it is best if you open an issue for this, so that it will not fall 
through the cracks.

Re: Weird! When legal?

2021-02-24 Thread Elizabeth Mattijsen
$ raku -e 'class samesame { hello samesame, { say "Wosup?" } }' 
===SORRY!=== Error while compiling -e
Undeclared routine:
   hello used at line 1. Did you mean 'shell'?

Are you missing a comma there?  Did you intend to call the "hello" subroutine, 
with "samesame" and the block as parameters?

If not, what *did* you mean to accomplish?

> On 24 Feb 2021, at 17:40, rir  wrote:
> 
> Hello,
> 
>> class samesame { hello samesame { say "Wosup?" } }
> 
> ===SORRY!=== Error while compiling:
> Unexpected block in infix position (missing statement control word before the 
> expression?)
> --> class samesame { hello samesame⏏ { say "Wosup?" } }
>   expecting any of:
>   infix
>   infix stopper
>   postfix
> 
> Why is this a special case instead of a common undeclared error?  The
> second 'samesame' could be 'Instant' and do the same.
> I'm not seeing how to continue from the ⏏  to make a statement.
> 
> 
> rir
> 



Re: dimensions in a multidimensional array

2021-02-05 Thread Elizabeth Mattijsen
> On 5 Feb 2021, at 15:49, Theo van den Heuvel  wrote:
> I cannot seem to find an idiomatic way to get the dimensions of a 
> multidimensional array,
> other than by looking at the size of the first row and column, with 
> @m[0;*].elems and @m[*;0].elems.
> Am I missing something in the docs?

If it's a shaped multidimensional array, you can call the .shape method

my @a[3;3;3];
dd @a.shape;   # (3,3,3)

If it is not, then your workaround appears the way to do it.

Re: Is there sn ETA for the next Rakudo* ?

2021-01-16 Thread Elizabeth Mattijsen
> On 16 Jan 2021, at 00:27, Parrot Raiser <1parr...@gmail.com> wrote:
> I'm setting up a new machine, and I don't want to install something
> I'm going to have to update in a week.

In about a week, we will have a new Rakudo compiler release.  I think the 
Rakudo* people will wait for that.  So I would guess the next release of 
Rakudo* won't be for another 2 weeks or so.

Re: Strange behaviour in REPL

2021-01-11 Thread Elizabeth Mattijsen
Agree.

That's why I did https://github.com/rakudo/rakudo/commit/d53a927331 earlier 
today.

> On 11 Jan 2021, at 18:36, Richard Hainsworth  wrote:
> 
> I want to test for a key being defined in one hash, and if it is, then it 
> should be a hash, and I need the value of that second key.
> 
> So I was testing my syntax with raku and got the following:
> 
> raku
> Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.12.
> Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
> Built on MoarVM version 2020.12.
> 
> To exit type 'exit' or '^D'
> > my %h =  Z=> 1..*
> {one => 1, three => 3, two => 2}
> > %h = %( this-key  => 'something' )
> {this-key => something}
> > my $x
> (Any)
> > with %h { do with . { $x = $_ } }
> something
> > with %h { do with . { $x = $_ } }
> ===SORRY!===
> Word 'with' interpreted as a listop; please use 'do with' to introduce the 
> statement control word
> at line 4
> --> $ = with⏏ %h { do with . { $x = $
> Unexpected block in infix position (two terms in a row)
> at line 4
> --> $ = with %h⏏ { do with . { $x = $_ } };
> 
> Note the lines begining with 'with'. Exactly the same line, executed twice, 
> produces two significantly different answers.
> 
> I think this shouldn't happen.
> 



Re: surprise with start

2021-01-05 Thread Elizabeth Mattijsen
If those are the only lines in your program, the program will have exited 
before the sleep in the start has actually passed.  If you change the program 
to:

start { sleep 1; say "done"; exit }
say "working";
sleep;

you should also see the "done".

> On 5 Jan 2021, at 14:15, Theo van den Heuvel  wrote:
> 
> Hi gurus,
> 
> The first example in the documentation on the start control flow does not 
> seem to work as promised.
> Here is the code:
> 
> start { sleep 1; say "done" }
> say "working";
> # working, done
> 
> Both 2020.1 and the 2020.12 version under Ubuntu yield only "working". Am I 
> missing something?
> 
> -- 
> Theo van den Heuvel



Re: Help with bug

2020-12-30 Thread Elizabeth Mattijsen
Thank you for the compliment.  But I was merely channeling Jonathan 
Worthington...  :-)

> On 30 Dec 2020, at 14:43, Gianni Ceccarelli  wrote:
> 
> Liz is, as usual, correct: there's no reason to wait until our write
> buffers are flushed (``await $conn.print``) before ``react``ing to
> what's in our *read* buffers.
> 
> In https://github.com/dakkar/raku-socket-test-from-demanuel I've
> removed all ``await`` but one (the ``await .connect``), and the
> program is much more reliable. I have seen it hang once, though,
> so I feel there's still some weirdness going on with buffers
> *somewhere*.
> 
> David: please look at my version of your code, I really think it's
> clearer and simpler to work with, without the explicit ``.tap`` and
> ``.then`` (ok, I have a few ``.then``, but they're for debugging, they
> don't affect the actual working of the program!)
> 
> -- 
>   Dakkar - 
>   GPG public key fingerprint = A071 E618 DD2C 5901 9574
>6FE2 40EA 9883 7519 3F88
>   key id = 0x75193F88
> 



Re: Help with bug

2020-12-29 Thread Elizabeth Mattijsen
Using an `await` inside a react, feels like a code smell to me.  An `await` 
will block the `react` block from processing other messages until the `await` 
returns.  Which feels like it is opening up a large window of dead-locking 
opportunities.

Couldn't a whenever be used there instead?

> On 29 Dec 2020, at 19:12, Gianni Ceccarelli  wrote:
> 
> On 2020-12-29 David Santiago  wrote:
>> i don't want it to exit, i want it to keep reading from the socket
>> until a "200" code happens.
> 
> Sorry, I had mis-understood the protocol.
> 
> I've put the code on Github so it's easier to look at it
> https://github.com/dakkar/raku-socket-test-from-demanuel (those
> certificates are from a random apache test installation)
> 
>> Like you said it looks like it's getting stuck in a react, but why?
> 
> Adding a bunch of ``print``, it looks like it most commonly hangs this
> way:
> 
> * client sends ``SENDING``
> * server reads it, sends the 340
> * the client does *not* see a new line from the connection
> 
> But, if I replace ``IO::Socket::Async::SSL`` with plain
> ``IO::Socket::Async``, I can't make it hang anymore.
> 
> I fear we've uncovered a hard-to-diagnose bug in
> ``IO::Socket::Async::SSL`` …
> 
> -- 
>   dakkar - 
>   GPG public key fingerprint = A071 E618 DD2C 5901 9574
>6FE2 40EA 9883 7519 3F88
>   key id = 0x75193F88
> 



Re: Is the cosine page wrong?

2020-12-28 Thread Elizabeth Mattijsen
https://github.com/Raku/doc/issues/3753

> On 28 Dec 2020, at 16:23, Parrot Raiser <1parr...@gmail.com> wrote:
> 
> I just went to the page at docs.raku.org on multi-line comments, to
> suggest a couple of clarifying edits. The pencil icon invoked a 404
> from GitHub.
> 
> When one goes to make a fix, and the fixer is broken, it's a bit
> recursive. Can anyone cure problem #1, so I can get to step #2? :-)*
> 
> On 12/28/20, Elizabeth Mattijsen  wrote:
>> ❤️
>> 
>>> On 28 Dec 2020, at 13:54, Richard Hainsworth 
>>> wrote:
>>> 
>>> Todd,
>>> 
>>> Some of what you have said in this email list over the years has been very
>>> valuable. You ask questions that get some very illuminating answers. I
>>> wrote a Module just for you (although I' still trying to get it to work on
>>> Windows) and it inspired me to look much more deeply at GTK::Simple, which
>>> I have just become the maintainer for.
>>> 
>>> So please take what I say now as a plea for you to adapt a little, not to
>>> get pissed off with us even though you do seem to have pissed some of us
>>> off.
>>> 
>>> You have very definite ideas about what the documentation should and
>>> shouldn't be. You have stated them over and over again. The Raku community
>>> at large - based on replies from multiple individuals over the years -
>>> disagrees with you.
>>> 
>>> The Raku community has come to the concensus that there is a distinction
>>> between Tutorials and Reference, and that the Documentation site should
>>> contain both. Tutorials define how to use some aspect of Raku, with
>>> example text and explanation. Reference tries to cover as much of the
>>> language as possible, covering all the methods/subs/names/types etc as
>>> possible. Reference is written for a person who already knows how to
>>> program and who uses Raku. The assumption is that if a person reading a
>>> reference does not understand some term, then s/he will search in the
>>> documentation on that term to understand it.
>>> 
>>> No set of documentation standards will please everyone - that's life. Even
>>> so, there ARE STILL areas of the Raku documentation that are lacking (just
>>> look at the issues on the Documentation repository, any of them raised by
>>> our indefatigable JJ).
>>> 
>>> However, the balances between prolixity and brevity, examples and
>>> assumption of knowledge, exhibited in the Raku Documentation do by and
>>> large reflect a community consensus.
>>> 
>>> It is polite in a community of rational human beings to accept what seems
>>> to be the general consensus, even if you do not agree with it. By
>>> continuing to demand your views about documentation should be accepted
>>> without any support from anyone else, is quite irritating. So please try
>>> to find a different way to express ways to improve the documentation that
>>> will not piss people off.
>>> 
>>> You have suggested in this email list a variety of 'keepers', which seem
>>> to be the way you document your use of Raku. However, these 'keeper' texts
>>> are full of spelling mistakes, indicating you do not use a spell-checker,
>>> and also are ambiguous or technically wrong. Personally, I have not found
>>> your keepers to have been any use at all. But they may be useful to
>>> someone. Even worse, it is not possible for me to find a collection of
>>> your keepers because they are in posts to this email list, and I am not
>>> going to search through thousands of emails for your keepers on something
>>> whose keywords I would need to guess at. So the form you have made the
>>> keepers available is not easily accessible.
>>> 
>>> In addition, the way the Raku community has evolved to work is to make
>>> changes to Documentation, whether Tutorials or Reference, by actually
>>> suggesting changes. If you look on the upper right of any primary document
>>> (the docs.raku.org site displays pages that are both automatically
>>> generated from primary documents, and the primary documents themselves -
>>> basically the documents referenced from the home page), you will see a
>>> Pencil icon. Click on that, and you will be taken to the github site and
>>> you can directly edit the document. The change is then submitted as a Pull
>>> Request, and it will be reviewed. If the change is seen to be reasonable,
>>> it is included.
&g

Re: Is the cosine page wrong?

2020-12-28 Thread Elizabeth Mattijsen
❤️

> On 28 Dec 2020, at 13:54, Richard Hainsworth  wrote:
> 
> Todd,
> 
> Some of what you have said in this email list over the years has been very 
> valuable. You ask questions that get some very illuminating answers. I wrote 
> a Module just for you (although I' still trying to get it to work on Windows) 
> and it inspired me to look much more deeply at GTK::Simple, which I have just 
> become the maintainer for.
> 
> So please take what I say now as a plea for you to adapt a little, not to get 
> pissed off with us even though you do seem to have pissed some of us off.
> 
> You have very definite ideas about what the documentation should and 
> shouldn't be. You have stated them over and over again. The Raku community at 
> large - based on replies from multiple individuals over the years - disagrees 
> with you.
> 
> The Raku community has come to the concensus that there is a distinction 
> between Tutorials and Reference, and that the Documentation site should 
> contain both. Tutorials define how to use some aspect of Raku, with example 
> text and explanation. Reference tries to cover as much of the language as 
> possible, covering all the methods/subs/names/types etc as possible. 
> Reference is written for a person who already knows how to program and who 
> uses Raku. The assumption is that if a person reading a reference does not 
> understand some term, then s/he will search in the documentation on that term 
> to understand it.
> 
> No set of documentation standards will please everyone - that's life. Even 
> so, there ARE STILL areas of the Raku documentation that are lacking (just 
> look at the issues on the Documentation repository, any of them raised by our 
> indefatigable JJ).
> 
> However, the balances between prolixity and brevity, examples and assumption 
> of knowledge, exhibited in the Raku Documentation do by and large reflect a 
> community consensus.
> 
> It is polite in a community of rational human beings to accept what seems to 
> be the general consensus, even if you do not agree with it. By continuing to 
> demand your views about documentation should be accepted without any support 
> from anyone else, is quite irritating. So please try to find a different way 
> to express ways to improve the documentation that will not piss people off.
> 
> You have suggested in this email list a variety of 'keepers', which seem to 
> be the way you document your use of Raku. However, these 'keeper' texts are 
> full of spelling mistakes, indicating you do not use a spell-checker, and 
> also are ambiguous or technically wrong. Personally, I have not found your 
> keepers to have been any use at all. But they may be useful to someone. Even 
> worse, it is not possible for me to find a collection of your keepers because 
> they are in posts to this email list, and I am not going to search through 
> thousands of emails for your keepers on something whose keywords I would need 
> to guess at. So the form you have made the keepers available is not easily 
> accessible.
> 
> In addition, the way the Raku community has evolved to work is to make 
> changes to Documentation, whether Tutorials or Reference, by actually 
> suggesting changes. If you look on the upper right of any primary document 
> (the docs.raku.org site displays pages that are both automatically generated 
> from primary documents, and the primary documents themselves - basically the 
> documents referenced from the home page), you will see a Pencil icon. Click 
> on that, and you will be taken to the github site and you can directly edit 
> the document. The change is then submitted as a Pull Request, and it will be 
> reviewed. If the change is seen to be reasonable, it is included.
> 
> In this way, every single member of the Raku Community has the ability to 
> make or suggest a contribution.
> 
> However, a word of caution about human nature. If you go and try to 
> completely change all the documentation to the way you want it, trashing 
> everything that has already been contributed, it is extremely unlikely that 
> your amendments will ever be accepted. Further, you run the risk that 
> contributions with your name will never be considered by the Core Developers 
> because they have rejected PRs you made before.
> 
> Contribute in a way that enhances the Documentation, and your work will be 
> praised.
> 
> I hope whatever end of year, mid-winter or religious festival you celebrated 
> was festive, even in our pandemic afflicted world, and I wish you a safe and 
> productive CE 2021.
> 
> Regards,
> 
> Richard
> 
> On 28/12/2020 11:55, ToddAndMargo via perl6-users wrote:
>> On 12/25/20 8:10 AM, Ralph Mellor wrote:
 On 12/23/20 4:28 PM, Ralph Mellor wrote:
   > If a method does not explicitly specify its invocant type, it is set
   > to the type of the enclosing class.
 
 But it does not specify an invocant.  It just leaves it blank
>>> 
>>> This is how it works in Raku source code. If there's 

Re: Is the cosine page wrong?

2020-12-24 Thread Elizabeth Mattijsen
> On 24 Dec 2020, at 03:55, Matthias Peng  wrote:
> May I ask if there is any practical perl6 project running? For example, 
> homebrew by ruby, k8s by go, flask by python etc.

https://raku-advent.blog/2020/12/20/day-20-a-raku-in-the-wild/ looks like a 
practical project to me.

Re: Missing NullPointerException

2020-12-03 Thread Elizabeth Mattijsen
Nil is really a Failure that doesn't throw.  It indicates the absence of a 
value where there is one expected.

That is why Nil doesn't throw.  If you want to indicate a soft failure, you 
should use fail().

If the chain of methods you mention are core methods, and one of them is 
returning Nil, then perhaps we have a bug.  Could you elaborate on the 
situation where you encountered this?

> On 3 Dec 2020, at 15:22, Konrad Bucheli via perl6-users 
>  wrote:
> 
> 
> 
> On 02.12.20 15:55, Ralph Mellor wrote:
>> On Wed, Dec 2, 2020 at 7:08 AM Patrick R. Michaud  wrote:
>>> Nil.any_non_existent method always seems to return Nil.  I'm not sure where 
>>> this is documented
>> It's near the top of the `Nil` doc page you linked:
>>> Any method call on `Nil` of a method that does not exist ... will succeed 
>>> and return `Nil`.
> 
> 
> OK, that is intentional and documented then. What is actually the rationale 
> for such a behaviour?
> 
> For me it was an unexpected trap as I had a chain of methods which should do 
> some side effect. It all went fine only the side effect was not there. I then 
> figured out after some time that one of methods returned Nil and somehow 
> silently it did not do what I expected.
> 
> Thanks
> 
> Konrad
> 


  1   2   3   4   5   6   7   8   9   10   >