Re: question about the multi in method

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 07:07:29PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-07 14:20, Peter Pentchev wrote:
> > On Sun, Jun 07, 2020 at 12:28:33PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-07 08:19, Peter Pentchev wrote:
> > > > On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> > > > > On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> > > > > perl6-us...@perl.org> wrote:
> > > > > 
> > > > > > Hi All,
> > > > > > 
> > > > > > Dumb question:
> > > > > > 
> > > > > > Does the "multi" in "multi method" mean there
> > > > > > is more than one way to address a method?
> > > > > > 
> > > > > > Or, are the all methods "multi methods".
> > > > > > 
> > > > > > If not and the method is a multi, should not the
> > > > > > documentation show all (more than one) the ways of
> > > > > > addressing a multi method?
> > > > > 
> > > > > There are four different types of a function. (both method and sub)
> > > > > 
> > > > > - `multi`
> > > > > - `proto`
> > > > > - `only`
> > > > > - `anon`
> > > > > 
> > [snip]
> > > > 
> > > > Please note that I'm not criticizing the documentation,
> > > 
> > > That is all right.  I will take up that job.  I am
> > > about to zinger it pretty good.
> > > 
> > > > automatically
> > > > generated or not, or the efforts of everyone involved in producing it :)
> > > > I am under the impression that it is, at least to some extent,
> > > > automatically generated, so I'm genuinely curious what is it about
> > > > the .starts-with() method that has caused it to lose its Cool :)
> > > > 
> > > > ...and, of course, it may turn out that Todd meant something completely
> > > > different in this particular message and I hijacked the thread...
> > > > 
> > > > G'luck,
> > > > Peter
> > > > 
> > > 
> > > 
> > > Hi Peter,
> > > 
> > > Pretty close.
> > > 
> > > I do believe Brad answered the question.  There are
> > > multiple and only and some other types.
> > > 
> > > The reason why I ask is that I find the documentation
> > > frustrating.   Here is an example of a method I
> > > have NO trouble with and use all the time:
> > > 
> > > https://docs.raku.org/type/Mu#method_defined
> > > 
> > >Declared as
> > >   multi method defined(   --> Bool:D)
> > >Returns False on a type object, and True otherwise.
> > > 
> > > It shows one method, but clearly defines it as a
> > > "multi method".  If it is indeed a multiple,
> > > where are the other crypto lines?  Or is it a
> > > misprint and there is only one crypto line as
> > > it is indeed an "only".
> > > 
> > > So I asked, are they ALL multi's.  And the answer is "no".
> > > 
> > > Now when I opened a bug report on one of them:
> > > 
> > >   Where is the multi in starts-with?
> > >   https://github.com/Raku/doc/issues/3456
> > > 
> > > JJ closed the ticket with the following answer:
> > > 
> > >   Let me see how I explain this. It's a bit like
> > >   the American party primaries. Anyone can run,
> > >   right? Only in some cases (mainly when the incumbent
> > >   is there), nobody else bothers to. In this case, a
> > >   multi shows the possibility of declaring other
> > >   routines with the same name and different signature,
> > >   unlike only which says "Nope, you can't".
> > 
> > This is actually very, very common in object-oriented programming.
> > You create a new class, you have a couple of methods that you know will
> > be useful to others, so you declare them as multi in Raku or, say,
> > virtual in C++. Then you add a couple of other methods, and you stop and
> > think "hm, okay, so right now I don't have a need to use this method in
> > another way or override it in another class, but what it does is pretty
> > general, easily extensible, so, yeah, it is very much possible that
> > tomorrow I (or somebody else) will need to redefine or extend it" - and
> > that's why you put a "multi" on a method that *right now* has no real
> > use for it, but it will have one tomorrow.
> > 
> > I do not have an example in mind right now, but I bet that if I look
> > through some of the modules found at https://modules.raku.org/ I can
> > find classes that redefine or extend some really basic methods in
> > Raku's base classes. This is only possible because the developers of
> > Raku decided to declare them as "multi" even though they had no
> > immediate use for that right at that moment.
> > 
> > >   As a matter of fact, there are several of them.
> > > 
> > > https://github.com/rakudo/rakudo/search?q=%22method+starts-with%22_q=%22method+starts-with%22
> > >   However, in this case we made the call of putting
> > >   them in a single definition, since the existence
> > >   of different ones is simply an implementation
> > >   detail.
> > > 
> > > So JJ confirmed that the method was indeed a multi method
> > > but that he WOULD NOT include the other definitions
> > > as it is an "implementation detail".  This 

Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 19:47, ToddAndMargo via perl6-users wrote:

Hi Richard,

How do I stretch the box out so it will show
the entire title?

-T


Only one letter in the title shows
https://ibb.co/X3sVxBV


Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 20:06, ToddAndMargo via perl6-users wrote:

On 2020-06-07 19:47, ToddAndMargo via perl6-users wrote:

Hi Richard,

How do I stretch the box out so it will show
the entire title?

-T



Figured out what is going wrong with the :timer

$data = inform( 'Something cleaver here 
',

     :timer(5),
     # :buttons( [ :OK("OK Maybe") ] ),
     :title("5 second Countdown test"),
     # :entries( [verbage => 'Write me something'] ),
     :show-countdown(True)
   );

:buttons and :entries have to both be commented out
for the timer to work.

Is this suppose to happen?



Am I am still in the dark as to what :show-countdown does.
I was thinking the pop up would have a time showing remain
seconds to dismiss.


Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 19:47, ToddAndMargo via perl6-users wrote:

Hi Richard,

How do I stretch the box out so it will show
the entire title?

-T



Figured out what is going wrong with the :timer

$data = inform( 'Something cleaver here 
',

:timer(5),
# :buttons( [ :OK("OK Maybe") ] ),
:title("5 second Countdown test"),
# :entries( [verbage => 'Write me something'] ),
:show-countdown(True)
  );

:buttons and :entries have to both be commented out
for the timer to work.

Is this suppose to happen?


Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

Hi Richard,

How do I stretch the box out so it will show
the entire title?

-T


Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 08:45, Richard Hainsworth wrote:



Hi Richard,

Some follow questions:

1) where are the directions? 
I don't understand this question. Which directions? I tried to make the 
example as full of explanation as possible.

where are the
variable definitions?

I don't understand this. The variables are all defined.


By directions, I mean the (English) definition of
what each variable does. What do the following do:

:buttons,
:Response,
:timer,
:title,
:show-countdown,
data.response = <$data.response>;
etc.

They may be somewhere there, but I need a link
to them



in the following:

# my first attempt:


first you will need a 'my'. In the example, I put:

my $popup = inform  etc

As I said, but I expanded in the comments, 'inform' is a subroutine that 
returns and 'Informing' object.


Actually, this is also a pointer in answer to something you asked 
elsewhere. This is a way of creating something to which methods are 
attached.



$popup = inform( 'Something cleaver here',
 # :buttons(Dismiss => 'Dismiss Test', 
:Response('Dismissed'))

 # :buttons(Dismiss => 'Dismiss Test'),
 # :buttons( OK=>'OK',b2=>'Not on your life', 
'Cancel'=> "I don't want to")

 :buttons( OK=>'OK Maybe', b2=>'Not on your life' ),
 :timer(5),
 :title("5 second Countdown test"),
 :show-countdown );
print( "popup = <$popup>\n" );
print( "data.response = <$data.response>\n" );


The first print should give you something about the Informing object

Note that in the second print, you have invoked the `.response` method 
on the object. This is used to extract the information from the dialog 
box. However, you have used '<' which is used inside a "" string for 
other things. Better to use


print "data response is = < { $popup.response } >";


That has got me into trouble before.  I switched to
 print( "data = <" ~ $popup ~ ">\n" );
 print( "data.response = <" ~ $data.response ~ ">\n" );

 data = >
 data.response =# or OK




Also note that you have not defined $data.


oops.

What is with the weird
data = >



2) why do I have to have more than one button?
`:buttons( OK=>'OK Maybe' )` errors with

  Type check failed in binding to parameter
  '@buttons'; expected Positional but got Pair
  (:OK("OK Maybe"))


More than one button, possible!

But look at the error message. You have specified `OK => 'string'` which 
is the definition of a Pair, as the error message says.


But what is wanted is a Positional, as the error message says. An 
example of a Positional is an Array. So try this


`:buttons( [ :OK("OK Maybe") ] )

The [ ] creates an Array, which is a Positional.




In my example, I gave three Pairs separated by commas. That is 
interpreted by raku as a Sequence, which is also a Positional.


You could have written

:buttons(:OK("OK Maybe) , ) # note the trailing comma, which is 
essential here.


So it was the comma.  H

There is no reason why an Array can only have one item. But in order to 
make things generic, there needs to be a way to have more than one.


I have array's all the tme with only one element.  Then add t them 
latter.  Raku does not seem to care.  So I am confused

3) what is the difference between "buttons" and "response"?
Both of these give two buttons:
  :buttons(Dismiss => 'Dismiss Test', :Response('Dismissed'))
This is simply raku. There are two ways to define a pair (a) String => 
SomeObject, (b) :String(SomeObject)

When you use => the key is autoquoted to make it a string.


I understand


4) why am I getting a weird response:
 popup = >


Not at all weird, but highly informative :) . This is telling you that 
popup is an Informing Object instance from the Informative Module.


If you look at the text (which you can find in github - my p6/raku 
repositories are public), you will see how Informative is defined.



data.response = .response>


how do I turn it into something useful to me?



5) What is popup suppose to show?

Say what?


$popup.show(



6) why is it not dismissing after 5 seconds?
I don't understand this. I am not prescient - I cannot see what is 
happening on your screen with your setup. It works fine on my computer.


It just sits there on my screen.  You example works though.



7) why is there no "show-countdown"?


There is! `:show-countdown` is named parameter to the method 'show', and 
an example is shown.


By default `:show-countdown` is True, so there is no need to set it if 
you want a countdown. If you dont want a count-down shown, then you need 
to set `:!show-countdown` , which in itself is a shortcut for 
`show-countdown(True)` . This was one of the examples.


I think I misunderstand what :show-countdown does.  I was thinking the 
pop up would have a time showing remain seconds

to dismiss.



Hope the Module could be of some use.


Oh I love it.  It will get a lot of use!

:-)

Thank you!

-T


Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 14:20, Peter Pentchev wrote:

On Sun, Jun 07, 2020 at 12:28:33PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-07 08:19, Peter Pentchev wrote:

On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:

On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:


Hi All,

Dumb question:

Does the "multi" in "multi method" mean there
is more than one way to address a method?

Or, are the all methods "multi methods".

If not and the method is a multi, should not the
documentation show all (more than one) the ways of
addressing a multi method?


There are four different types of a function. (both method and sub)

- `multi`
- `proto`
- `only`
- `anon`


[snip]


Please note that I'm not criticizing the documentation,


That is all right.  I will take up that job.  I am
about to zinger it pretty good.


automatically
generated or not, or the efforts of everyone involved in producing it :)
I am under the impression that it is, at least to some extent,
automatically generated, so I'm genuinely curious what is it about
the .starts-with() method that has caused it to lose its Cool :)

...and, of course, it may turn out that Todd meant something completely
different in this particular message and I hijacked the thread...

G'luck,
Peter




Hi Peter,

Pretty close.

I do believe Brad answered the question.  There are
multiple and only and some other types.

The reason why I ask is that I find the documentation
frustrating.   Here is an example of a method I
have NO trouble with and use all the time:

https://docs.raku.org/type/Mu#method_defined

   Declared as
  multi method defined(   --> Bool:D)
   Returns False on a type object, and True otherwise.

It shows one method, but clearly defines it as a
"multi method".  If it is indeed a multiple,
where are the other crypto lines?  Or is it a
misprint and there is only one crypto line as
it is indeed an "only".

So I asked, are they ALL multi's.  And the answer is "no".

Now when I opened a bug report on one of them:

  Where is the multi in starts-with?
  https://github.com/Raku/doc/issues/3456

JJ closed the ticket with the following answer:

  Let me see how I explain this. It's a bit like
  the American party primaries. Anyone can run,
  right? Only in some cases (mainly when the incumbent
  is there), nobody else bothers to. In this case, a
  multi shows the possibility of declaring other
  routines with the same name and different signature,
  unlike only which says "Nope, you can't".


This is actually very, very common in object-oriented programming.
You create a new class, you have a couple of methods that you know will
be useful to others, so you declare them as multi in Raku or, say,
virtual in C++. Then you add a couple of other methods, and you stop and
think "hm, okay, so right now I don't have a need to use this method in
another way or override it in another class, but what it does is pretty
general, easily extensible, so, yeah, it is very much possible that
tomorrow I (or somebody else) will need to redefine or extend it" - and
that's why you put a "multi" on a method that *right now* has no real
use for it, but it will have one tomorrow.

I do not have an example in mind right now, but I bet that if I look
through some of the modules found at https://modules.raku.org/ I can
find classes that redefine or extend some really basic methods in
Raku's base classes. This is only possible because the developers of
Raku decided to declare them as "multi" even though they had no
immediate use for that right at that moment.


  As a matter of fact, there are several of them.

https://github.com/rakudo/rakudo/search?q=%22method+starts-with%22_q=%22method+starts-with%22
  However, in this case we made the call of putting
  them in a single definition, since the existence
  of different ones is simply an implementation
  detail.

So JJ confirmed that the method was indeed a multi method
but that he WOULD NOT include the other definitions
as it is an "implementation detail".  This makes the
documentation "incomplete" and frustrating as it
is not apparent if it is just incomplete or is it
inaccurate.


I wouldn't go that far. For the .starts-with() method, the three
signatures that Raku gives as possible candidates in the error message
that started this whole thing, one of them actually encompasses the
other two. The fact that the other two exist does not matter *at all* to
the person who uses the .starts-with() method, except in some very,
very, *very* weird cases that you and I will almost certainly not have
to write code for in the next five years.

Let's go back to that error message once more:


(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Str:D: Str:D $needle, *%_ --> Bool)


So what do we see here?

- first, we see a method that accepts a string 

Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 00:28, ToddAndMargo via perl6-users wrote:

Hi All,

Is there a way to do an "if" on "use lib", so
I do not have to keep commenting these back and forth?

# use lib 'C:/NtUtil', '.';
use lib 'C:/NtUtil', '.', 'K:/NtUtil';

Many thanks,
-T


Follow up:

With tons of help from Peter and others, this is my
keeper on "use lib":

-T


Perl 6: "use lib" delimiter:

Single quote each path and separate with a comma:

   use lib '/usr/share/perl6/site/bin', '/home/linuxutil';

You can also feed it an array
   use lib @path


To print you "use lib" path:
   $ raku -e 'use lib "/home/todd","/home/bozo"; say $*REPO.repo-chain;'
   (file#/home/bozo file#/home/todd inst#/home/todd/.raku 
inst#/opt/rakudo-pkg/share/perl6/site 
inst#/opt/rakudo-pkg/share/perl6/vendor 
inst#/opt/rakudo-pkg/share/perl6/core ap# nqp# perl5#)


   $ raku -e 'use lib "/home/todd","/home/bozo"; dd $*REPO.repo-chain;'
   (CompUnit::Repository::FileSystem.new(prefix => "/home/bozo"), 
CompUnit::Repository::FileSystem.new(prefix => "/home/todd"), 
CompUnit::Repository::Installation.new(prefix => "/home/todd/.raku"), 
CompUnit::Repository::Installation.new(prefix => 
"/opt/rakudo-pkg/share/perl6/site"), 
CompUnit::Repository::Installation.new(prefix => 
"/opt/rakudo-pkg/share/perl6/vendor"), 
CompUnit::Repository::Installation.new(prefix => 
"/opt/rakudo-pkg/share/perl6/core"), 
CompUnit::Repository::AbsolutePath.new(next-repo => 
CompUnit::Repository::NQP.new(next-repo => 
CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository))), 
CompUnit::Repository::NQP.new(next-repo => 
CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository)), 
CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository))


   $ raku -e 'use lib "/home/todd","/home/bozo"; dd 
$*REPO.repo-chain.lines;'
("/home/bozo /home/todd /home/todd/.raku 
/opt/rakudo-pkg/share/perl6/site /opt/rakudo-pkg/share/perl6/vendor 
/opt/rakudo-pkg/share/perl6/core 
CompUnit::Repository::AbsolutePath<88733600> 
CompUnit::Repository::NQP<78635800> 
CompUnit::Repository::Perl5<78635840>",).Seq



To add things to a "use lib" based on a test:

~
#!/usr/bin/env raku

# Note: this has to be the first thing at the top

my @LibPath;

BEGIN {
   for ('K:/Windows/NtUtil', 'X:/NtUtil') -> $candidate {
 push @LibPath, $candidate if $candidate.IO.d;
  }
   push @LibPath, 'C:/NtUtil';
   push @LibPath, '.';
}


use lib @LibPath;

dd @LibPath;
dd $*REPO.repo-chain.lines;
~~

raku use.lib.test.pl6

Array @LibPath = ["K:/Windows/NtUtil", "C:/NtUtil", "."]

("K:\\Windows\\NtUtil C:\\NtUtil C:\\Users\\todd\\.raku 
C:\\rakudo\\share\\perl6\\site C:\\rakudo\\share\\perl6\\vendor 
C:\\rakudo\\share\\perl6\\core 
CompUnit::Repository::AbsolutePath<131860432> 
CompUnit::Repository::NQP<124427016> 
CompUnit::Repository::Perl5<124427056>",).Seq


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 14:40, Peter Pentchev wrote:

On Mon, Jun 08, 2020 at 12:26:42AM +0300, Peter Pentchev wrote:

On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote:

On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-07 13:53, Peter Pentchev wrote:

$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';


Got it!  Thank you!

I am not seeing the above enter the proper syntax:

 'lib1', 'lib2' etc.

Where is the comma?  How are the single quotes entered?


I don't understand what you are asking. The above checks whether
a directory exists and, depending on the result of this check, assigns
one of two values to a variable. I don't know what comma you are talking
about.


Wait, I think I got it. You're asking about the line underneath, the one
that you did not quote in this message, the line that says:

   use lib $path;

"use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is
a string.  $path is a variable that holds a string. "use lib $path"
calls "use lib" and passes to it the string in the variable $path.


So to be a bit more clear, in your case you have a path that you always
need to pass ('c:/something') and another one that you want to pass only
if it exists. OK, so maybe something like:

my @path;

BEGIN {
 for ('K:/NtUtil', 'X:/NtUtil') -> $candidate {
 push @path, $candidate if $candidate.IO.d;
 }
 push @path, 'C:/NtUtil';
}

use lib @path;

Maybe something like that will work for you.

G'luck,
Peter



Hi Peter,

That worked.  Thank you!

Apparently I do not need the BEGIN.  What was it's
utility?


~
#!/usr/bin/env raku

BEGIN {
   for ('K:/NtUtil', 'X:/NtUtil') -> $candidate {
 push @path, $candidate if $candidate.IO.d;
  }
   push @path, 'C:/NtUtil';
   push @path, '.';
}

use lib @path;

dd @path;
dd $*REPO.repo-chain.lines;
~~

raku use.lib.test.pl6

Array @path = ["K:/NtUtil", "C:/NtUtil", "."]

("K:\\Windows\\NtUtil C:\\NtUtil K:\\NtUtil C:\\Users\\tony\\.raku 
C:\\rakudo\\share\\perl6\\site C:\\rakudo\\share\\perl6\\vendor 
C:\\rakudo\\share\\perl6\\core 
CompUnit::Repository::AbsolutePath<127518976> 
CompUnit::Repository::NQP<126192040> 
CompUnit::Repository::Perl5<126192080>",).Seq


-T


Re: question about the multi in method

2020-06-07 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 12:20:03AM +0300, Peter Pentchev wrote:
> On Sun, Jun 07, 2020 at 12:28:33PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-06-07 08:19, Peter Pentchev wrote:
> > > On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> > > > On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> > > > perl6-us...@perl.org> wrote:
> > > > 
> > > > > Hi All,
> > > > > 
> > > > > Dumb question:
> > > > > 
> > > > > Does the "multi" in "multi method" mean there
> > > > > is more than one way to address a method?
> > > > > 
> > > > > Or, are the all methods "multi methods".
> > > > > 
> > > > > If not and the method is a multi, should not the
> > > > > documentation show all (more than one) the ways of
> > > > > addressing a multi method?
> > > > 
> > > > There are four different types of a function. (both method and sub)
> > > > 
> > > > - `multi`
> > > > - `proto`
> > > > - `only`
> > > > - `anon`
> > > > 
> [snip]
> > > 
> > > Please note that I'm not criticizing the documentation,
> > 
> > That is all right.  I will take up that job.  I am
> > about to zinger it pretty good.
> > 
> > > automatically
> > > generated or not, or the efforts of everyone involved in producing it :)
> > > I am under the impression that it is, at least to some extent,
> > > automatically generated, so I'm genuinely curious what is it about
> > > the .starts-with() method that has caused it to lose its Cool :)
> > > 
> > > ...and, of course, it may turn out that Todd meant something completely
> > > different in this particular message and I hijacked the thread...
> > > 
> > > G'luck,
> > > Peter
> > > 
> > 
> > 
> > Hi Peter,
> > 
> > Pretty close.
> > 
> > I do believe Brad answered the question.  There are
> > multiple and only and some other types.
> > 
> > The reason why I ask is that I find the documentation
> > frustrating.   Here is an example of a method I
> > have NO trouble with and use all the time:
> > 
> > https://docs.raku.org/type/Mu#method_defined
> > 
> >   Declared as
> >  multi method defined(   --> Bool:D)
> >   Returns False on a type object, and True otherwise.
> > 
> > It shows one method, but clearly defines it as a
> > "multi method".  If it is indeed a multiple,
> > where are the other crypto lines?  Or is it a
> > misprint and there is only one crypto line as
> > it is indeed an "only".
> > 
> > So I asked, are they ALL multi's.  And the answer is "no".
> > 
> > Now when I opened a bug report on one of them:
> > 
> >  Where is the multi in starts-with?
> >  https://github.com/Raku/doc/issues/3456
> > 
> > JJ closed the ticket with the following answer:
> > 
> >  Let me see how I explain this. It's a bit like
> >  the American party primaries. Anyone can run,
> >  right? Only in some cases (mainly when the incumbent
> >  is there), nobody else bothers to. In this case, a
> >  multi shows the possibility of declaring other
> >  routines with the same name and different signature,
> >  unlike only which says "Nope, you can't".
> 
> This is actually very, very common in object-oriented programming.
> You create a new class, you have a couple of methods that you know will
> be useful to others, so you declare them as multi in Raku or, say,
> virtual in C++. Then you add a couple of other methods, and you stop and
> think "hm, okay, so right now I don't have a need to use this method in
> another way or override it in another class, but what it does is pretty
> general, easily extensible, so, yeah, it is very much possible that
> tomorrow I (or somebody else) will need to redefine or extend it" - and
> that's why you put a "multi" on a method that *right now* has no real
> use for it, but it will have one tomorrow.
> 
> I do not have an example in mind right now, but I bet that if I look
> through some of the modules found at https://modules.raku.org/ I can
> find classes that redefine or extend some really basic methods in
> Raku's base classes. This is only possible because the developers of
> Raku decided to declare them as "multi" even though they had no
> immediate use for that right at that moment.

All of this would have been a little bit clearer if I had actually
remembered to make the distinction between Raku the language (that has a
specification that says that .starts-with() has a positional parameter
and a couple of optional ones) and {NQP, MoarVM, Rakudo} as the
combination that brings us the most-often used implementation,
the so-called "reference implementation" written by the same people who
write the specification. The reference implementation is there partly to
give people an actual usable language and partly to prove that the
specification is sensible, that it *may* be implemented in a compiler
and a virtual machine that may be used to run real programs written in
the Raku language.

This does not mean that the {NQP, MoarVM, Rakudo} implementation is
restricted to only having the methods that the Raku 

Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 05:33:43PM -0400, Will Coleda wrote:
> On Sun, Jun 7, 2020 at 4:53 PM Peter Pentchev  wrote:
> >
> > On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-07 02:32, Peter Pentchev wrote:
> > >
> > > > BEGIN {
> > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > > > }
> > >
> > > Does the final "}" close the BEGIN?
> >
> > Well, there is an opening { after "BEGIN", so, yes.
> >
> > More precisely, it closes the block that is to be executed early.
> >
> > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > >
> > > Hi Peter,
> > >
> > > Would you explain what the ?? and !! are
> > > doing in the above?
> >
> > https://docs.raku.org/language/operators#infix_??_!!
> 
> the URL with literal !! in it didn't work for me, but this does:
> https://docs.raku.org/language/operators#infix_??_%21%21

Ah, but of course. Aren't Web standards and browsers great. I did copy
and paste it from the location bar, and I did not stop to think about
it, since I foolishly trusted that my browser would actually copy
a usable URL.

Thanks.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 12:26:42AM +0300, Peter Pentchev wrote:
> On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote:
> > On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-07 13:53, Peter Pentchev wrote:
> > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > > 
> > > Got it!  Thank you!
> > > 
> > > I am not seeing the above enter the proper syntax:
> > > 
> > > 'lib1', 'lib2' etc.
> > > 
> > > Where is the comma?  How are the single quotes entered?
> > 
> > I don't understand what you are asking. The above checks whether
> > a directory exists and, depending on the result of this check, assigns
> > one of two values to a variable. I don't know what comma you are talking
> > about.
> 
> Wait, I think I got it. You're asking about the line underneath, the one
> that you did not quote in this message, the line that says:
> 
>   use lib $path;
> 
> "use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is
> a string.  $path is a variable that holds a string. "use lib $path"
> calls "use lib" and passes to it the string in the variable $path.

So to be a bit more clear, in your case you have a path that you always
need to pass ('c:/something') and another one that you want to pass only
if it exists. OK, so maybe something like:

my @path;

BEGIN { 
for ('K:/NtUtil', 'X:/NtUtil') -> $candidate {
push @path, $candidate if $candidate.IO.d;
}
push @path, 'C:/NtUtil';
}   

use lib @path;

Maybe something like that will work for you.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Will Coleda
the URL with literal !! in it didn't work for me, but this does:
https://docs.raku.org/language/operators#infix_??_%21%21

On Sun, Jun 7, 2020 at 4:53 PM Peter Pentchev  wrote:
>
> On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-06-07 02:32, Peter Pentchev wrote:
> >
> > > BEGIN {
> > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > > }
> >
> > Does the final "}" close the BEGIN?
>
> Well, there is an opening { after "BEGIN", so, yes.
>
> More precisely, it closes the block that is to be executed early.
>
> > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> >
> > Hi Peter,
> >
> > Would you explain what the ?? and !! are
> > doing in the above?
>
> https://docs.raku.org/language/operators#infix_??_!!
>
> G'luck,
> Peter
>
> --
> Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
> PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote:
> On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-06-07 13:53, Peter Pentchev wrote:
> > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > 
> > Got it!  Thank you!
> > 
> > I am not seeing the above enter the proper syntax:
> > 
> > 'lib1', 'lib2' etc.
> > 
> > Where is the comma?  How are the single quotes entered?
> 
> I don't understand what you are asking. The above checks whether
> a directory exists and, depending on the result of this check, assigns
> one of two values to a variable. I don't know what comma you are talking
> about.

Wait, I think I got it. You're asking about the line underneath, the one
that you did not quote in this message, the line that says:

  use lib $path;

"use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is
a string.  $path is a variable that holds a string. "use lib $path"
calls "use lib" and passes to it the string in the variable $path.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 12:32, ToddAndMargo via perl6-users wrote:

n 2020-06-07 02:32, Peter Pentchev wrote:


BEGIN {
$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
}


Does the final "}" close the BEGIN?



Hi Peter,

I am so use to

   BEGIN
   ...
   END

In other languages, that I had to ask.  Modula2
is especially a BEGIN and END user.

I do adore the way Raku cleans up the unnesseary
verbage.

But I still do catch myself saying "DO" when I
type "{" and "END" when I type "}"

:'(

-T


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-07 13:53, Peter Pentchev wrote:
> > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> 
> Got it!  Thank you!
> 
> I am not seeing the above enter the proper syntax:
> 
> 'lib1', 'lib2' etc.
> 
> Where is the comma?  How are the single quotes entered?

I don't understand what you are asking. The above checks whether
a directory exists and, depending on the result of this check, assigns
one of two values to a variable. I don't know what comma you are talking
about.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: question about the multi in method

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 12:28:33PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-07 08:19, Peter Pentchev wrote:
> > On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> > > On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> > > perl6-us...@perl.org> wrote:
> > > 
> > > > Hi All,
> > > > 
> > > > Dumb question:
> > > > 
> > > > Does the "multi" in "multi method" mean there
> > > > is more than one way to address a method?
> > > > 
> > > > Or, are the all methods "multi methods".
> > > > 
> > > > If not and the method is a multi, should not the
> > > > documentation show all (more than one) the ways of
> > > > addressing a multi method?
> > > 
> > > There are four different types of a function. (both method and sub)
> > > 
> > > - `multi`
> > > - `proto`
> > > - `only`
> > > - `anon`
> > > 
[snip]
> > 
> > Please note that I'm not criticizing the documentation,
> 
> That is all right.  I will take up that job.  I am
> about to zinger it pretty good.
> 
> > automatically
> > generated or not, or the efforts of everyone involved in producing it :)
> > I am under the impression that it is, at least to some extent,
> > automatically generated, so I'm genuinely curious what is it about
> > the .starts-with() method that has caused it to lose its Cool :)
> > 
> > ...and, of course, it may turn out that Todd meant something completely
> > different in this particular message and I hijacked the thread...
> > 
> > G'luck,
> > Peter
> > 
> 
> 
> Hi Peter,
> 
> Pretty close.
> 
> I do believe Brad answered the question.  There are
> multiple and only and some other types.
> 
> The reason why I ask is that I find the documentation
> frustrating.   Here is an example of a method I
> have NO trouble with and use all the time:
> 
> https://docs.raku.org/type/Mu#method_defined
> 
>   Declared as
>  multi method defined(   --> Bool:D)
>   Returns False on a type object, and True otherwise.
> 
> It shows one method, but clearly defines it as a
> "multi method".  If it is indeed a multiple,
> where are the other crypto lines?  Or is it a
> misprint and there is only one crypto line as
> it is indeed an "only".
> 
> So I asked, are they ALL multi's.  And the answer is "no".
> 
> Now when I opened a bug report on one of them:
> 
>  Where is the multi in starts-with?
>  https://github.com/Raku/doc/issues/3456
> 
> JJ closed the ticket with the following answer:
> 
>  Let me see how I explain this. It's a bit like
>  the American party primaries. Anyone can run,
>  right? Only in some cases (mainly when the incumbent
>  is there), nobody else bothers to. In this case, a
>  multi shows the possibility of declaring other
>  routines with the same name and different signature,
>  unlike only which says "Nope, you can't".

This is actually very, very common in object-oriented programming.
You create a new class, you have a couple of methods that you know will
be useful to others, so you declare them as multi in Raku or, say,
virtual in C++. Then you add a couple of other methods, and you stop and
think "hm, okay, so right now I don't have a need to use this method in
another way or override it in another class, but what it does is pretty
general, easily extensible, so, yeah, it is very much possible that
tomorrow I (or somebody else) will need to redefine or extend it" - and
that's why you put a "multi" on a method that *right now* has no real
use for it, but it will have one tomorrow.

I do not have an example in mind right now, but I bet that if I look
through some of the modules found at https://modules.raku.org/ I can
find classes that redefine or extend some really basic methods in
Raku's base classes. This is only possible because the developers of
Raku decided to declare them as "multi" even though they had no
immediate use for that right at that moment.

>  As a matter of fact, there are several of them.
> 
> https://github.com/rakudo/rakudo/search?q=%22method+starts-with%22_q=%22method+starts-with%22
>  However, in this case we made the call of putting
>  them in a single definition, since the existence
>  of different ones is simply an implementation
>  detail.
> 
> So JJ confirmed that the method was indeed a multi method
> but that he WOULD NOT include the other definitions
> as it is an "implementation detail".  This makes the
> documentation "incomplete" and frustrating as it
> is not apparent if it is just incomplete or is it
> inaccurate.

I wouldn't go that far. For the .starts-with() method, the three
signatures that Raku gives as possible candidates in the error message
that started this whole thing, one of them actually encompasses the
other two. The fact that the other two exist does not matter *at all* to
the person who uses the .starts-with() method, except in some very,
very, *very* weird cases that you and I will almost certainly not have
to write code for in the next five years.

Let's go back to that 

Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 13:57, ToddAndMargo via perl6-users wrote:

On 2020-06-07 13:53, Peter Pentchev wrote:

$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';


Got it!  Thank you!

I am not seeing the above enter the proper syntax:

     'lib1', 'lib2' etc.

Where is the comma?  How are the single quotes entered?

-T


what am I doing wrong?

~~
#!/usr/bin/env raku

my $path;

BEGIN {
	  # $path = 'K:/NtUtil'.IO.d ?? 'K:/NtUtil' !! 'C:/NtUtil';  # "" true; 
 !! false

  $path = Q['] ~ 'X:/NtUtil'.IO.d ?? 'X:/NtUtil' !! '';
   $path = Q['] ~ $path ~ Q[', 'C:/NtUtil', '.'];
}

use lib $path;

print $path ~ "\n";
~

K:\Windows\NtUtil>raku use.lib.test
===SORRY!=== Error while compiling K:\Windows\NtUtil/use.lib.test
An exception occurred while evaluating a BEGIN
at K:\Windows\NtUtil/use.lib.test:5
Exception details:
  Failed to find 'X:\NtUtil' while trying to do '.d'
in block  at use.lib.test line 7


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 13:53, Peter Pentchev wrote:

$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';


Got it!  Thank you!

I am not seeing the above enter the proper syntax:

'lib1', 'lib2' etc.

Where is the comma?  How are the single quotes entered?

-T


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-07 02:32, Peter Pentchev wrote:
> 
> > BEGIN {
> > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > }
> 
> Does the final "}" close the BEGIN?

Well, there is an opening { after "BEGIN", so, yes.

More precisely, it closes the block that is to be executed early.

> > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> 
> Hi Peter,
> 
> Would you explain what the ?? and !! are
> doing in the above?

https://docs.raku.org/language/operators#infix_??_!!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 08:29, Veesh Goldman wrote:

I imagine they called it cool because it, indeed, is cool.


The Raku developers do have a sense of humor.  Cool,
needle, slurp, spurt: someone had a good laugh.

:-)


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 02:32, Peter Pentchev wrote:


BEGIN {
$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
}


Does the final "}" close the BEGIN?



$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';


Hi Peter,

Would you explain what the ?? and !! are
doing in the above?

Many thanks,
-T


Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 08:19, Peter Pentchev wrote:

On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:

On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:


Hi All,

Dumb question:

Does the "multi" in "multi method" mean there
is more than one way to address a method?

Or, are the all methods "multi methods".

If not and the method is a multi, should not the
documentation show all (more than one) the ways of
addressing a multi method?


There are four different types of a function. (both method and sub)

- `multi`
- `proto`
- `only`
- `anon`

A `proto` function is mainly just to declare there will be multiple
functions with same name.
`multi` is short for "multiple", meaning more than one.
`only` is the default, it means there is only one.
`anon` is for creating a lambda. (You only need it if you give the function
a name.)

Again this applies to both subs and methods.
(Also `regex`, `token`, and `rule`. As they are just special methods.)

 only sub foo (){}
 only sub foo (1){} # ERROR: redeclaration
 # note that `only` is optional, as it is the default.

 proto sub bar (|){*}
 multi sub bar (){}
 multi sub bar (1){}
 # note that defining a `proto` function is optional

 my $var = anon sub baz (){ 'fuzz' };
 say baz(); # ERROR: can't find a sub named `baz`
 say $var(); # fuzz
 say $var.name; # baz


I believe, though I'm not sure, that Todd may be referring to one of
the questions that came up in a longish recent thread, namely the fact
that the documentation of Str.starts-with() seems to only document it as
a Str method, while Raku seems to disagree:

[roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("a")'
Cannot resolve caller starts-with(Str:U: Str:D); none of these signatures match:
 (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
 (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Cool:D: Cool:D $needle, *%_ --> Bool)
 (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
 (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Str:D: Str:D $needle, *%_ --> Bool)
   in block  at -e line 1

[roam@straylight ~]$

So it seems that Cool has a .starts-with() method too, and this is borne
out by a further experiment:

[roam@straylight ~]$ raku -e 'my Cool $x; $x.starts-with("a")'
Cannot resolve caller starts-with(Cool:U: Str:D); none of these signatures 
match:
 (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
 (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
 (Cool:D: Cool:D $needle, *%_ --> Bool)
   in block  at -e line 1

[roam@straylight ~]$

So the truth is that I do not fully understand why the documentation
does not list .starts-with() as a method for Cool as well as Str: in
https://docs.raku.org/routine.html "starts-with" is listed as "from
Str", while there are other methods that are listed as "from Cool, Str",
e.g. "subst".

Now, yeah, I understand that Str.starts-with() defines a coercion for
its $needle argument that means that Cool.starts-with() will never be
called for an invocant that is either a Str or of any type derived from
Str, no matter what $needle is - if it is from another Cool-derived
type, it will be coerced to Str and Str.starts-with() will be called.
However, should the documentation not mention that another type derived
from Cool will also have a .starts-with() method?

Please note that I'm not criticizing the documentation, 


That is all right.  I will take up that job.  I am
about to zinger it pretty good.


automatically
generated or not, or the efforts of everyone involved in producing it :)
I am under the impression that it is, at least to some extent,
automatically generated, so I'm genuinely curious what is it about
the .starts-with() method that has caused it to lose its Cool :)

...and, of course, it may turn out that Todd meant something completely
different in this particular message and I hijacked the thread...

G'luck,
Peter




Hi Peter,

Pretty close.

I do believe Brad answered the question.  There are
multiple and only and some other types.

The reason why I ask is that I find the documentation
frustrating.   Here is an example of a method I
have NO trouble with and use all the time:

https://docs.raku.org/type/Mu#method_defined

  Declared as
 multi method defined(   --> Bool:D)
  Returns False on a type object, and True otherwise.

It shows one method, but clearly defines it as a
"multi method".  If it is indeed a multiple,
where are the other crypto lines?  Or is it a
misprint and there is only one crypto line as
it is indeed an "only".

So I asked, are they ALL multi's.  And the answer is "no".

Now when I opened a bug report on one of them:

 Where is the multi in starts-with?
 https://github.com/Raku/doc/issues/3456

JJ closed the ticket with the following answer:

 Let me see how I explain this. It's a 

Re: I need a GTK pop up with time out

2020-06-07 Thread Richard Hainsworth

Mea culpa

:!show-countdown === :show-countdown(False)

:show-countdown === :show-coundown(True)

But skewer-names, not snake.

Thanks Peter for the correction.

Richard

On 07/06/2020 17:18, Peter Pentchev wrote:

On Sun, Jun 07, 2020 at 04:45:16PM +0100, Richard Hainsworth wrote:

Todd

I'm answering this question in the main list to explain some shortcuts.

Just to make sure it all works (if Windows will accept GTK), copy the
program from the Readme to a script file and run it with raku.

Playing around with it should make things clear.

On 07/06/2020 07:16, ToddAndMargo via perl6-users wrote:

[snip]

7) why is there no "show-countdown"?

There is! `:show-countdown` is named parameter to the method 'show', and an
example is shown.

By default `:show-countdown` is True, so there is no need to set it if you
want a countdown. If you dont want a count-down shown, then you need to set
`:!show-countdown` , which in itself is a shortcut for
`show-countdown(True)` . This was one of the examples.

Just a minor point: ITYM "a shortcut for show_countdown(False)" :)


Those shortcuts are becoming fairly common raku idioms. I didn't think it
would be necessary to document them.

G'luck,
Peter



Re: I need a GTK pop up with time out

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 04:45:16PM +0100, Richard Hainsworth wrote:
> Todd
> 
> I'm answering this question in the main list to explain some shortcuts.
> 
> Just to make sure it all works (if Windows will accept GTK), copy the
> program from the Readme to a script file and run it with raku.
> 
> Playing around with it should make things clear.
> 
> On 07/06/2020 07:16, ToddAndMargo via perl6-users wrote:
[snip]
> > 7) why is there no "show-countdown"?
> 
> There is! `:show-countdown` is named parameter to the method 'show', and an
> example is shown.
> 
> By default `:show-countdown` is True, so there is no need to set it if you
> want a countdown. If you dont want a count-down shown, then you need to set
> `:!show-countdown` , which in itself is a shortcut for
> `show-countdown(True)` . This was one of the examples.

Just a minor point: ITYM "a shortcut for show_countdown(False)" :)

> Those shortcuts are becoming fairly common raku idioms. I didn't think it
> would be necessary to document them.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: I need a GTK pop up with time out

2020-06-07 Thread Richard Hainsworth

Todd

I'm answering this question in the main list to explain some shortcuts.

Just to make sure it all works (if Windows will accept GTK), copy the 
program from the Readme to a script file and run it with raku.


Playing around with it should make things clear.

On 07/06/2020 07:16, ToddAndMargo via perl6-users wrote:

On 2020-06-04 04:35, Richard Hainsworth wrote:

Todd,

I wrote you one a very long time ago, after a question from you.

The module is called "Inform". Its on the modules site.

Since it was a long time ago, there may be some bit-rot. Let me know 
if there is .


The module should show how to use GTK, and there is a time-out function.

Richard, aka finanalyst

On 04/06/2020 02:55, ToddAndMargo via perl6-users wrote:

Hi All,

Okay, now I know I am pushing it.  Can anyone point me to
an example of a GTK information pop up with a time out
feature?  Or similar?

Many thanks,
-T


Hi Richard,

Some follow questions:

1) where are the directions? 
I don't understand this question. Which directions? I tried to make the 
example as full of explanation as possible.

where are the
variable definitions?

I don't understand this. The variables are all defined.


in the following:

# my first attempt:


first you will need a 'my'. In the example, I put:

my $popup = inform  etc

As I said, but I expanded in the comments, 'inform' is a subroutine that 
returns and 'Informing' object.


Actually, this is also a pointer in answer to something you asked 
elsewhere. This is a way of creating something to which methods are 
attached.



$popup = inform( 'Something cleaver here',
 # :buttons(Dismiss => 'Dismiss Test', 
:Response('Dismissed'))

 # :buttons(Dismiss => 'Dismiss Test'),
 # :buttons( OK=>'OK',b2=>'Not on your life', 
'Cancel'=> "I don't want to")

 :buttons( OK=>'OK Maybe', b2=>'Not on your life' ),
 :timer(5),
 :title("5 second Countdown test"),
 :show-countdown );
print( "popup = <$popup>\n" );
print( "data.response = <$data.response>\n" );


The first print should give you something about the Informing object

Note that in the second print, you have invoked the `.response` method 
on the object. This is used to extract the information from the dialog 
box. However, you have used '<' which is used inside a "" string for 
other things. Better to use


print "data response is = < { $popup.response } >";

Also note that you have not defined $data.



2) why do I have to have more than one button?
`:buttons( OK=>'OK Maybe' )` errors with

  Type check failed in binding to parameter
  '@buttons'; expected Positional but got Pair
  (:OK("OK Maybe"))


More than one button, possible!

But look at the error message. You have specified `OK => 'string'` which 
is the definition of a Pair, as the error message says.


But what is wanted is a Positional, as the error message says. An 
example of a Positional is an Array. So try this


`:buttons( [ :OK("OK Maybe") ] )

The [ ] creates an Array, which is a Positional.

In my example, I gave three Pairs separated by commas. That is 
interpreted by raku as a Sequence, which is also a Positional.


You could have written

:buttons(:OK("OK Maybe) , ) # note the trailing comma, which is 
essential here.


There is no reason why an Array can only have one item. But in order to 
make things generic, there needs to be a way to have more than one.




3) what is the difference between "buttons" and "response"?
Both of these give two buttons:
  :buttons(Dismiss => 'Dismiss Test', :Response('Dismissed'))
This is simply raku. There are two ways to define a pair (a) String => 
SomeObject, (b) :String(SomeObject)

When you use => the key is autoquoted to make it a string.

4) why am I getting a weird response:
 popup = >


Not at all weird, but highly informative :) . This is telling you that 
popup is an Informing Object instance from the Informative Module.


If you look at the text (which you can find in github - my p6/raku 
repositories are public), you will see how Informative is defined.



data.response = .response>

5) What is popup suppose to show?

Say what?


6) why is it not dismissing after 5 seconds?
I don't understand this. I am not prescient - I cannot see what is 
happening on your screen with your setup. It works fine on my computer.


7) why is there no "show-countdown"?


There is! `:show-countdown` is named parameter to the method 'show', and 
an example is shown.


By default `:show-countdown` is True, so there is no need to set it if 
you want a countdown. If you dont want a count-down shown, then you need 
to set `:!show-countdown` , which in itself is a shortcut for 
`show-countdown(True)` . This was one of the examples.


Those shortcuts are becoming fairly common raku idioms. I didn't think 
it would be necessary to document them.





Many thanks,
-T

Hope the Module could be of some use.


Re: question about the multi in method

2020-06-07 Thread Veesh Goldman
I imagine they called it cool because it, indeed, is cool.

On Sun, Jun 7, 2020, 18:28 Peter Pentchev  wrote:

> On Sun, Jun 07, 2020 at 06:19:29PM +0300, Peter Pentchev wrote:
> > On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> > > On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> > > perl6-us...@perl.org> wrote:
> > >
> > > > Hi All,
> > > >
> > > > Dumb question:
> > > >
> > > > Does the "multi" in "multi method" mean there
> > > > is more than one way to address a method?
> > > >
> > > > Or, are the all methods "multi methods".
> > > >
> > > > If not and the method is a multi, should not the
> > > > documentation show all (more than one) the ways of
> > > > addressing a multi method?
> > >
> > > There are four different types of a function. (both method and sub)
> > >
> > > - `multi`
> > > - `proto`
> > > - `only`
> > > - `anon`
> > >
> > > A `proto` function is mainly just to declare there will be multiple
> > > functions with same name.
> > > `multi` is short for "multiple", meaning more than one.
> > > `only` is the default, it means there is only one.
> > > `anon` is for creating a lambda. (You only need it if you give the
> function
> > > a name.)
> > >
> > > Again this applies to both subs and methods.
> > > (Also `regex`, `token`, and `rule`. As they are just special methods.)
> > >
> > > only sub foo (){}
> > > only sub foo (1){} # ERROR: redeclaration
> > > # note that `only` is optional, as it is the default.
> > >
> > > proto sub bar (|){*}
> > > multi sub bar (){}
> > > multi sub bar (1){}
> > > # note that defining a `proto` function is optional
> > >
> > > my $var = anon sub baz (){ 'fuzz' };
> > > say baz(); # ERROR: can't find a sub named `baz`
> > > say $var(); # fuzz
> > > say $var.name; # baz
> >
> > I believe, though I'm not sure, that Todd may be referring to one of
> > the questions that came up in a longish recent thread, namely the fact
> > that the documentation of Str.starts-with() seems to only document it as
> > a Str method, while Raku seems to disagree:
> >
> > [roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("a")'
> > Cannot resolve caller starts-with(Str:U: Str:D); none of these
> signatures match:
> > (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
> --> Bool)
> > (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> > (Cool:D: Cool:D $needle, *%_ --> Bool)
> > (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ -->
> Bool)
> > (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> > (Str:D: Str:D $needle, *%_ --> Bool)
> >   in block  at -e line 1
> >
> > [roam@straylight ~]$
> >
> > So it seems that Cool has a .starts-with() method too, and this is borne
> > out by a further experiment:
> >
> > [roam@straylight ~]$ raku -e 'my Cool $x; $x.starts-with("a")'
> > Cannot resolve caller starts-with(Cool:U: Str:D); none of these
> signatures match:
> > (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_
> --> Bool)
> > (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> > (Cool:D: Cool:D $needle, *%_ --> Bool)
> >   in block  at -e line 1
> >
> > [roam@straylight ~]$
> >
> > So the truth is that I do not fully understand why the documentation
> > does not list .starts-with() as a method for Cool as well as Str: in
> > https://docs.raku.org/routine.html "starts-with" is listed as "from
> > Str", while there are other methods that are listed as "from Cool, Str",
> > e.g. "subst".
> >
> > Now, yeah, I understand that Str.starts-with() defines a coercion for
> > its $needle argument that means that Cool.starts-with() will never be
> > called for an invocant that is either a Str or of any type derived from
> > Str, no matter what $needle is - if it is from another Cool-derived
> > type, it will be coerced to Str and Str.starts-with() will be called.
> > However, should the documentation not mention that another type derived
> > from Cool will also have a .starts-with() method?
> >
> > Please note that I'm not criticizing the documentation, automatically
> > generated or not, or the efforts of everyone involved in producing it :)
> > I am under the impression that it is, at least to some extent,
> > automatically generated, so I'm genuinely curious what is it about
> > the .starts-with() method that has caused it to lose its Cool :)
> >
> > ...and, of course, it may turn out that Todd meant something completely
> > different in this particular message and I hijacked the thread...
>
> Ah nevermind, I figured it out. Stupid me!
>
> That *is* what Cool does!
>
> That is the whole purpose Cool - to coerce its invocant to a specific
> type, depending on what method is called. So, yeah, if somebody invokes
> .starts-with() on an object of a type that is derived from Cool, yet is
> not Str, the Cool.starts-with() method will try to coerce the invocant
> itself to Str and, thus, invoke Str.starts-with() :)
>
> 

Re: question about the multi in method

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 06:19:29PM +0300, Peter Pentchev wrote:
> On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> > On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> > perl6-us...@perl.org> wrote:
> > 
> > > Hi All,
> > >
> > > Dumb question:
> > >
> > > Does the "multi" in "multi method" mean there
> > > is more than one way to address a method?
> > >
> > > Or, are the all methods "multi methods".
> > >
> > > If not and the method is a multi, should not the
> > > documentation show all (more than one) the ways of
> > > addressing a multi method?
> > 
> > There are four different types of a function. (both method and sub)
> > 
> > - `multi`
> > - `proto`
> > - `only`
> > - `anon`
> > 
> > A `proto` function is mainly just to declare there will be multiple
> > functions with same name.
> > `multi` is short for "multiple", meaning more than one.
> > `only` is the default, it means there is only one.
> > `anon` is for creating a lambda. (You only need it if you give the function
> > a name.)
> > 
> > Again this applies to both subs and methods.
> > (Also `regex`, `token`, and `rule`. As they are just special methods.)
> > 
> > only sub foo (){}
> > only sub foo (1){} # ERROR: redeclaration
> > # note that `only` is optional, as it is the default.
> > 
> > proto sub bar (|){*}
> > multi sub bar (){}
> > multi sub bar (1){}
> > # note that defining a `proto` function is optional
> > 
> > my $var = anon sub baz (){ 'fuzz' };
> > say baz(); # ERROR: can't find a sub named `baz`
> > say $var(); # fuzz
> > say $var.name; # baz
> 
> I believe, though I'm not sure, that Todd may be referring to one of
> the questions that came up in a longish recent thread, namely the fact
> that the documentation of Str.starts-with() seems to only document it as
> a Str method, while Raku seems to disagree:
> 
> [roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("a")'
> Cannot resolve caller starts-with(Str:U: Str:D); none of these signatures 
> match:
> (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
> Bool)
> (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> (Cool:D: Cool:D $needle, *%_ --> Bool)
> (Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
> (Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> (Str:D: Str:D $needle, *%_ --> Bool)
>   in block  at -e line 1
> 
> [roam@straylight ~]$
> 
> So it seems that Cool has a .starts-with() method too, and this is borne
> out by a further experiment:
> 
> [roam@straylight ~]$ raku -e 'my Cool $x; $x.starts-with("a")'
> Cannot resolve caller starts-with(Cool:U: Str:D); none of these signatures 
> match:
> (Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> 
> Bool)
> (Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
> (Cool:D: Cool:D $needle, *%_ --> Bool)
>   in block  at -e line 1
> 
> [roam@straylight ~]$
> 
> So the truth is that I do not fully understand why the documentation
> does not list .starts-with() as a method for Cool as well as Str: in
> https://docs.raku.org/routine.html "starts-with" is listed as "from
> Str", while there are other methods that are listed as "from Cool, Str",
> e.g. "subst".
> 
> Now, yeah, I understand that Str.starts-with() defines a coercion for
> its $needle argument that means that Cool.starts-with() will never be
> called for an invocant that is either a Str or of any type derived from
> Str, no matter what $needle is - if it is from another Cool-derived
> type, it will be coerced to Str and Str.starts-with() will be called.
> However, should the documentation not mention that another type derived
> from Cool will also have a .starts-with() method?
> 
> Please note that I'm not criticizing the documentation, automatically
> generated or not, or the efforts of everyone involved in producing it :)
> I am under the impression that it is, at least to some extent,
> automatically generated, so I'm genuinely curious what is it about
> the .starts-with() method that has caused it to lose its Cool :)
> 
> ...and, of course, it may turn out that Todd meant something completely
> different in this particular message and I hijacked the thread...

Ah nevermind, I figured it out. Stupid me!

That *is* what Cool does!

That is the whole purpose Cool - to coerce its invocant to a specific
type, depending on what method is called. So, yeah, if somebody invokes
.starts-with() on an object of a type that is derived from Cool, yet is
not Str, the Cool.starts-with() method will try to coerce the invocant
itself to Str and, thus, invoke Str.starts-with() :)

OK, so I get it now, I guess whatever generates the documentation knows
that Cool is way, way special, and knows that there is no point in
describing Cool.starts-with(), since all it does is invoke
Str.starts-with() if there is nothing more specific. Sorry for the
noise... so I learned something today, and, TBH, 

Re: question about the multi in method

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 09:04:45AM -0500, Brad Gilbert wrote:
> On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
> perl6-us...@perl.org> wrote:
> 
> > Hi All,
> >
> > Dumb question:
> >
> > Does the "multi" in "multi method" mean there
> > is more than one way to address a method?
> >
> > Or, are the all methods "multi methods".
> >
> > If not and the method is a multi, should not the
> > documentation show all (more than one) the ways of
> > addressing a multi method?
> 
> There are four different types of a function. (both method and sub)
> 
> - `multi`
> - `proto`
> - `only`
> - `anon`
> 
> A `proto` function is mainly just to declare there will be multiple
> functions with same name.
> `multi` is short for "multiple", meaning more than one.
> `only` is the default, it means there is only one.
> `anon` is for creating a lambda. (You only need it if you give the function
> a name.)
> 
> Again this applies to both subs and methods.
> (Also `regex`, `token`, and `rule`. As they are just special methods.)
> 
> only sub foo (){}
> only sub foo (1){} # ERROR: redeclaration
> # note that `only` is optional, as it is the default.
> 
> proto sub bar (|){*}
> multi sub bar (){}
> multi sub bar (1){}
> # note that defining a `proto` function is optional
> 
> my $var = anon sub baz (){ 'fuzz' };
> say baz(); # ERROR: can't find a sub named `baz`
> say $var(); # fuzz
> say $var.name; # baz

I believe, though I'm not sure, that Todd may be referring to one of
the questions that came up in a longish recent thread, namely the fact
that the documentation of Str.starts-with() seems to only document it as
a Str method, while Raku seems to disagree:

[roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("a")'
Cannot resolve caller starts-with(Str:U: Str:D); none of these signatures match:
(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Cool:D: Cool:D $needle, *%_ --> Bool)
(Str:D: Str:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
(Str:D: Str:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Str:D: Str:D $needle, *%_ --> Bool)
  in block  at -e line 1

[roam@straylight ~]$

So it seems that Cool has a .starts-with() method too, and this is borne
out by a further experiment:

[roam@straylight ~]$ raku -e 'my Cool $x; $x.starts-with("a")'
Cannot resolve caller starts-with(Cool:U: Str:D); none of these signatures 
match:
(Cool:D: Cool:D $needle, :i(:$ignorecase)!, :m(:$ignoremark), *%_ --> Bool)
(Cool:D: Cool:D $needle, :m(:$ignoremark)!, *%_ --> Bool)
(Cool:D: Cool:D $needle, *%_ --> Bool)
  in block  at -e line 1

[roam@straylight ~]$

So the truth is that I do not fully understand why the documentation
does not list .starts-with() as a method for Cool as well as Str: in
https://docs.raku.org/routine.html "starts-with" is listed as "from
Str", while there are other methods that are listed as "from Cool, Str",
e.g. "subst".

Now, yeah, I understand that Str.starts-with() defines a coercion for
its $needle argument that means that Cool.starts-with() will never be
called for an invocant that is either a Str or of any type derived from
Str, no matter what $needle is - if it is from another Cool-derived
type, it will be coerced to Str and Str.starts-with() will be called.
However, should the documentation not mention that another type derived
from Cool will also have a .starts-with() method?

Please note that I'm not criticizing the documentation, automatically
generated or not, or the efforts of everyone involved in producing it :)
I am under the impression that it is, at least to some extent,
automatically generated, so I'm genuinely curious what is it about
the .starts-with() method that has caused it to lose its Cool :)

...and, of course, it may turn out that Todd meant something completely
different in this particular message and I hijacked the thread...

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: question about the multi in method

2020-06-07 Thread Brad Gilbert
There are four different types of a function. (both method and sub)

- `multi`
- `proto`
- `only`
- `anon`

A `proto` function is mainly just to declare there will be multiple
functions with same name.
`multi` is short for "multiple", meaning more than one.
`only` is the default, it means there is only one.
`anon` is for creating a lambda. (You only need it if you give the function
a name.)

Again this applies to both subs and methods.
(Also `regex`, `token`, and `rule`. As they are just special methods.)

only sub foo (){}
only sub foo (1){} # ERROR: redeclaration
# note that `only` is optional, as it is the default.

proto sub bar (|){*}
multi sub bar (){}
multi sub bar (1){}
# note that defining a `proto` function is optional

my $var = anon sub baz (){ 'fuzz' };
say baz(); # ERROR: can't find a sub named `baz`
say $var(); # fuzz
say $var.name; # baz

On Sun, Jun 7, 2020 at 3:15 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> Dumb question:
>
> Does the "multi" in "multi method" mean there
> is more than one way to address a method?
>
> Or, are the all methods "multi methods".
>
> If not and the method is a multi, should not the
> documentation show all (more than one) the ways of
> addressing a multi method?
>
> Many thanks,
> -T
>


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 11:37:43AM +0200, JJ Merelo wrote:
> El dom., 7 jun. 2020 a las 11:32, Peter Pentchev ()
> escribió:
> 
> > On Sun, Jun 07, 2020 at 12:28:36AM -0700, ToddAndMargo via perl6-users
> > wrote:
> > > Hi All,
> > >
> > > Is there a way to do an "if" on "use lib", so
> > > I do not have to keep commenting these back and forth?
> > >
> > > # use lib 'C:/NtUtil', '.';
> > > use lib 'C:/NtUtil', '.', 'K:/NtUtil';
> >
> > "use lib" is evaluated quite early in the program's execution, so to do
> > any interesting things with it, you will need to use a BEGIN phaser
> > (similar to what you might know as a BEGIN block in Perl):
> >
> > =
> > #!/usr/bin/env raku
> >
> > use v6.d;
> >
> > my $path;
> >
> > BEGIN {
> > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> > }
> >
> > use lib $path;
> >
> > use Foo;
> >
> > Foo.new.hello;
> > =
> >
> > Hope that helps!
> >
> > G'luck,
> > Peter
> >
> > --
> > Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
> > PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
> > Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
> >
> 
> Also, you can simply issue different -I arguments when you invoke the
> script; you can put that in a shell or whatever script
> 
> raku -Imy/lib script
> 
> for your own lib
> 
> raku -Iother/lib script
> 
> for other
> 
> (or Windows equivalent). No need to use Raku to change the path, actually.

True, true :)

"Wait, let's take a step back; what are you *really* trying to do?" is
something that my coworkers have learned to expect when they come to me
with a question :) Thanks for calling me out on the same thing here!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: changing name of module

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 02:28:08PM +0100, Richard Hainsworth wrote:
> On 07/06/2020 13:31, Parrot Raiser wrote:
> > Create an updated version, perhaps with an "rk" prefix, (preserving
> > any text alignment, since "p6" and "rk" are the same length), then
> > change the "pk" version simply to invoke the "rk"?
> > 
> > Existing code should continue to work, albeit nanoseconds slower,
> > while new code can be culturally consistent.
> 
> Why nanoseconds slower? (I won't notice them, but why would a name change
> slow things?)
> 
> If alignment is not a concern, then p6 and raku are equivalent?

I believe the idea is that two modules are installed on the user's
machine: the renamed rk-* one and a single-line p6-* shim that only
imports the rk-* one. Thus, other programs that use the p6-* name will
load that first, then load the rk-* one, hence the nanoseconds delay.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: changing name of module

2020-06-07 Thread Richard Hainsworth
Why nanoseconds slower? (I won't notice them, but why would a name 
change slow things?)


If alignment is not a concern, then p6 and raku are equivalent?

On 07/06/2020 13:31, Parrot Raiser wrote:

Create an updated version, perhaps with an "rk" prefix, (preserving
any text alignment, since "p6" and "rk" are the same length), then
change the "pk" version simply to invoke the "rk"?

Existing code should continue to work, albeit nanoseconds slower,
while new code can be culturally consistent.


Re: changing name of module

2020-06-07 Thread Parrot Raiser
Create an updated version, perhaps with an "rk" prefix, (preserving
any text alignment, since "p6" and "rk" are the same length), then
change the "pk" version simply to invoke the "rk"?

Existing code should continue to work, albeit nanoseconds slower,
while new code can be culturally consistent.


changing name of module

2020-06-07 Thread Richard Hainsworth

Hi,

I've written some modules and released them into the Ecosystem. (I don't 
use cpan for raku)


In the past, I have named my modules 'p6-xxx'. So references for zef 
would be git - finanalyst - p6-xxx (loosely speaking).


Now I am considering whether to rename the module to `raku-xxx`

There are three alternatives:

a) leave the module name as before - historical roots.

b) change the name in my github repo, and change the source reference in 
the public ecosystem file 
(https://github.com/Raku/ecosystem/blob/master/META.list).


I don't know what would happen if someone has installed the module using 
zef, and the source changes.


c) leave the old versions of the module with one source, create a new 
repo and bump the version number in the META.json file


Any comments about what might be best practice?

Regards,

Richard


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread JJ Merelo
Also, you can simply issue different -I arguments when you invoke the
script; you can put that in a shell or whatever script

raku -Imy/lib script

for your own lib

raku -Iother/lib script

for other

(or Windows equivalent). No need to use Raku to change the path, actually.

El dom., 7 jun. 2020 a las 11:32, Peter Pentchev ()
escribió:

> On Sun, Jun 07, 2020 at 12:28:36AM -0700, ToddAndMargo via perl6-users
> wrote:
> > Hi All,
> >
> > Is there a way to do an "if" on "use lib", so
> > I do not have to keep commenting these back and forth?
> >
> > # use lib 'C:/NtUtil', '.';
> > use lib 'C:/NtUtil', '.', 'K:/NtUtil';
>
> "use lib" is evaluated quite early in the program's execution, so to do
> any interesting things with it, you will need to use a BEGIN phaser
> (similar to what you might know as a BEGIN block in Perl):
>
> =
> #!/usr/bin/env raku
>
> use v6.d;
>
> my $path;
>
> BEGIN {
> $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
> }
>
> use lib $path;
>
> use Foo;
>
> Foo.new.hello;
> =
>
> Hope that helps!
>
> G'luck,
> Peter
>
> --
> Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
> PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
>


-- 
JJ


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread Peter Pentchev
On Sun, Jun 07, 2020 at 12:28:36AM -0700, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> Is there a way to do an "if" on "use lib", so
> I do not have to keep commenting these back and forth?
> 
> # use lib 'C:/NtUtil', '.';
> use lib 'C:/NtUtil', '.', 'K:/NtUtil';

"use lib" is evaluated quite early in the program's execution, so to do
any interesting things with it, you will need to use a BEGIN phaser
(similar to what you might know as a BEGIN block in Perl):

=
#!/usr/bin/env raku

use v6.d;

my $path;

BEGIN {
$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
}

use lib $path;

use Foo;

Foo.new.hello;
=

Hope that helps!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 01:39, JJ Merelo wrote:
No, there's no else. This if is for using modules with different names. 
If you want to use modules in different paths, it's probably not a good 
idea to call them by the same name. You can call them different names 
(and do a use lib on all paths), or use other mechanisms to 
differentiate them, such as the :api module metadata Check everything 
about that here: 
https://docs.raku.org/language/typesystem#Versioning,_authorship,_and_API_version.



My mock up has the modules in K:\NtUtil.  My
customer will have them in C:\NtUtil.

K:\NtUtil is a Samba network drive so I can see only
one copy of everything in all my Windows Virtual
Machines.

Can I have several "use lib" statements

use lib 'C:\NtUtil", ".";
use lib 'K:\NtUtil';  # if directory does not exist

to use with the "if" statement?


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread JJ Merelo
No, there's no else. This if is for using modules with different names. If
you want to use modules in different paths, it's probably not a good idea
to call them by the same name. You can call them different names (and do a
use lib on all paths), or use other mechanisms to differentiate them, such
as the :api module metadata Check everything about that here:
https://docs.raku.org/language/typesystem#Versioning,_authorship,_and_API_version
.

El dom., 7 jun. 2020 a las 10:21, ToddAndMargo via perl6-users (<
perl6-us...@perl.org>) escribió:

> On 2020-06-07 00:55, ToddAndMargo via perl6-users wrote:
> >>> El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users
> >>> (mailto:perl6-us...@perl.org>>) escribió:
> >>>
> >>> Hi All,
> >>>
> >>> Is there a way to do an "if" on "use lib", so
> >>> I do not have to keep commenting these back and forth?
> >>>
> >>> # use lib 'C:/NtUtil', '.';
> >>> use lib 'C:/NtUtil', '.', 'K:/NtUtil';
> >>>
> >>> Many thanks,
> >>> -T
> >
> > On 2020-06-07 00:41, JJ Merelo wrote:
> >> Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if
> >> Install it with zef install if
> >>
> >> And then...
> >>
> >>
> >> use  if;# activate the :if adverb on use statements
> >>
> >> use  My::Linux::Backend:if($*KERNEL.name  eq  'linux');
> >> use  My::Fallback::Backend:if($*KERNEL.name  ne  'linux');
> >
> > Hi JJ,
> >
> > Thank you!
> >
> > Would show me an example of how to use it
> > with "use lib"?
> >
> > -T
>
> Also, is there an "else" that goes with that?
>


-- 
JJ


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-07 00:55, ToddAndMargo via perl6-users wrote:
El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users 
(mailto:perl6-us...@perl.org>>) escribió:


    Hi All,

    Is there a way to do an "if" on "use lib", so
    I do not have to keep commenting these back and forth?

    # use lib 'C:/NtUtil', '.';
    use lib 'C:/NtUtil', '.', 'K:/NtUtil';

    Many thanks,
    -T


On 2020-06-07 00:41, JJ Merelo wrote:

Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if
Install it with zef install if

And then...


use  if;# activate the :if adverb on use statements

use  My::Linux::Backend:if($*KERNEL.name  eq  'linux');
use  My::Fallback::Backend:if($*KERNEL.name  ne  'linux');


Hi JJ,

Thank you!

Would show me an example of how to use it
with "use lib"?

-T


Also, is there an "else" that goes with that?


question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

Hi All,

Dumb question:

Does the "multi" in "multi method" mean there
is more than one way to address a method?

Or, are the all methods "multi methods".

If not and the method is a multi, should not the
documentation show all (more than one) the ways of
addressing a multi method?

Many thanks,
-T


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users
El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users 
(mailto:perl6-us...@perl.org>>) escribió:


Hi All,

Is there a way to do an "if" on "use lib", so
I do not have to keep commenting these back and forth?

# use lib 'C:/NtUtil', '.';
use lib 'C:/NtUtil', '.', 'K:/NtUtil';

Many thanks,
-T


On 2020-06-07 00:41, JJ Merelo wrote:

Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if
Install it with zef install if

And then...


use  if;# activate the :if adverb on use statements

use  My::Linux::Backend:if($*KERNEL.name  eq  'linux');
use  My::Fallback::Backend:if($*KERNEL.name  ne  'linux');


Hi JJ,

Thank you!

Would show me an example of how to use it
with "use lib"?

-T


Re: Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread JJ Merelo
Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if
Install it with zef install if

And then...



use if; # activate the :if adverb on use statements
use My::Linux::Backend:if($*KERNEL.name eq 'linux');use
My::Fallback::Backend:if($*KERNEL.name ne 'linux');


El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users (<
perl6-us...@perl.org>) escribió:

> Hi All,
>
> Is there a way to do an "if" on "use lib", so
> I do not have to keep commenting these back and forth?
>
> # use lib 'C:/NtUtil', '.';
> use lib 'C:/NtUtil', '.', 'K:/NtUtil';
>
> Many thanks,
> -T
>


-- 
JJ


Is thre a way to do an "if" on "use lib"?

2020-06-07 Thread ToddAndMargo via perl6-users

Hi All,

Is there a way to do an "if" on "use lib", so
I do not have to keep commenting these back and forth?

# use lib 'C:/NtUtil', '.';
use lib 'C:/NtUtil', '.', 'K:/NtUtil';

Many thanks,
-T


Re: I need a GTK pop up with time out

2020-06-07 Thread ToddAndMargo via perl6-users

On 2020-06-04 04:35, Richard Hainsworth wrote:

Todd,

I wrote you one a very long time ago, after a question from you.

The module is called "Inform". Its on the modules site.

Since it was a long time ago, there may be some bit-rot. Let me know if 
there is .


The module should show how to use GTK, and there is a time-out function.

Richard, aka finanalyst

On 04/06/2020 02:55, ToddAndMargo via perl6-users wrote:

Hi All,

Okay, now I know I am pushing it.  Can anyone point me to
an example of a GTK information pop up with a time out
feature?  Or similar?

Many thanks,
-T


Hi Richard,

Some follow questions:

1) where are the directions?  where are the
variable definitions?

in the following:

# my first attempt:
$popup = inform( 'Something cleaver here',
 # :buttons(Dismiss => 'Dismiss Test', 
:Response('Dismissed'))

 # :buttons(Dismiss => 'Dismiss Test'),
 # :buttons( OK=>'OK',b2=>'Not on your life', 
'Cancel'=> "I don't want to")

 :buttons( OK=>'OK Maybe', b2=>'Not on your life' ),
 :timer(5),
 :title("5 second Countdown test"),
 :show-countdown );
print( "popup = <$popup>\n" );
print( "data.response = <$data.response>\n" );


2) why do I have to have more than one button?
`:buttons( OK=>'OK Maybe' )` errors with

  Type check failed in binding to parameter
  '@buttons'; expected Positional but got Pair
  (:OK("OK Maybe"))

3) what is the difference between "buttons" and "response"?
Both of these give two buttons:
  :buttons(Dismiss => 'Dismiss Test', :Response('Dismissed'))

4) why am I getting a weird response:
 popup = >
 data.response = .response>

5) What is popup suppose to show?

6) why is it not dismissing after 5 seconds?

7) why is there no "show-countdown"?


Many thanks,
-T