Re: I reproduced one of the errors!

2020-06-05 Thread Todd Chester via perl6-users




On 2020-06-04 00:08, Peter Pentchev wrote:

On Wed, Jun 03, 2020 at 07:00:53PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-03 02:21, Peter Pentchev wrote:

On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-02 22:15, Peter Pentchev wrote:

On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-01 23:02, Peter Pentchev wrote:

https://docs.raku.org/language/classtut


Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
Connection timed out

Poop!


This is usually some kind of temporary error - something broke down
between your computer and the server. Try again later, it might work.
(it's the Raku docs site, you've used it before, you know it usually
works :)

G'luck,
Peter



Hi Peter,

It is working now.  Thank you.

You would happen to know of a tutorial.  Me and
the documents ... well, lets say they are not
written with the same outcome in mind as perldocs.

Is there a way to write a methods as I would write
a sub and avoiding the class thing?


OK, now I really have to ask, just like other people have.

What exactly do you mean by "method"?

G'luck,
Peter




say "AbCd".lc

abcd

lc would be the method:
multi method lc(Str:D: --> Str:D)


Right. So apart from the & trick that Fernando Santagata showed you (but
see below, it's not really calling a method) and that is neat but has
its drawbacks (like for instance you cannot ask an object if it .can()
do a specific method), you want to call a method on an object.

In general, and the point of this subthread is, methods are not
standalone subroutines; they are defined as part of the whole "variables
have types, those types are called classes, each class defines
the methods that you may call on its variables" object-oriented
programming thing. When you say "method", this is what people think
you're talking about, because, well, this is what "method" kind of means
when one uses it in a conversation about computer programming,
especially when talking about a language with a class-, role-, and
inheritance-based type system.

The trick that Fernando showed you is not really calling a method;
it is a cute way of the Raku syntax to specify the first argument when
calling a subroutine. The subroutine is not a method, it does not show
up in .can() or .^methods or .HOW or any of the way to ask a variable
what methods it supports. Yes, it is possible to define a multi sub that
does different things when called on different types of first argument,
but it is still not a method, it is a subroutine.

A method is something that is tied to a class. For a quick overview of
classes, methods, and the main ideas of object-oriented programming, try
https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/
Also, take another look at https://docs.raku.org/language/classtut -
especially the part "Starting with a class" and onwards.

G'luck,
Peter




Thank you.  I gots some reading in my future


Re: I reproduced one of the errors!

2020-06-04 Thread Peter Pentchev
On Wed, Jun 03, 2020 at 07:00:53PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-03 02:21, Peter Pentchev wrote:
> > On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-02 22:15, Peter Pentchev wrote:
> > > > On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users 
> > > > wrote:
> > > > > On 2020-06-01 23:02, Peter Pentchev wrote:
> > > > > > https://docs.raku.org/language/classtut
> > > > > 
> > > > > Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
> > > > > Connection timed out
> > > > > 
> > > > > Poop!
> > > > 
> > > > This is usually some kind of temporary error - something broke down
> > > > between your computer and the server. Try again later, it might work.
> > > > (it's the Raku docs site, you've used it before, you know it usually
> > > > works :)
> > > > 
> > > > G'luck,
> > > > Peter
> > > > 
> > > 
> > > Hi Peter,
> > > 
> > > It is working now.  Thank you.
> > > 
> > > You would happen to know of a tutorial.  Me and
> > > the documents ... well, lets say they are not
> > > written with the same outcome in mind as perldocs.
> > > 
> > > Is there a way to write a methods as I would write
> > > a sub and avoiding the class thing?
> > 
> > OK, now I really have to ask, just like other people have.
> > 
> > What exactly do you mean by "method"?
> > 
> > G'luck,
> > Peter
> > 
> 
> > say "AbCd".lc
> abcd
> 
> lc would be the method:
> multi method lc(Str:D: --> Str:D)

Right. So apart from the & trick that Fernando Santagata showed you (but
see below, it's not really calling a method) and that is neat but has
its drawbacks (like for instance you cannot ask an object if it .can()
do a specific method), you want to call a method on an object.

In general, and the point of this subthread is, methods are not
standalone subroutines; they are defined as part of the whole "variables
have types, those types are called classes, each class defines
the methods that you may call on its variables" object-oriented
programming thing. When you say "method", this is what people think
you're talking about, because, well, this is what "method" kind of means
when one uses it in a conversation about computer programming,
especially when talking about a language with a class-, role-, and
inheritance-based type system.

The trick that Fernando showed you is not really calling a method;
it is a cute way of the Raku syntax to specify the first argument when
calling a subroutine. The subroutine is not a method, it does not show
up in .can() or .^methods or .HOW or any of the way to ask a variable
what methods it supports. Yes, it is possible to define a multi sub that
does different things when called on different types of first argument,
but it is still not a method, it is a subroutine.

A method is something that is tied to a class. For a quick overview of
classes, methods, and the main ideas of object-oriented programming, try
https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/
Also, take another look at https://docs.raku.org/language/classtut -
especially the part "Starting with a class" and onwards.

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 reproduced one of the errors!

2020-06-03 Thread ToddAndMargo via perl6-users

On 2020-06-03 02:21, Peter Pentchev wrote:

On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-02 22:15, Peter Pentchev wrote:

On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-01 23:02, Peter Pentchev wrote:

https://docs.raku.org/language/classtut


Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
Connection timed out

Poop!


This is usually some kind of temporary error - something broke down
between your computer and the server. Try again later, it might work.
(it's the Raku docs site, you've used it before, you know it usually
works :)

G'luck,
Peter



Hi Peter,

It is working now.  Thank you.

You would happen to know of a tutorial.  Me and
the documents ... well, lets say they are not
written with the same outcome in mind as perldocs.

Is there a way to write a methods as I would write
a sub and avoiding the class thing?


OK, now I really have to ask, just like other people have.

What exactly do you mean by "method"?

G'luck,
Peter



> say "AbCd".lc
abcd

lc would be the method:
multi method lc(Str:D: --> Str:D)


Re: I reproduced one of the errors!

2020-06-03 Thread ToddAndMargo via perl6-users

On 2020-06-03 01:25, Fernando Santagata wrote:
On Wed, Jun 3, 2020 at 10:07 AM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


Is there a way to write a methods as I would write
a sub and avoiding the class thing?


I re-read the whole thread, but I still fail to understand what a 
"method as a sub, avoiding the class thing" is.
Yet, I'm trying a mind-reading trick: when you say "method" perhaps you 
mean a sub you can call using a method call syntax.


Yes


If that's the case, then one may write something like this:

sub f($x) { $x² }

6. # output: 36

Did the trick work?

--
Fernando Santagata



Indeed!  Thank you!

> sub f($x) { $x² }

>
> 6.
36

I just have to add & in from of it.

-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I reproduced one of the errors!

2020-06-03 Thread Peter Pentchev
On Wed, Jun 03, 2020 at 01:12:41PM +0300, Veesh Goldman wrote:
> On Wed, Jun 3, 2020, 12:22 Peter Pentchev  wrote:
> 
> > On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users
> > wrote:
> > > On 2020-06-02 22:15, Peter Pentchev wrote:
> > > > On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users
> > wrote:
> > > > > On 2020-06-01 23:02, Peter Pentchev wrote:
> > > > > > https://docs.raku.org/language/classtut
> > > > >
> > > > > Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
> > > > > Connection timed out
> > > > >
> > > > > Poop!
> > > >
> > > > This is usually some kind of temporary error - something broke down
> > > > between your computer and the server. Try again later, it might work.
> > > > (it's the Raku docs site, you've used it before, you know it usually
> > > > works :)
> > > >
> > > > G'luck,
> > > > Peter
> > > >
> > >
> > > Hi Peter,
> > >
> > > It is working now.  Thank you.
> > >
> > > You would happen to know of a tutorial.  Me and
> > > the documents ... well, lets say they are not
> > > written with the same outcome in mind as perldocs.
> > >
> > > Is there a way to write a methods as I would write
> > > a sub and avoiding the class thing?
> >
> > OK, now I really have to ask, just like other people have.
> >
> > What exactly do you mean by "method"?
> 
> I assume he means a multi method.

Um, that would be kind of recursive, that would still require knowledge
of what a method is. Better to let Todd explain what is meant by
"method" in these messages.

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 reproduced one of the errors!

2020-06-03 Thread Veesh Goldman
I assume he means a multi method.

On Wed, Jun 3, 2020, 12:22 Peter Pentchev  wrote:

> On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users
> wrote:
> > On 2020-06-02 22:15, Peter Pentchev wrote:
> > > On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users
> wrote:
> > > > On 2020-06-01 23:02, Peter Pentchev wrote:
> > > > > https://docs.raku.org/language/classtut
> > > >
> > > > Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
> > > > Connection timed out
> > > >
> > > > Poop!
> > >
> > > This is usually some kind of temporary error - something broke down
> > > between your computer and the server. Try again later, it might work.
> > > (it's the Raku docs site, you've used it before, you know it usually
> > > works :)
> > >
> > > G'luck,
> > > Peter
> > >
> >
> > Hi Peter,
> >
> > It is working now.  Thank you.
> >
> > You would happen to know of a tutorial.  Me and
> > the documents ... well, lets say they are not
> > written with the same outcome in mind as perldocs.
> >
> > Is there a way to write a methods as I would write
> > a sub and avoiding the class thing?
>
> OK, now I really have to ask, just like other people have.
>
> What exactly do you mean by "method"?
>
> 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: I reproduced one of the errors!

2020-06-03 Thread Peter Pentchev
On Wed, Jun 03, 2020 at 01:06:33AM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-02 22:15, Peter Pentchev wrote:
> > On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-01 23:02, Peter Pentchev wrote:
> > > > https://docs.raku.org/language/classtut
> > > 
> > > Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
> > > Connection timed out
> > > 
> > > Poop!
> > 
> > This is usually some kind of temporary error - something broke down
> > between your computer and the server. Try again later, it might work.
> > (it's the Raku docs site, you've used it before, you know it usually
> > works :)
> > 
> > G'luck,
> > Peter
> > 
> 
> Hi Peter,
> 
> It is working now.  Thank you.
> 
> You would happen to know of a tutorial.  Me and
> the documents ... well, lets say they are not
> written with the same outcome in mind as perldocs.
> 
> Is there a way to write a methods as I would write
> a sub and avoiding the class thing?

OK, now I really have to ask, just like other people have.

What exactly do you mean by "method"?

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 reproduced one of the errors!

2020-06-03 Thread Richard Hainsworth




Is there a way to write a methods as I would write
a sub and avoiding the class thing?

-T
I suppose if a sensei were to ask what blue and yellow make - after 
explaining colour mixing in great detail - then get the answer red, 
would the sensei hit her head upon a wall? ... if the aspirant is blind???


Re: I reproduced one of the errors!

2020-06-03 Thread Richard Hainsworth

This is so good as a reply!!!

Makes the tedium of questioning worth paying attention to.

On 02/06/2020 16:41, Parrot Raiser wrote:

I suspect that "methods" were originally distinguished from
"subroutines" because it made the rain-dance about the new cure for
all civilisation's ills and the heartbreak of psoriasis,
Object-Oriented Programming,  look more impressive. After one has seen
a few programming religions launched, the similarities blur the
differences.  Profundity through obscurity always helps the marketing,
because it slows the recognition.

Subroutines are blocks of code that can be used anywhere within a
scope that may be global or local. Methods are a subset of subroutines
that can only be used within a particular scope on particular kinds of
things.


Re: I reproduced one of the errors!

2020-06-03 Thread Fernando Santagata
On Wed, Jun 3, 2020 at 10:07 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Is there a way to write a methods as I would write
> a sub and avoiding the class thing?
>

I re-read the whole thread, but I still fail to understand what a "method
as a sub, avoiding the class thing" is.
Yet, I'm trying a mind-reading trick: when you say "method" perhaps you
mean a sub you can call using a method call syntax.
If that's the case, then one may write something like this:

sub f($x) { $x² }

6. # output: 36

Did the trick work?

-- 
Fernando Santagata


Re: I reproduced one of the errors!

2020-06-03 Thread ToddAndMargo via perl6-users

On 2020-06-02 22:15, Peter Pentchev wrote:

On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-01 23:02, Peter Pentchev wrote:

https://docs.raku.org/language/classtut


Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
Connection timed out

Poop!


This is usually some kind of temporary error - something broke down
between your computer and the server. Try again later, it might work.
(it's the Raku docs site, you've used it before, you know it usually
works :)

G'luck,
Peter



Hi Peter,

It is working now.  Thank you.

You would happen to know of a tutorial.  Me and
the documents ... well, lets say they are not
written with the same outcome in mind as perldocs.

Is there a way to write a methods as I would write
a sub and avoiding the class thing?

-T


Re: I reproduced one of the errors!

2020-06-02 Thread Peter Pentchev
On Tue, Jun 02, 2020 at 07:39:16PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-01 23:02, Peter Pentchev wrote:
> > https://docs.raku.org/language/classtut
> 
> Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
> Connection timed out
> 
> Poop!

This is usually some kind of temporary error - something broke down
between your computer and the server. Try again later, it might work.
(it's the Raku docs site, you've used it before, you know it usually
works :)

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 reproduced one of the errors!

2020-06-02 Thread ToddAndMargo via perl6-users

On 2020-06-01 23:02, Peter Pentchev wrote:

https://docs.raku.org/language/classtut


Error 522 Ray ID: 59d609616954eb79 • 2020-06-03 02:38:12 UTC
Connection timed out

Poop!


Re: I reproduced one of the errors!

2020-06-02 Thread ToddAndMargo via perl6-users

On 2020-06-02 07:04, Andy Bach wrote:
 > Some times methods are great for human readability.  I would like to 
have both in my tool chest.


Not sure that's really answering the question Richard was asking.  I 
believe he was looking for a more specific answer - when would you want 
to use a method vs wanting to use a sub.



Hi Andy,

I have nothing in particular in mind to do
with it yet, but I want the capability.
Methods can be really sweet.

-T


Re: I reproduced one of the errors!

2020-06-02 Thread Peter Pentchev
On Tue, Jun 02, 2020 at 09:34:30PM +0300, Peter Pentchev wrote:
> On Tue, Jun 02, 2020 at 11:41:31AM -0400, Parrot Raiser wrote:
> > I suspect that "methods" were originally distinguished from
> > "subroutines" because it made the rain-dance about the new cure for
> > all civilisation's ills and the heartbreak of psoriasis,
> > Object-Oriented Programming,  look more impressive. After one has seen
> > a few programming religions launched, the similarities blur the
> > differences.  Profundity through obscurity always helps the marketing,
> > because it slows the recognition.
> 
> That... is only if you look at methods purely from an imperative and
> procedural programming perspective :) Once you start thinking about
> message passing or events, things get a little weirder :)

...not to mention that methods do, of course, provide a level of
abstraction that is difficult to achieve with unbound subroutines.
I imagine that you use that every day in Raku programming, either with
smart-matching (the ACCEPTS method is kind of useful there), or with
checking whether lists or arrays are empty (the .Bool method is kind of
useful there), or with outputting values in easy-to-read format
(the .gist method is kind of useful there). All of these would be...
kind of unwieldy to do with subroutines that are not bound to any
object, but have to check what they are called at every step.

> > Subroutines are blocks of code that can be used anywhere within a
> > scope that may be global or local. Methods are a subset of subroutines
> > that can only be used within a particular scope on particular kinds of
> > things.
> 
> ...or so it is in procedural languages, which have their orientation
> towards procedures (another name for subroutines) encoded right there in
> the designation :)
> 
> But that's a wholly different topic, we've abused this thread's subject
> too much already, so I'll stop now :)

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 reproduced one of the errors!

2020-06-02 Thread Peter Pentchev
On Tue, Jun 02, 2020 at 11:41:31AM -0400, Parrot Raiser wrote:
> I suspect that "methods" were originally distinguished from
> "subroutines" because it made the rain-dance about the new cure for
> all civilisation's ills and the heartbreak of psoriasis,
> Object-Oriented Programming,  look more impressive. After one has seen
> a few programming religions launched, the similarities blur the
> differences.  Profundity through obscurity always helps the marketing,
> because it slows the recognition.

That... is only if you look at methods purely from an imperative and
procedural programming perspective :) Once you start thinking about
message passing or events, things get a little weirder :)

> Subroutines are blocks of code that can be used anywhere within a
> scope that may be global or local. Methods are a subset of subroutines
> that can only be used within a particular scope on particular kinds of
> things.

...or so it is in procedural languages, which have their orientation
towards procedures (another name for subroutines) encoded right there in
the designation :)

But that's a wholly different topic, we've abused this thread's subject
too much already, so I'll stop now :)

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 reproduced one of the errors!

2020-06-02 Thread Parrot Raiser
I suspect that "methods" were originally distinguished from
"subroutines" because it made the rain-dance about the new cure for
all civilisation's ills and the heartbreak of psoriasis,
Object-Oriented Programming,  look more impressive. After one has seen
a few programming religions launched, the similarities blur the
differences.  Profundity through obscurity always helps the marketing,
because it slows the recognition.

Subroutines are blocks of code that can be used anywhere within a
scope that may be global or local. Methods are a subset of subroutines
that can only be used within a particular scope on particular kinds of
things.


Re: I reproduced one of the errors!

2020-06-02 Thread Andy Bach
>> Repeating any of this material won't help you. So what is a method to
>> you? How do you think it might be used?

> Some times methods are great for human readability.  I would like to have 
> both in my tool chest.

Not sure that's really answering the question Richard was asking.  I believe he 
was looking for a more specific answer - when would you want to use a method vs 
wanting to use a sub.

It may be just me, but I can see methods as class related subroutines (subs 
with the class object passed as an "unlisted" parameter) or subroutines as 
classless methods.  I'm not sure what you see them as or how you see them as 
different than subs.

From: ToddAndMargo via perl6-users 
Sent: Monday, June 1, 2020 5:49 PM
To: perl6-us...@perl.org 
Subject: Re: I reproduced one of the errors!

On 2020-06-01 15:19, Richard Hainsworth wrote:
> Todd,
>
> You said you asked if you could create your own methods, and that you
> were told 'no'. That was a surprising statement, so I asked about some
> context about who would say such a stupid(?!) thing. Seems like this was
> a half-remembered 'no' somewhere in a cloud . Lets leave it there.

My memory is clear on it.


> You often ask questions that get interesting answers. But rather than
> guessing what you're thinking, perhaps you might explain how you see a
> 'subroutine' differing from a 'method'. If you look at the Raku
> documentation, which I know for you, is like shoving your head in a
> barrel of cold water, you will find quite a few examples of methods,
> subs, blocks, and pointies, together with things called signatures.
> Repeating any of this material won't help you. So what is a method to
> you? How do you think it might be used?
>
> Richard


Some times methods are great for human readability.  I
would like to have both in my tool chest.


Re: I reproduced one of the errors!

2020-06-02 Thread Peter Pentchev
On Tue, Jun 02, 2020 at 08:52:37AM +0300, Peter Pentchev wrote:
> On Mon, Jun 01, 2020 at 01:36:19PM -0700, ToddAndMargo via perl6-users wrote:
[snip]
> > A follow up question:
> > 
> > Is there a booboo in the documentation here?
> > 
> > https://docs.raku.org/routine/starts-with
> > multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
> > :m(:$ignoremark) --> Bool:D)
> > 
> > It says "multi method" but only shows one method.
> > Did they leave something out?
> 
> Mmm, and this is where we come to the original error message :)
> It says that there is a "starts-with()" method in the Str class that
> accepts a "$needle" parameter of the Str:D type, but then (or, rather,
> before that) it says that there is a "starts-with()" method in the Cool
> class that accepts a "$neddle" parameter of the Cool:D type. Since Str
> is derived from Cool, when you call a method on Str Raku will also look
> for this method in Cool. Since the two methods accept parameters of
> different types, they (or at least the method in the child class Str)
> have to be declared as multi methods so Raku knows that a type mismatch
> on the first one that it found does not mean that it should stop
> looking.
> 
> But, hm, why the documentation of the starts-with() method on the page
> that you linked to does not mention that it is also present in Cool is
> indeed an interesting question. Moreover, even the list of methods at
> https://docs.raku.org/routine-method.html says "method starts-with()
> from Str", while other methods such as subst() are listed as "from Cool,
> Str", etc. I honestly don't know what the difference is, I expect it is
> because of some internal details of the implementation of the Str
> method, but I won't be able to look it in the source right now. Maybe
> somebody else could shed some light on that?

OK, so I have a theory. Is it possible that this is because
Str.starts-with() has a coercion of its $needle parameter from Cool, so
whatever is building the documentation deduces (correctly) that
Cool.starts-with() will never be invoked on anything that is Str or is
derived from Str? Still, should the documentation not, well, document
that any class derived from Cool has a starts-with() method?

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 reproduced one of the errors!

2020-06-02 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 01:38:48PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-01 02:21, Peter Pentchev wrote:
> > class Thing {
> > multi method do-things(Int:D $value) {
> > say "A thing can do things with an integer: $value";
> > }
> > 
> > multi method do-things(Rational:D $value) {
> > say "A thing can do things with a rational number: $value";
> > }
> > }
> 
> Hi Peter,
> 
> I have asked this question before.  Is it possible for
> me to create my own methods.  The answer came back as
> "no".
> 
> Did you just demonstrate for me how to create my own
> methods?

Is it possible that you asked whether you could add your own methods to
an already-existing class, like add a "meows()" method to the Str class
that would return the number of occurrences of the substring "meow"?
Because in that case the answer is "in most cases, no, except for some
weirdness that may lead to weird things if it is used in weird ways".

You *can* define your *own* classes and once you define a class, it is
kind of assumed that you will define methods for that class. There is
something like a tutorial (not a reference) at
https://docs.raku.org/language/classtut (note that it starts with
an example that may not be easy to understand right off the bat, but
then in the "Starting with class" section and onwards it explains what
was used in that example point by point).

You can also extend other classes, especially ones that you have
defined. Now there are exceptions: there are some system classes that it
is not easy to extend except using some of the weirdness that
I mentioned in the first paragraph, and I really will not go into that
here.

You can also add roles to most classes using the "does" and "but"
keywords. This is explained in more detail at
https://docs.raku.org/language/typesystem#role but bear in mind that
adding roles to existing classes may cause some already-written code to
behave in unexpected ways and cause difficult-to-find mistakes, so it's
better to either add a role to a specific object or to define a new
class that says "I'm just like that original class, but I also have that
role". Of course, there are always exceptions; there are a few cases
when the so-called "monkey-patching" technique may be put to good use,
and Raku will allow you to that if you really want to, but it really
often leads to difficult-to-find mistakes.

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 reproduced one of the errors!

2020-06-01 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 01:36:19PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-01 02:21, Peter Pentchev wrote:
> > On Mon, Jun 01, 2020 at 01:15:23AM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-05-31 17:13, Peter Pentchev wrote:
> > > > On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:
> > > > > On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via 
> > > > > perl6-users wrote:
> > > > > > On 2020-05-31 04:58, Peter Pentchev wrote:
> > > > > > > > > So my beef is when you feed these guys an undefined
> > > > > > > > > variable, that they needs to tell you it requires
> > > > > > > > > a "defined" variable.  Not a bunch of useless rubbish.
> > > > > > > > > For example (useless rubbish):
> > > > > > > And also... I thought I mentioned this before. You want a more 
> > > > > > > clear
> > > > > > > error message for*one*  *single*  specific case of a "can't find 
> > > > > > > this
> > > > > > > method, did you mean one of these?" error message. I tried to 
> > > > > > > explain
> > > > > > > that this error message is one that is displayed in many cases, 
> > > > > > > not only
> > > > > > > for "you passed an undefined thing, I want a defined thing"; in my
> > > > > > > opinion, it is actually quite helpful in that it actually lists
> > > > > > > the candidates in a "did you mean one of these?" style.
> > > > > > > 
> > > > > > > You want it to be clear if you pass an undefined value where a 
> > > > > > > defined
> > > > > > > value was expected; that would mean that somebody would have to 
> > > > > > > write
> > > > > > > the code to make it check whether it is this very specific case 
> > > > > > > and then
> > > > > > > that code would have to be maintained for years and years. 
> > > > > > > Tomorrow
> > > > > > > you'll say "but can't it give me a more clear message when I pass 
> > > > > > > an
> > > > > > > integer and it expected a string?" and the day after tomorrow 
> > > > > > > you'll say
> > > > > > > "but can't it give me a more clear message when I pass a string 
> > > > > > > and it
> > > > > > > expected a function?".
> > > > > > > 
> > > > > > > The error message says "you passed an object of this type, and I 
> > > > > > > can't
> > > > > > > find this method for this type; here are a couple of types that 
> > > > > > > have
> > > > > > > this method, did you mean one of these?"  It tells you what the 
> > > > > > > types
> > > > > > > are, and it doesn't have to have thousands of special cases. It 
> > > > > > > tells
> > > > > > > you what the types are.
> > > > > > 
> > > > > > Hi  Peter,
> > > > > > 
> > > > > > I like that you in-line and bottom post.  You are a lot
> > > > > > easier to follow.
> > > > > > 
> > > > > > I think are talking at cross purposes.  Let me give an
> > > > > > example:
> > > > > > 
> > > > > > Q: is a "cow" a "Plant"?
> > > > > > A: a "cow" in not a hazel nut
> > > > > > A: a "cow" in not a radish
> > > > > > A: a "cow" in not a carrot
> > > > > > A: a "cow" in not a cabbage
> > > > > > ...
> > > > > > 
> > > > > > Are all of the answers a correct?
> > > > > > Yes.. Evey answer is completely correct.
> > > > > > 
> > > > > > Are any of the answers helpful?
> > > > > > No
> > > > > 
> > > > > Right. So, once again, just as I said, you are only interested in one 
> > > > > of
> > > > > the answers - "Str:U is not a Str:D, you want a Str:D". However, how
> > > > > should Raku know *which* one of the answers you are interested in?
> > > > > Tomorrow you may pass an integer to a function that only accepts 
> > > > > strings
> > > > > and floating-point numbers; should Raku tell you "you must pass a
> > > > > string, not an integer" or "you must pass a floating-point number, not
> > > > > an integer"? Raku doesn't know which one of those you meant.
> > > > 
> > > > ...accepts strings *or* floating-point numbers, of course...
> > > > 
> > > > G'luck,
> > > > Peter
> > > > 
> > > 
> > > 
> > > Hi Peter,
> > > 
> > > I screw up A LOT.  When something REQUIRES "Str:D" and I
> > > send it a "Str:U", I want to be told such.  Not all
> > > the things it can't do, which I see thrashing around the
> > > protuberance of the scrubbary.
> > > 
> > >   starts-with's invocant requires a defined value (Str:D)
> > > 
> > > would be perfect.  Not appreciated is a list of all the
> > > things it can't do.  This makes me have to BOTH troubleshoot
> > > my screw up and the everything it can't do error message.
> > > 
> > > I think what you are trying to do is help me fix my screw
> > > ups, which is of course, much appreciated.  You are trying
> > > to help me understand what the error message means.
> > > 
> > > What I am after in this thread is a better error message.
> > > 
> > > Thank you for all the help and tips.
> > > 
> > > -T
> > > 
> > > p.s believe me, there will be a lot more screw ups on my
> > > part in the future for you to help me fix!  Of that you
> > > can rest assured.
> > 
> > OK, so for the last time :)
> > 

Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-06-01 15:19, Richard Hainsworth wrote:

Todd,




Do you have a favorite primer on creating methods
you could send me a link to?

I am delighted I can do my own methods.  Raku,
now 1002 ways of doing everything!  I do adore Raku!

-T


Guess not.


Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-06-01 15:19, Richard Hainsworth wrote:

Todd,

You said you asked if you could create your own methods, and that you 
were told 'no'. That was a surprising statement, so I asked about some 
context about who would say such a stupid(?!) thing. Seems like this was 
a half-remembered 'no' somewhere in a cloud . Lets leave it there.


My memory is clear on it.


You often ask questions that get interesting answers. But rather than 
guessing what you're thinking, perhaps you might explain how you see a 
'subroutine' differing from a 'method'. If you look at the Raku 
documentation, which I know for you, is like shoving your head in a 
barrel of cold water, you will find quite a few examples of methods, 
subs, blocks, and pointies, together with things called signatures. 
Repeating any of this material won't help you. So what is a method to 
you? How do you think it might be used?


Richard



Some times methods are great for human readability.  I
would like to have both in my tool chest.


Re: I reproduced one of the errors!

2020-06-01 Thread Richard Hainsworth

Todd,

You said you asked if you could create your own methods, and that you 
were told 'no'. That was a surprising statement, so I asked about some 
context about who would say such a stupid(?!) thing. Seems like this was 
a half-remembered 'no' somewhere in a cloud . Lets leave it there.


You often ask questions that get interesting answers. But rather than 
guessing what you're thinking, perhaps you might explain how you see a 
'subroutine' differing from a 'method'. If you look at the Raku 
documentation, which I know for you, is like shoving your head in a 
barrel of cold water, you will find quite a few examples of methods, 
subs, blocks, and pointies, together with things called signatures. 
Repeating any of this material won't help you. So what is a method to 
you? How do you think it might be used?


Richard

On 01/06/2020 22:06, ToddAndMargo via perl6-users wrote:

On 2020-06-01 13:46, Richard Hainsworth wrote:

Todd,

I'd be interested to see where someone said 'no' to creating your own 
methods.


Methods are integral to the whole idea of a class.

It's also clear throughout the Raku documentation that there are methods. 



But for a method, you need a class. Peter put the method in a class.

Do you want a method 'outside' a class? If so, what exactly do you 
think a method outside a class would do?


No idea what you are getting at.  I would just like
to create and run them as I do with subroutines.



Richard



Hi Richard,

I checked my sent bin and I had deleted it back a
years, so it did not show up.   I also checked

https://www.mail-archive.com/perl6-language@perl.org/

And if it is there is is drowned out by so many
other hits.

And I checked my own internal documentation, and
it says a lot about what they are, but not about
creating them (it will now).

So, Rats.  Maybe someone else reading this will
remember.

Do you have a favorite primer on creating methods
you could send me a link to?

I am delighted I can do my own methods.  Raku,
now 1002 ways of doing everything!  I do adore Raku!

-T


Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-06-01 13:46, Richard Hainsworth wrote:

Todd,

I'd be interested to see where someone said 'no' to creating your own 
methods.


Methods are integral to the whole idea of a class.

It's also clear throughout the Raku documentation that there are methods.

But for a method, you need a class. Peter put the method in a class.

Do you want a method 'outside' a class? If so, what exactly do you think 
a method outside a class would do?


No idea what you are getting at.  I would just like
to create and run them as I do with subroutines.



Richard



Hi Richard,

I checked my sent bin and I had deleted it back a
years, so it did not show up.   I also checked

https://www.mail-archive.com/perl6-language@perl.org/

And if it is there is is drowned out by so many
other hits.

And I checked my own internal documentation, and
it says a lot about what they are, but not about
creating them (it will now).

So, Rats.  Maybe someone else reading this will
remember.

Do you have a favorite primer on creating methods
you could send me a link to?

I am delighted I can do my own methods.  Raku,
now 1002 ways of doing everything!  I do adore Raku!

-T


Re: I reproduced one of the errors!

2020-06-01 Thread Richard Hainsworth

Todd,

I'd be interested to see where someone said 'no' to creating your own 
methods.


Methods are integral to the whole idea of a class.

It's also clear throughout the Raku documentation that there are methods.

But for a method, you need a class. Peter put the method in a class.

Do you want a method 'outside' a class? If so, what exactly do you think 
a method outside a class would do?


Richard

On 01/06/2020 21:38, ToddAndMargo via perl6-users wrote:

On 2020-06-01 02:21, Peter Pentchev wrote:

class Thing {
multi method do-things(Int:D $value) {
    say "A thing can do things with an integer: $value";
}

multi method do-things(Rational:D $value) {
    say "A thing can do things with a rational number: $value";
}
}



Hi Peter,

I have asked this question before.  Is it possible for
me to create my own methods.  The answer came back as
"no".

Did you just demonstrate for me how to create my own
methods?

-T


Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-06-01 02:21, Peter Pentchev wrote:

class Thing {
multi method do-things(Int:D $value) {
say "A thing can do things with an integer: $value";
}

multi method do-things(Rational:D $value) {
say "A thing can do things with a rational number: $value";
}
}



Hi Peter,

I have asked this question before.  Is it possible for
me to create my own methods.  The answer came back as
"no".

Did you just demonstrate for me how to create my own
methods?

-T


Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-06-01 02:21, Peter Pentchev wrote:

On Mon, Jun 01, 2020 at 01:15:23AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-31 17:13, Peter Pentchev wrote:

On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:

On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-31 04:58, Peter Pentchev wrote:

So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable.  Not a bunch of useless rubbish.
For example (useless rubbish):

And also... I thought I mentioned this before. You want a more clear
error message for*one*  *single*  specific case of a "can't find this
method, did you mean one of these?" error message. I tried to explain
that this error message is one that is displayed in many cases, not only
for "you passed an undefined thing, I want a defined thing"; in my
opinion, it is actually quite helpful in that it actually lists
the candidates in a "did you mean one of these?" style.

You want it to be clear if you pass an undefined value where a defined
value was expected; that would mean that somebody would have to write
the code to make it check whether it is this very specific case and then
that code would have to be maintained for years and years. Tomorrow
you'll say "but can't it give me a more clear message when I pass an
integer and it expected a string?" and the day after tomorrow you'll say
"but can't it give me a more clear message when I pass a string and it
expected a function?".

The error message says "you passed an object of this type, and I can't
find this method for this type; here are a couple of types that have
this method, did you mean one of these?"  It tells you what the types
are, and it doesn't have to have thousands of special cases. It tells
you what the types are.


Hi  Peter,

I like that you in-line and bottom post.  You are a lot
easier to follow.

I think are talking at cross purposes.  Let me give an
example:

Q: is a "cow" a "Plant"?
A: a "cow" in not a hazel nut
A: a "cow" in not a radish
A: a "cow" in not a carrot
A: a "cow" in not a cabbage
...

Are all of the answers a correct?
Yes.. Evey answer is completely correct.

Are any of the answers helpful?
No


Right. So, once again, just as I said, you are only interested in one of
the answers - "Str:U is not a Str:D, you want a Str:D". However, how
should Raku know *which* one of the answers you are interested in?
Tomorrow you may pass an integer to a function that only accepts strings
and floating-point numbers; should Raku tell you "you must pass a
string, not an integer" or "you must pass a floating-point number, not
an integer"? Raku doesn't know which one of those you meant.


...accepts strings *or* floating-point numbers, of course...

G'luck,
Peter




Hi Peter,

I screw up A LOT.  When something REQUIRES "Str:D" and I
send it a "Str:U", I want to be told such.  Not all
the things it can't do, which I see thrashing around the
protuberance of the scrubbary.

  starts-with's invocant requires a defined value (Str:D)

would be perfect.  Not appreciated is a list of all the
things it can't do.  This makes me have to BOTH troubleshoot
my screw up and the everything it can't do error message.

I think what you are trying to do is help me fix my screw
ups, which is of course, much appreciated.  You are trying
to help me understand what the error message means.

What I am after in this thread is a better error message.

Thank you for all the help and tips.

-T

p.s believe me, there will be a lot more screw ups on my
part in the future for you to help me fix!  Of that you
can rest assured.


OK, so for the last time :)

Imagine the following code:

===

#!/usr/bin/env raku

use v6.d;

class Thing {
multi method do-things(Int:D $value) {
say "A thing can do things with an integer: $value";
}

multi method do-things(Rational:D $value) {
say "A thing can do things with a rational number: $value";
}
}

my Thing:D $thing = Thing.new;

dd $thing;

$thing.do-things(5);
$thing.do-things(3/5);

# And now for the clincher...
$thing.do-things("what?!");

===

Running it on my system does this:

[roam@straylight ~/tmp/v/roam/testwhee]$ raku functions.raku
Thing $thing = Thing.new
A thing can do things with an integer: 5
A thing can do things with a rational number: 0.6
Cannot resolve caller do-things(Thing:D: Str:D); none of these signatures match:
 (Thing: Int:D $value, *%_)
 (Thing: Rational:D $value, *%_)
   in block  at functions.raku line 23

[roam@straylight ~/tmp/v/roam/testwhee]$

In other words, Raku tells me "I don't know which of these methods you want".
It doesn't know.

You say "it should tell me exactly what to do" - well, what exactly
would you like Raku to tell you in this case? Should it assume that you
meant to pass an integer? 

Re: I reproduced one of the errors!

2020-06-01 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 12:26:16PM +0300, Peter Pentchev wrote:
> On Mon, Jun 01, 2020 at 12:21:37PM +0300, Peter Pentchev wrote:
> > On Mon, Jun 01, 2020 at 01:15:23AM -0700, ToddAndMargo via perl6-users 
> > wrote:
[snip]
> > > Hi Peter,
> > > 
> > > I screw up A LOT.

And just in case this part isn't clear: this is fine. We all screw up
a lot. After more than thirty years of programming in more than twenty
different languages, I screw up a lot, all day, every day. I mess up
the syntax, I mess up the order of arguments to library functions that
I use all the time, I mess up the operator precedence... hell, just now,
when writing this simple program with the multi methods, first I forgot
that I had to call Thing.new to get an actual object (I tried with
"Thing()"... yeah, yeah, I also write Python, so sue me :)), and then
I forgot that I need to put "multi" there to define a, well, a multi
method :) And don't get me started on the *real* screw-ups I do now and
then, the ones that sometimes cost the company real money :)

So, yes. Screwing up is part of the game. I don't know a single
programmer who does not screw up every day.

I *really*, *really* like the way Raku handles my simple screw-ups.
Yes, it is a bit verbose sometimes, but it always helps me. Yes,
sometimes I have to think a little bit about what it is trying to tell
me, but then the lightbulb comes on and sometimes I learn something new
about the language :)

And yes, I understand how the verbose, detailed, and technical error
messages may seem a bit arcane to newcomers. Unfortunately, this is a
compromise that needs to be made when writing a compiler for a new
language: do you sit down and try to imagine all the ways that newcomers
will screw up, try to detect them, and try to give very, very helpful
messages, or do you give generic, but verbose messages with a lot of
detail? And, yeah, I know, this is another "trust me when I tell you
this" moment: I've dealt with compilers in other languages that have
tried to be very, very helpful, and while it does make things easy in
the beginning, in time you start to make not-so-simple mistakes and
the compiler doesn't *really* understand what you're trying to do... and
then it sends you on a *real* wild-goose chase by giving you an error
message that has *nothing* to do with the actual problem, because it
assumed that you were trying to do something that you were not.

So... yes. The Raku developers chose to go the detailed, verbose,
technical route. I actually like that. It takes some getting used to,
but once you've got some more accumulated knowledge, it *saves time*.

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 reproduced one of the errors!

2020-06-01 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 12:21:37PM +0300, Peter Pentchev wrote:
> On Mon, Jun 01, 2020 at 01:15:23AM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-31 17:13, Peter Pentchev wrote:
> > > On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:
> > > > On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users 
> > > > wrote:
> > > > > On 2020-05-31 04:58, Peter Pentchev wrote:
> > > > > > > > So my beef is when you feed these guys an undefined
> > > > > > > > variable, that they needs to tell you it requires
> > > > > > > > a "defined" variable.  Not a bunch of useless rubbish.
> > > > > > > > For example (useless rubbish):
> > > > > > And also... I thought I mentioned this before. You want a more clear
> > > > > > error message for*one*  *single*  specific case of a "can't find 
> > > > > > this
> > > > > > method, did you mean one of these?" error message. I tried to 
> > > > > > explain
> > > > > > that this error message is one that is displayed in many cases, not 
> > > > > > only
> > > > > > for "you passed an undefined thing, I want a defined thing"; in my
> > > > > > opinion, it is actually quite helpful in that it actually lists
> > > > > > the candidates in a "did you mean one of these?" style.
> > > > > > 
> > > > > > You want it to be clear if you pass an undefined value where a 
> > > > > > defined
> > > > > > value was expected; that would mean that somebody would have to 
> > > > > > write
> > > > > > the code to make it check whether it is this very specific case and 
> > > > > > then
> > > > > > that code would have to be maintained for years and years. Tomorrow
> > > > > > you'll say "but can't it give me a more clear message when I pass an
> > > > > > integer and it expected a string?" and the day after tomorrow 
> > > > > > you'll say
> > > > > > "but can't it give me a more clear message when I pass a string and 
> > > > > > it
> > > > > > expected a function?".
> > > > > > 
> > > > > > The error message says "you passed an object of this type, and I 
> > > > > > can't
> > > > > > find this method for this type; here are a couple of types that have
> > > > > > this method, did you mean one of these?"  It tells you what the 
> > > > > > types
> > > > > > are, and it doesn't have to have thousands of special cases. It 
> > > > > > tells
> > > > > > you what the types are.
> > > > > 
> > > > > Hi  Peter,
> > > > > 
> > > > > I like that you in-line and bottom post.  You are a lot
> > > > > easier to follow.
> > > > > 
> > > > > I think are talking at cross purposes.  Let me give an
> > > > > example:
> > > > > 
> > > > > Q: is a "cow" a "Plant"?
> > > > > A: a "cow" in not a hazel nut
> > > > > A: a "cow" in not a radish
> > > > > A: a "cow" in not a carrot
> > > > > A: a "cow" in not a cabbage
> > > > > ...
> > > > > 
> > > > > Are all of the answers a correct?
> > > > > Yes.. Evey answer is completely correct.
> > > > > 
> > > > > Are any of the answers helpful?
> > > > > No
> > > > 
> > > > Right. So, once again, just as I said, you are only interested in one of
> > > > the answers - "Str:U is not a Str:D, you want a Str:D". However, how
> > > > should Raku know *which* one of the answers you are interested in?
> > > > Tomorrow you may pass an integer to a function that only accepts strings
> > > > and floating-point numbers; should Raku tell you "you must pass a
> > > > string, not an integer" or "you must pass a floating-point number, not
> > > > an integer"? Raku doesn't know which one of those you meant.
> > > 
> > > ...accepts strings *or* floating-point numbers, of course...
> > > 
> > > G'luck,
> > > Peter
> > > 
> > 
> > 
> > Hi Peter,
> > 
> > I screw up A LOT.  When something REQUIRES "Str:D" and I
> > send it a "Str:U", I want to be told such.  Not all
> > the things it can't do, which I see thrashing around the
> > protuberance of the scrubbary.
> > 
> >  starts-with's invocant requires a defined value (Str:D)
> > 
> > would be perfect.  Not appreciated is a list of all the
> > things it can't do.  This makes me have to BOTH troubleshoot
> > my screw up and the everything it can't do error message.
> > 
> > I think what you are trying to do is help me fix my screw
> > ups, which is of course, much appreciated.  You are trying
> > to help me understand what the error message means.
> > 
> > What I am after in this thread is a better error message.
> > 
> > Thank you for all the help and tips.
> > 
> > -T
> > 
> > p.s believe me, there will be a lot more screw ups on my
> > part in the future for you to help me fix!  Of that you
> > can rest assured.
> 
> OK, so for the last time :)
> 
> Imagine the following code:
> 
> ===
> 
> #!/usr/bin/env raku
> 
> use v6.d;
> 
> class Thing {
>   multi method do-things(Int:D $value) {
>   say "A thing can do things with an integer: $value";
>   }
> 
>   multi method do-things(Rational:D $value) {
>   say "A thing can do 

Re: I reproduced one of the errors!

2020-06-01 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 01:15:23AM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-31 17:13, Peter Pentchev wrote:
> > On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:
> > > On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users 
> > > wrote:
> > > > On 2020-05-31 04:58, Peter Pentchev wrote:
> > > > > > > So my beef is when you feed these guys an undefined
> > > > > > > variable, that they needs to tell you it requires
> > > > > > > a "defined" variable.  Not a bunch of useless rubbish.
> > > > > > > For example (useless rubbish):
> > > > > And also... I thought I mentioned this before. You want a more clear
> > > > > error message for*one*  *single*  specific case of a "can't find this
> > > > > method, did you mean one of these?" error message. I tried to explain
> > > > > that this error message is one that is displayed in many cases, not 
> > > > > only
> > > > > for "you passed an undefined thing, I want a defined thing"; in my
> > > > > opinion, it is actually quite helpful in that it actually lists
> > > > > the candidates in a "did you mean one of these?" style.
> > > > > 
> > > > > You want it to be clear if you pass an undefined value where a defined
> > > > > value was expected; that would mean that somebody would have to write
> > > > > the code to make it check whether it is this very specific case and 
> > > > > then
> > > > > that code would have to be maintained for years and years. Tomorrow
> > > > > you'll say "but can't it give me a more clear message when I pass an
> > > > > integer and it expected a string?" and the day after tomorrow you'll 
> > > > > say
> > > > > "but can't it give me a more clear message when I pass a string and it
> > > > > expected a function?".
> > > > > 
> > > > > The error message says "you passed an object of this type, and I can't
> > > > > find this method for this type; here are a couple of types that have
> > > > > this method, did you mean one of these?"  It tells you what the types
> > > > > are, and it doesn't have to have thousands of special cases. It tells
> > > > > you what the types are.
> > > > 
> > > > Hi  Peter,
> > > > 
> > > > I like that you in-line and bottom post.  You are a lot
> > > > easier to follow.
> > > > 
> > > > I think are talking at cross purposes.  Let me give an
> > > > example:
> > > > 
> > > > Q: is a "cow" a "Plant"?
> > > > A: a "cow" in not a hazel nut
> > > > A: a "cow" in not a radish
> > > > A: a "cow" in not a carrot
> > > > A: a "cow" in not a cabbage
> > > > ...
> > > > 
> > > > Are all of the answers a correct?
> > > > Yes.. Evey answer is completely correct.
> > > > 
> > > > Are any of the answers helpful?
> > > > No
> > > 
> > > Right. So, once again, just as I said, you are only interested in one of
> > > the answers - "Str:U is not a Str:D, you want a Str:D". However, how
> > > should Raku know *which* one of the answers you are interested in?
> > > Tomorrow you may pass an integer to a function that only accepts strings
> > > and floating-point numbers; should Raku tell you "you must pass a
> > > string, not an integer" or "you must pass a floating-point number, not
> > > an integer"? Raku doesn't know which one of those you meant.
> > 
> > ...accepts strings *or* floating-point numbers, of course...
> > 
> > G'luck,
> > Peter
> > 
> 
> 
> Hi Peter,
> 
> I screw up A LOT.  When something REQUIRES "Str:D" and I
> send it a "Str:U", I want to be told such.  Not all
> the things it can't do, which I see thrashing around the
> protuberance of the scrubbary.
> 
>  starts-with's invocant requires a defined value (Str:D)
> 
> would be perfect.  Not appreciated is a list of all the
> things it can't do.  This makes me have to BOTH troubleshoot
> my screw up and the everything it can't do error message.
> 
> I think what you are trying to do is help me fix my screw
> ups, which is of course, much appreciated.  You are trying
> to help me understand what the error message means.
> 
> What I am after in this thread is a better error message.
> 
> Thank you for all the help and tips.
> 
> -T
> 
> p.s believe me, there will be a lot more screw ups on my
> part in the future for you to help me fix!  Of that you
> can rest assured.

OK, so for the last time :)

Imagine the following code:

===

#!/usr/bin/env raku

use v6.d;

class Thing {
multi method do-things(Int:D $value) {
say "A thing can do things with an integer: $value";
}

multi method do-things(Rational:D $value) {
say "A thing can do things with a rational number: $value";
}
}

my Thing:D $thing = Thing.new;

dd $thing;

$thing.do-things(5);
$thing.do-things(3/5);

# And now for the clincher...
$thing.do-things("what?!");

===

Running it on my system does this:

[roam@straylight ~/tmp/v/roam/testwhee]$ raku functions.raku
Thing $thing = Thing.new
A thing can do 

Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-05-31 17:13, Peter Pentchev wrote:

On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:

On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-31 04:58, Peter Pentchev wrote:

So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable.  Not a bunch of useless rubbish.
For example (useless rubbish):

And also... I thought I mentioned this before. You want a more clear
error message for*one*  *single*  specific case of a "can't find this
method, did you mean one of these?" error message. I tried to explain
that this error message is one that is displayed in many cases, not only
for "you passed an undefined thing, I want a defined thing"; in my
opinion, it is actually quite helpful in that it actually lists
the candidates in a "did you mean one of these?" style.

You want it to be clear if you pass an undefined value where a defined
value was expected; that would mean that somebody would have to write
the code to make it check whether it is this very specific case and then
that code would have to be maintained for years and years. Tomorrow
you'll say "but can't it give me a more clear message when I pass an
integer and it expected a string?" and the day after tomorrow you'll say
"but can't it give me a more clear message when I pass a string and it
expected a function?".

The error message says "you passed an object of this type, and I can't
find this method for this type; here are a couple of types that have
this method, did you mean one of these?"  It tells you what the types
are, and it doesn't have to have thousands of special cases. It tells
you what the types are.


Hi  Peter,

I like that you in-line and bottom post.  You are a lot
easier to follow.

I think are talking at cross purposes.  Let me give an
example:

Q: is a "cow" a "Plant"?
A: a "cow" in not a hazel nut
A: a "cow" in not a radish
A: a "cow" in not a carrot
A: a "cow" in not a cabbage
...

Are all of the answers a correct?
Yes.. Evey answer is completely correct.

Are any of the answers helpful?
No


Right. So, once again, just as I said, you are only interested in one of
the answers - "Str:U is not a Str:D, you want a Str:D". However, how
should Raku know *which* one of the answers you are interested in?
Tomorrow you may pass an integer to a function that only accepts strings
and floating-point numbers; should Raku tell you "you must pass a
string, not an integer" or "you must pass a floating-point number, not
an integer"? Raku doesn't know which one of those you meant.


...accepts strings *or* floating-point numbers, of course...

G'luck,
Peter




Hi Peter,

I screw up A LOT.  When something REQUIRES "Str:D" and I
send it a "Str:U", I want to be told such.  Not all
the things it can't do, which I see thrashing around the
protuberance of the scrubbary.

 starts-with's invocant requires a defined value (Str:D)

would be perfect.  Not appreciated is a list of all the
things it can't do.  This makes me have to BOTH troubleshoot
my screw up and the everything it can't do error message.

I think what you are trying to do is help me fix my screw
ups, which is of course, much appreciated.  You are trying
to help me understand what the error message means.

What I am after in this thread is a better error message.

Thank you for all the help and tips.

-T

p.s believe me, there will be a lot more screw ups on my
part in the future for you to help me fix!  Of that you
can rest assured.


Re: I reproduced one of the errors!

2020-06-01 Thread ToddAndMargo via perl6-users

On 2020-05-31 16:21, Peter Pentchev wrote:

On Sun, May 31, 2020 at 04:06:28PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-31 12:48, Veesh Goldman wrote:

well, literally it would mean something like "a direct result of
inability to read is to not understand", which in context should mean if
you can't read you won't understand. But I think the point was made.



Hi Veesh,

Please help me with my reading skills here.

https://docs.raku.org/routine/starts-with

multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
:m(:$ignoremark) --> Bool:D)

Does this or does this not state that the "Haystack"
(invocant) is required to be defined ("Str:D:")?


Yes, it does. Good!


If I am reading it correctly, is requires a "defined"
("D") Haystack (invocant).  Am I misreading something?


No, you're not - or at least, only slightly, see below.


Running a test, the method DO NOT check for defined:

 p6 'my $x; say $x.starts-with( "1" );'
 No such method 'starts-with' for invocant of type
 'Any' in block  at -e line 1
What am I misreading?  Does it say anywhere that the
Haystack in not defined? Does it way anywhere that I
violated the requirement that the Haystack be defined?

And what is "No such method 'starts-with'" suppose to
mean?  I am staring at the method on right on the manual
page.  Did the developers forget to include "opens-with"
on my version of Raku?  Obvious it does not mean what
it says.  Unless my reading skill really suck.


Try it with something slightly different, give Raku something to
work with :)

[roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("1")'
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 ~]$

The difference is that you said "my $x", thus making $x an undefined
variable of the "Any" type (since you did not specify a type), and
I said "my Str $x", thus making $x an undefined string. Once Raku knows
that $x is supposed to be a string, it can look for a .starts-with()
method in the Str class and in all its parent classes - and it finds
some methods in Str and some methods in the class named Cool.


Also, lets add to my reading comprehension, the Needle:
`Str(Cool) $needle`

I do not see "D" or "U" anywhere.  Am I missing something?

A test:
  $ p6 'my $x; say "abc".starts-with( $x );'
  Cannot resolve caller starts-with(Str:D: Any:U);
  none of these signatures match: ...


Hm, this one is interesting. On the one hand, your test was once again
slightly wrong, once again you should have declared $x to be a Str.
On the other hand, even with the corrected test:

[roam@straylight ~]$ raku -e 'my Str $x; dd "abc".starts-with($x);'
Cannot resolve caller starts-with(Str:D: Str:U); 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 ~]$

And here we come to the interesting part: it seems that the
documentation is wrong here, since what Raku says is that the
.starts-with() method of the Str class really wants a `Str:D $needle` -
it does expect its argument to be defined.


Okay, now it tells me "Any:U" for the needle.  It
is telling me that I sent it a undefined value.  To
me, that is a good troubleshooting hint.  Am I
misreading it?


Well, it's actually telling you that you *passed* an Any:U object :)
Yes, it's telling you that it cannot find a method .starts-with() that
will accept an undefined object of the "Any" type as a parameter,
so, yeah, getting close :)


Now what I would "like to see" (suggestion, not a demand),
is the Haystack complain in a similar fashion.  For instance:

 starts-with's invocant requires a defined value (Str:D)

Have I misread anything?


See above - you'll get this if you declare $x as a Str :)
But, yes, you're making progress, great!

G'luck,
Peter



Hi peter,

Close to you too.  The test were deliberate misuse
to slow the result.   This is about how to
troubleshoot what comes back when I screw up.

And the answers coming back are telling me what it
can't do rather than what is wrong.  In other words,
I have to BOTH what did wrong and what the error message
is suppose to mean.

-T


Re: I reproduced one of the errors!

2020-05-31 Thread Peter Pentchev
On Mon, Jun 01, 2020 at 03:12:05AM +0300, Peter Pentchev wrote:
> On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-31 04:58, Peter Pentchev wrote:
> > > > > So my beef is when you feed these guys an undefined
> > > > > variable, that they needs to tell you it requires
> > > > > a "defined" variable.  Not a bunch of useless rubbish.
> > > > > For example (useless rubbish):
> > > And also... I thought I mentioned this before. You want a more clear
> > > error message for*one*  *single*  specific case of a "can't find this
> > > method, did you mean one of these?" error message. I tried to explain
> > > that this error message is one that is displayed in many cases, not only
> > > for "you passed an undefined thing, I want a defined thing"; in my
> > > opinion, it is actually quite helpful in that it actually lists
> > > the candidates in a "did you mean one of these?" style.
> > > 
> > > You want it to be clear if you pass an undefined value where a defined
> > > value was expected; that would mean that somebody would have to write
> > > the code to make it check whether it is this very specific case and then
> > > that code would have to be maintained for years and years. Tomorrow
> > > you'll say "but can't it give me a more clear message when I pass an
> > > integer and it expected a string?" and the day after tomorrow you'll say
> > > "but can't it give me a more clear message when I pass a string and it
> > > expected a function?".
> > > 
> > > The error message says "you passed an object of this type, and I can't
> > > find this method for this type; here are a couple of types that have
> > > this method, did you mean one of these?"  It tells you what the types
> > > are, and it doesn't have to have thousands of special cases. It tells
> > > you what the types are.
> > 
> > Hi Peter,
> > 
> > I like that you in-line and bottom post.  You are a lot
> > easier to follow.
> > 
> > I think are talking at cross purposes.  Let me give an
> > example:
> > 
> > Q: is a "cow" a "Plant"?
> > A: a "cow" in not a hazel nut
> > A: a "cow" in not a radish
> > A: a "cow" in not a carrot
> > A: a "cow" in not a cabbage
> > ...
> > 
> > Are all of the answers a correct?
> > Yes.. Evey answer is completely correct.
> > 
> > Are any of the answers helpful?
> > No
> 
> Right. So, once again, just as I said, you are only interested in one of
> the answers - "Str:U is not a Str:D, you want a Str:D". However, how
> should Raku know *which* one of the answers you are interested in?
> Tomorrow you may pass an integer to a function that only accepts strings
> and floating-point numbers; should Raku tell you "you must pass a
> string, not an integer" or "you must pass a floating-point number, not
> an integer"? Raku doesn't know which one of those you meant.

...accepts strings *or* floating-point numbers, of course...

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 reproduced one of the errors!

2020-05-31 Thread Peter Pentchev
On Sun, May 31, 2020 at 04:29:55PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-31 04:58, Peter Pentchev wrote:
> > > > So my beef is when you feed these guys an undefined
> > > > variable, that they needs to tell you it requires
> > > > a "defined" variable.  Not a bunch of useless rubbish.
> > > > For example (useless rubbish):
> > And also... I thought I mentioned this before. You want a more clear
> > error message for*one*  *single*  specific case of a "can't find this
> > method, did you mean one of these?" error message. I tried to explain
> > that this error message is one that is displayed in many cases, not only
> > for "you passed an undefined thing, I want a defined thing"; in my
> > opinion, it is actually quite helpful in that it actually lists
> > the candidates in a "did you mean one of these?" style.
> > 
> > You want it to be clear if you pass an undefined value where a defined
> > value was expected; that would mean that somebody would have to write
> > the code to make it check whether it is this very specific case and then
> > that code would have to be maintained for years and years. Tomorrow
> > you'll say "but can't it give me a more clear message when I pass an
> > integer and it expected a string?" and the day after tomorrow you'll say
> > "but can't it give me a more clear message when I pass a string and it
> > expected a function?".
> > 
> > The error message says "you passed an object of this type, and I can't
> > find this method for this type; here are a couple of types that have
> > this method, did you mean one of these?"  It tells you what the types
> > are, and it doesn't have to have thousands of special cases. It tells
> > you what the types are.
> 
> Hi Peter,
> 
> I like that you in-line and bottom post.  You are a lot
> easier to follow.
> 
> I think are talking at cross purposes.  Let me give an
> example:
> 
> Q: is a "cow" a "Plant"?
> A: a "cow" in not a hazel nut
> A: a "cow" in not a radish
> A: a "cow" in not a carrot
> A: a "cow" in not a cabbage
> ...
> 
> Are all of the answers a correct?
> Yes.. Evey answer is completely correct.
> 
> Are any of the answers helpful?
> No

Right. So, once again, just as I said, you are only interested in one of
the answers - "Str:U is not a Str:D, you want a Str:D". However, how
should Raku know *which* one of the answers you are interested in?
Tomorrow you may pass an integer to a function that only accepts strings
and floating-point numbers; should Raku tell you "you must pass a
string, not an integer" or "you must pass a floating-point number, not
an integer"? Raku doesn't know which one of those you meant.

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 reproduced one of the errors!

2020-05-31 Thread ToddAndMargo via perl6-users

On 2020-05-31 04:58, Peter Pentchev wrote:

So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable.  Not a bunch of useless rubbish.
For example (useless rubbish):

And also... I thought I mentioned this before. You want a more clear
error message for*one*  *single*  specific case of a "can't find this
method, did you mean one of these?" error message. I tried to explain
that this error message is one that is displayed in many cases, not only
for "you passed an undefined thing, I want a defined thing"; in my
opinion, it is actually quite helpful in that it actually lists
the candidates in a "did you mean one of these?" style.

You want it to be clear if you pass an undefined value where a defined
value was expected; that would mean that somebody would have to write
the code to make it check whether it is this very specific case and then
that code would have to be maintained for years and years. Tomorrow
you'll say "but can't it give me a more clear message when I pass an
integer and it expected a string?" and the day after tomorrow you'll say
"but can't it give me a more clear message when I pass a string and it
expected a function?".

The error message says "you passed an object of this type, and I can't
find this method for this type; here are a couple of types that have
this method, did you mean one of these?"  It tells you what the types
are, and it doesn't have to have thousands of special cases. It tells
you what the types are.


Hi Peter,

I like that you in-line and bottom post.  You are a lot
easier to follow.

I think are talking at cross purposes.  Let me give an
example:

Q: is a "cow" a "Plant"?
A: a "cow" in not a hazel nut
A: a "cow" in not a radish
A: a "cow" in not a carrot
A: a "cow" in not a cabbage
...

Are all of the answers a correct?
Yes.. Evey answer is completely correct.

Are any of the answers helpful?
No

I do believe you are telling me the above answers
are useful.  They may be if a certain sense, but
not at all useful in troubleshooting.

What I am after is:
Q: is a "cow" a "Plant"?
A: No

Now when I code, I spend at least 50% of my time double
checking the validity of what the user entered.  If
I require a windows drive to be in the format of "A:\",
I am going to check that index 0 is "a...z, A..Z", that
index 1 is ":", and that index 2 is "\".  If it fails,
I am going to say why, not give alternate uses of
the invocant: A: a "cow" in not a turnip

Now the manual says (I am not a big fan of the manual,
but I do use it):

https://docs.raku.org/routine/starts-with
multi method starts-with(Str:D: Str(Cool) $needle, 
:i(:$ignorecase), :m(:$ignoremark) --> Bool:D)


It clearly states that the haystack (invocant) is
a defined string (Str:D) and it is required to
be to operate correctly.

The message you get back, does to say anything about
violating the requirement, but just give information
on other uses of the haystack (invocant).

A: a "cow" in not a pepper.
A: a "cow" in not a onion
A: a "cow" in not a pine tree
A: a "cow" in not a tumble weed

What I would like to see (that is a suggestion, not a
demand) come back would be something like:

 starts-with's invocant requires a defined value (Str:D)

Much more useful.  Not a list of all the types the
method can handle. No chasing the wrong rabbit
down the wrong hole.

Thank you for all the help and tips!
-T


A: a "cow" in not a onion
A: a "cow" in not a pine tree

would you please stop?

A: a "cow" in not a tumble weed

NO!  I have 500 more to go!

A: a "cow" in not a tomato
A: a "cow" in not a pot...



DON'T YOU DARE!

atoe



AA Curses on y 


Re: I reproduced one of the errors!

2020-05-31 Thread Peter Pentchev
On Sun, May 31, 2020 at 04:06:28PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-31 12:48, Veesh Goldman wrote:
> > well, literally it would mean something like "a direct result of
> > inability to read is to not understand", which in context should mean if
> > you can't read you won't understand. But I think the point was made.
> 
> 
> Hi Veesh,
> 
> Please help me with my reading skills here.
> 
> https://docs.raku.org/routine/starts-with
> 
> multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
> :m(:$ignoremark) --> Bool:D)
> 
> Does this or does this not state that the "Haystack"
> (invocant) is required to be defined ("Str:D:")?

Yes, it does. Good!

> If I am reading it correctly, is requires a "defined"
> ("D") Haystack (invocant).  Am I misreading something?

No, you're not - or at least, only slightly, see below.

> Running a test, the method DO NOT check for defined:
> 
> p6 'my $x; say $x.starts-with( "1" );'
> No such method 'starts-with' for invocant of type
> 'Any' in block  at -e line 1
> What am I misreading?  Does it say anywhere that the
> Haystack in not defined? Does it way anywhere that I
> violated the requirement that the Haystack be defined?
> 
> And what is "No such method 'starts-with'" suppose to
> mean?  I am staring at the method on right on the manual
> page.  Did the developers forget to include "opens-with"
> on my version of Raku?  Obvious it does not mean what
> it says.  Unless my reading skill really suck.

Try it with something slightly different, give Raku something to
work with :)

[roam@straylight ~]$ raku -e 'my Str $x; $x.starts-with("1")' 
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 ~]$

The difference is that you said "my $x", thus making $x an undefined
variable of the "Any" type (since you did not specify a type), and
I said "my Str $x", thus making $x an undefined string. Once Raku knows
that $x is supposed to be a string, it can look for a .starts-with()
method in the Str class and in all its parent classes - and it finds
some methods in Str and some methods in the class named Cool.

> Also, lets add to my reading comprehension, the Needle:
>`Str(Cool) $needle`
> 
> I do not see "D" or "U" anywhere.  Am I missing something?
> 
> A test:
>  $ p6 'my $x; say "abc".starts-with( $x );'
>  Cannot resolve caller starts-with(Str:D: Any:U);
>  none of these signatures match: ...

Hm, this one is interesting. On the one hand, your test was once again
slightly wrong, once again you should have declared $x to be a Str.
On the other hand, even with the corrected test:

[roam@straylight ~]$ raku -e 'my Str $x; dd "abc".starts-with($x);'
Cannot resolve caller starts-with(Str:D: Str:U); 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 ~]$

And here we come to the interesting part: it seems that the
documentation is wrong here, since what Raku says is that the
.starts-with() method of the Str class really wants a `Str:D $needle` -
it does expect its argument to be defined.

> Okay, now it tells me "Any:U" for the needle.  It
> is telling me that I sent it a undefined value.  To
> me, that is a good troubleshooting hint.  Am I
> misreading it?

Well, it's actually telling you that you *passed* an Any:U object :)
Yes, it's telling you that it cannot find a method .starts-with() that
will accept an undefined object of the "Any" type as a parameter,
so, yeah, getting close :)

> Now what I would "like to see" (suggestion, not a demand),
> is the Haystack complain in a similar fashion.  For instance:
> 
> starts-with's invocant requires a defined value (Str:D)
> 
> Have I misread anything?

See above - you'll get this if you declare $x as a Str :)
But, yes, you're making progress, great!

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 reproduced one of the errors!

2020-05-31 Thread ToddAndMargo via perl6-users

On 2020-05-31 12:48, Veesh Goldman wrote:
well, literally it would mean something like "a direct result of 
inability to read is to not understand", which in context should mean if 
you can't read you won't understand. But I think the point was made.



Hi Veesh,

Please help me with my reading skills here.

https://docs.raku.org/routine/starts-with

multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase), 
:m(:$ignoremark) --> Bool:D)


Does this or does this not state that the "Haystack"
(invocant) is required to be defined ("Str:D:")?

If I am reading it correctly, is requires a "defined"
("D") Haystack (invocant).  Am I misreading something?

Running a test, the method DO NOT check for defined:

p6 'my $x; say $x.starts-with( "1" );'
No such method 'starts-with' for invocant of type
'Any' in block  at -e line 1

What am I misreading?  Does it say anywhere that the
Haystack in not defined? Does it way anywhere that I
violated the requirement that the Haystack be defined?

And what is "No such method 'starts-with'" suppose to
mean?  I am staring at the method on right on the manual
page.  Did the developers forget to include "opens-with"
on my version of Raku?  Obvious it does not mean what
it says.  Unless my reading skill really suck.


Also, lets add to my reading comprehension, the Needle:
   `Str(Cool) $needle`

I do not see "D" or "U" anywhere.  Am I missing something?

A test:
 $ p6 'my $x; say "abc".starts-with( $x );'
 Cannot resolve caller starts-with(Str:D: Any:U);
 none of these signatures match: ...

Okay, now it tells me "Any:U" for the needle.  It
is telling me that I sent it a undefined value.  To
me, that is a good troubleshooting hint.  Am I
misreading it?

Now what I would "like to see" (suggestion, not a demand),
is the Haystack complain in a similar fashion.  For instance:

starts-with's invocant requires a defined value (Str:D)

Have I misread anything?

-T

不十分に書かれている場合、指示は理解するのが困難です


Re: I reproduced one of the errors!

2020-05-31 Thread Veesh Goldman
well, literally it would mean something like "a direct result of inability
to read is to not understand", which in context should mean if you can't
read you won't understand. But I think the point was made.

On Sun, May 31, 2020 at 10:42 PM Elizabeth Mattijsen  wrote:

> I won't understand because I cannot learn to read, so I want everybody to
> adapt to me so that I can enforce my understanding to you
>
> > On 31 May 2020, at 20:40, Richard Hainsworth 
> wrote:
> >
> > Probably more like: I won't understand if I don't read.
> >
> > On 31/05/2020 18:43, ToddAndMargo via perl6-users wrote:
>  On Sun, May 31, 2020, 09:05 Veesh Goldman  > wrote:
> 
>  読めないと分かりませんよ。
> >>
> >> On 2020-05-30 23:15, Veesh Goldman wrote:
> >>> Sorry, my Japanese is mediocre.
> >>> Meant to say that you can't complain about not understanding something
> if you haven't learned how to read it.
> >>>
> >>
> >> Google Translate: "I can't understand if I can't read"
>


Re: I reproduced one of the errors!

2020-05-31 Thread Elizabeth Mattijsen
I won't understand because I cannot learn to read, so I want everybody to adapt 
to me so that I can enforce my understanding to you

> On 31 May 2020, at 20:40, Richard Hainsworth  wrote:
> 
> Probably more like: I won't understand if I don't read.
> 
> On 31/05/2020 18:43, ToddAndMargo via perl6-users wrote:
 On Sun, May 31, 2020, 09:05 Veesh Goldman >>> > wrote:
 
 読めないと分かりませんよ。
>> 
>> On 2020-05-30 23:15, Veesh Goldman wrote:
>>> Sorry, my Japanese is mediocre.
>>> Meant to say that you can't complain about not understanding something if 
>>> you haven't learned how to read it.
>>> 
>> 
>> Google Translate: "I can't understand if I can't read"


Re: I reproduced one of the errors!

2020-05-31 Thread Richard Hainsworth

Probably more like: I won't understand if I don't read.

On 31/05/2020 18:43, ToddAndMargo via perl6-users wrote:
On Sun, May 31, 2020, 09:05 Veesh Goldman > wrote:


    読めないと分かりませんよ。


On 2020-05-30 23:15, Veesh Goldman wrote:

Sorry, my Japanese is mediocre.
Meant to say that you can't complain about not understanding 
something if you haven't learned how to read it.




Google Translate: "I can't understand if I can't read"


Re: I reproduced one of the errors!

2020-05-31 Thread ToddAndMargo via perl6-users
On Sun, May 31, 2020, 09:05 Veesh Goldman > wrote:


読めないと分かりませんよ。


On 2020-05-30 23:15, Veesh Goldman wrote:

Sorry, my Japanese is mediocre.
Meant to say that you can't complain about not understanding something 
if you haven't learned how to read it.




Google Translate: "I can't understand if I can't read"


Re: I reproduced one of the errors!

2020-05-31 Thread Peter Pentchev
On Sun, May 31, 2020 at 02:53:45PM +0300, Peter Pentchev wrote:
> On Sat, May 30, 2020 at 04:22:56PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-30 04:19, Peter Pentchev wrote:
> > > On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users 
> > > wrote:
> > 
> > > > Hi Peter,
> > > > 
> > > > No doubt it is operating as designed.
> > > > 
> > > > It would be a lot more friendly if "Str:U" was
> > > > changed to "Str:D". Oh please!   Oh Please!
> > > 
> > > Sorry, I don't really understand what you mean.  "Str:U" means
> > > an undefined string - that's what you're calling .starts-with() on.
> > > "Str:D" means a defined string - that's what .starts-with() wants to
> > > operate on.  What do you mean "change Str:U to Str:D" - the error
> > > message says "you invoked it on an undefined string, it wants to be
> > > invoked on a defined string", what do you want to change?
> > > 
> > > Now, if you meant "change Str:U to 'an undefined string'", , what
> > > I was trying to explain is that the error message is generic, it covers
> > > any wrong calls of functions on any types... it does not really try to
> > > get into what the types are (it cannot, in the general case for any
> > > other type).
> > > 
> > > G'luck,
> > > Peter
> > > 
> > 
> > 
> > Hi Peter,
> 
> Apologies if what I write further down may come off as a little bit
> brusque. It's just that... see at the end, I'm getting a bit of
> deja vu here :)
> 
> [snip]
> > So my beef is when you feed these guys an undefined
> > variable, that they needs to tell you it requires
> > a "defined" variable.  Not a bunch of useless rubbish.
> > For example (useless rubbish):

And also... I thought I mentioned this before. You want a more clear
error message for *one* *single* specific case of a "can't find this
method, did you mean one of these?" error message. I tried to explain
that this error message is one that is displayed in many cases, not only
for "you passed an undefined thing, I want a defined thing"; in my
opinion, it is actually quite helpful in that it actually lists
the candidates in a "did you mean one of these?" style.

You want it to be clear if you pass an undefined value where a defined
value was expected; that would mean that somebody would have to write
the code to make it check whether it is this very specific case and then
that code would have to be maintained for years and years. Tomorrow
you'll say "but can't it give me a more clear message when I pass an
integer and it expected a string?" and the day after tomorrow you'll say
"but can't it give me a more clear message when I pass a string and it
expected a function?".

The error message says "you passed an object of this type, and I can't
find this method for this type; here are a couple of types that have
this method, did you mean one of these?"  It tells you what the types
are, and it doesn't have to have thousands of special cases. It tells
you what the types are.

> >Cannot resolve caller starts-with(Str:U: Str:D);
> 
> This is not useless rubbish. It says "you tried to call starts-with() on
> something that was an undefined string, and then you passed a defined
> string as a parameter."
> 
> >none of these signatures match
> > 
> >(Cool:D: Cool:D $needle, :i(:$ignorecase)!,
> >:m(:$ignoremark), *%_ --> Bool)
> 
> This is not useless rubbish. It says "you may call starts-with() on
> something that is defined and is of the "Cool" type and pass another
> defined "Cool" thing as a parameter, and then a couple of other
> parameters."
> 
> [snip]
> >(Str:D: Str:D $needle, :i(:$ignorecase)!,
> >:m(:$ignoremark), *%_ --> Bool)
> 
> This is not useless rubbish. It says "you may call starts-with() on
> something that is a defined string, and pass another defined string as a
> parameter, and then maybe a couple of other parameters."
> 
> > And I know, I don't get a vote on the matter.
> 
> It's not that you don't get a vote on the matter. It's that there have
> been several times (let's put it that way) when people have told you
> that to read the Raku documentation and to be able to fully use
> the powers of Raku, it would *really*, *really* help you to figure out
> those pesky signature things.
> 
> 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



-- 
-- 
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 reproduced one of the errors!

2020-05-31 Thread Peter Pentchev
On Sat, May 30, 2020 at 04:22:56PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-30 04:19, Peter Pentchev wrote:
> > On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> 
> > > Hi Peter,
> > > 
> > > No doubt it is operating as designed.
> > > 
> > > It would be a lot more friendly if "Str:U" was
> > > changed to "Str:D". Oh please!   Oh Please!
> > 
> > Sorry, I don't really understand what you mean.  "Str:U" means
> > an undefined string - that's what you're calling .starts-with() on.
> > "Str:D" means a defined string - that's what .starts-with() wants to
> > operate on.  What do you mean "change Str:U to Str:D" - the error
> > message says "you invoked it on an undefined string, it wants to be
> > invoked on a defined string", what do you want to change?
> > 
> > Now, if you meant "change Str:U to 'an undefined string'", , what
> > I was trying to explain is that the error message is generic, it covers
> > any wrong calls of functions on any types... it does not really try to
> > get into what the types are (it cannot, in the general case for any
> > other type).
> > 
> > G'luck,
> > Peter
> > 
> 
> 
> Hi Peter,

Apologies if what I write further down may come off as a little bit
brusque. It's just that... see at the end, I'm getting a bit of
deja vu here :)

[snip]
> So my beef is when you feed these guys an undefined
> variable, that they needs to tell you it requires
> a "defined" variable.  Not a bunch of useless rubbish.
> For example (useless rubbish):
> 
>Cannot resolve caller starts-with(Str:U: Str:D);

This is not useless rubbish. It says "you tried to call starts-with() on
something that was an undefined string, and then you passed a defined
string as a parameter."

>none of these signatures match
> 
>(Cool:D: Cool:D $needle, :i(:$ignorecase)!,
>:m(:$ignoremark), *%_ --> Bool)

This is not useless rubbish. It says "you may call starts-with() on
something that is defined and is of the "Cool" type and pass another
defined "Cool" thing as a parameter, and then a couple of other
parameters."

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

This is not useless rubbish. It says "you may call starts-with() on
something that is a defined string, and pass another defined string as a
parameter, and then maybe a couple of other parameters."

> And I know, I don't get a vote on the matter.

It's not that you don't get a vote on the matter. It's that there have
been several times (let's put it that way) when people have told you
that to read the Raku documentation and to be able to fully use
the powers of Raku, it would *really*, *really* help you to figure out
those pesky signature things.

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 reproduced one of the errors!

2020-05-31 Thread Veesh Goldman
Sorry, my Japanese is mediocre.
Meant to say that you can't complain about not understanding something if
you haven't learned how to read it.

On Sun, May 31, 2020, 09:05 Veesh Goldman  wrote:

> 読めないと分かりませんよ。
>
>
> On Sun, May 31, 2020, 02:23 ToddAndMargo via perl6-users <
> perl6-us...@perl.org> wrote:
>
>> On 2020-05-30 04:19, Peter Pentchev wrote:
>> > On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users
>> wrote:
>>
>> >> Hi Peter,
>> >>
>> >> No doubt it is operating as designed.
>> >>
>> >> It would be a lot more friendly if "Str:U" was
>> >> changed to "Str:D". Oh please!   Oh Please!
>> >
>> > Sorry, I don't really understand what you mean.  "Str:U" means
>> > an undefined string - that's what you're calling .starts-with() on.
>> > "Str:D" means a defined string - that's what .starts-with() wants to
>> > operate on.  What do you mean "change Str:U to Str:D" - the error
>> > message says "you invoked it on an undefined string, it wants to be
>> > invoked on a defined string", what do you want to change?
>> >
>> > Now, if you meant "change Str:U to 'an undefined string'", , what
>> > I was trying to explain is that the error message is generic, it covers
>> > any wrong calls of functions on any types... it does not really try to
>> > get into what the types are (it cannot, in the general case for any
>> > other type).
>> >
>> > G'luck,
>> > Peter
>> >
>>
>>
>> Hi Peter,
>>
>> What a second.
>>
>> https://docs.raku.org/routine/starts-with
>> multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
>> :m(:$ignoremark) --> Bool:D)
>>
>> https://docs.raku.org/routine/contains
>> method contains(Cool:D: |c)
>>
>> I had incorrectly presumed that since neither of
>> these two complained about `Str:D` not being defined
>> that it was specified as `Str:U`
>>
>> So my beef is when you feed these guys an undefined
>> variable, that they needs to tell you it requires
>> a "defined" variable.  Not a bunch of useless rubbish.
>> For example (useless rubbish):
>>
>> 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  ...
>>
>> And I know, I don't get a vote on the matter.
>> -T
>>
>


Re: I reproduced one of the errors!

2020-05-31 Thread Veesh Goldman
読めないと分かりませんよ。


On Sun, May 31, 2020, 02:23 ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2020-05-30 04:19, Peter Pentchev wrote:
> > On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users
> wrote:
>
> >> Hi Peter,
> >>
> >> No doubt it is operating as designed.
> >>
> >> It would be a lot more friendly if "Str:U" was
> >> changed to "Str:D". Oh please!   Oh Please!
> >
> > Sorry, I don't really understand what you mean.  "Str:U" means
> > an undefined string - that's what you're calling .starts-with() on.
> > "Str:D" means a defined string - that's what .starts-with() wants to
> > operate on.  What do you mean "change Str:U to Str:D" - the error
> > message says "you invoked it on an undefined string, it wants to be
> > invoked on a defined string", what do you want to change?
> >
> > Now, if you meant "change Str:U to 'an undefined string'", , what
> > I was trying to explain is that the error message is generic, it covers
> > any wrong calls of functions on any types... it does not really try to
> > get into what the types are (it cannot, in the general case for any
> > other type).
> >
> > G'luck,
> > Peter
> >
>
>
> Hi Peter,
>
> What a second.
>
> https://docs.raku.org/routine/starts-with
> multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
> :m(:$ignoremark) --> Bool:D)
>
> https://docs.raku.org/routine/contains
> method contains(Cool:D: |c)
>
> I had incorrectly presumed that since neither of
> these two complained about `Str:D` not being defined
> that it was specified as `Str:U`
>
> So my beef is when you feed these guys an undefined
> variable, that they needs to tell you it requires
> a "defined" variable.  Not a bunch of useless rubbish.
> For example (useless rubbish):
>
> 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  ...
>
> And I know, I don't get a vote on the matter.
> -T
>


Re: I reproduced one of the errors!

2020-05-30 Thread ToddAndMargo via perl6-users

On 2020-05-30 04:19, Peter Pentchev wrote:

On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users wrote:



Hi Peter,

No doubt it is operating as designed.

It would be a lot more friendly if "Str:U" was
changed to "Str:D". Oh please!   Oh Please!


Sorry, I don't really understand what you mean.  "Str:U" means
an undefined string - that's what you're calling .starts-with() on.
"Str:D" means a defined string - that's what .starts-with() wants to
operate on.  What do you mean "change Str:U to Str:D" - the error
message says "you invoked it on an undefined string, it wants to be
invoked on a defined string", what do you want to change?

Now, if you meant "change Str:U to 'an undefined string'", , what
I was trying to explain is that the error message is generic, it covers
any wrong calls of functions on any types... it does not really try to
get into what the types are (it cannot, in the general case for any
other type).

G'luck,
Peter




Hi Peter,

What a second.

https://docs.raku.org/routine/starts-with
multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase), 
:m(:$ignoremark) --> Bool:D)


https://docs.raku.org/routine/contains
method contains(Cool:D: |c)

I had incorrectly presumed that since neither of
these two complained about `Str:D` not being defined
that it was specified as `Str:U`

So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable.  Not a bunch of useless rubbish.
For example (useless rubbish):

   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  ...

And I know, I don't get a vote on the matter.
-T


Re: I reproduced one of the errors!

2020-05-30 Thread Peter Pentchev
On Fri, May 29, 2020 at 04:36:41PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-28 06:39, Peter Pentchev wrote:
> > On Wed, May 27, 2020 at 03:12:01PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > > On 2020-05-27 14:32, Andy Bach wrote:
> > > > > #!/usr/bin/env raku
> > > > > my Str $x;
> > > > > if $x.starts-with( "[" )  &&
> > > > > $x.contains( "]" )
> > > > > { say "Passed"; } else { say "Failed"; }
> > > > > 
> > > > > K:\Windows\NtUtil>raku Contains.Test.pl6
> > > > > 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 Contains.Test.pl6 line 3
> > > > > 
> > > > >   > The function should just complain that the variable is not 
> > > > > initialized.
> > > > > 
> > > 
> > > 
> > > > Well, it is:
> > > > Cannot resolve caller starts-with(Str:U: Str:D);
> > > > ...
> > > > in block  at Contains.Test.pl6 line 3
> > > > 
> > > > it says:
> > > > For line 3:
> > > > if $x.starts-with( "[" )
> > > > looking for a possible method 'starts-with' with a signature of 2
> > > > params; an undefined string ('Str:U:') and a defined one ('Str:D:')
> > > > failed - here's the list of the possible signatures raku currently has
> > > > ..."
> > > > 
> > > > I'd not be surprise if you could write your own "starts-with(Str:U:
> > > > Str:D); " method in raku and take care of this.  You could probably even
> > > > have it "say"
> > > > You have an undefined String var in this call, not going to be able to
> > > > do much useful matching against that.  Did you forget to initialize
> > > > something?
> > > 
> > > Hi Andy,
> > > 
> > > The function should just complain that you need to feed it an
> > > initialized value instead of sending you on a wild goose chase,
> > 
> > It does say that you are trying to call "starts-with()" as a method on
> > a value of type Str:U (undefined string), and it cannot find such
> > a method. It also tells you what methods it can find.
> > 
> > It gives the same error message no matter what types the function/method
> > can handle and no matter what type you are trying to call it on.
> >  From that point on Raku kind of expects you to know what Str:U means and
> > that the :U part means "undefined". It would give the same *type* of
> > message if you were trying to call a method that only works on undefined
> > strings and you were trying to call it on a defined string, only then it
> > would say that it can't find such a method for Str:D. In the eyes of
> > Raku, these errors are of the same kind, and it has provided you with
> > the types.
> 
> Hi Peter,
> 
> No doubt it is operating as designed.
> 
> It would be a lot more friendly if "Str:U" was
> changed to "Str:D". Oh please!   Oh Please!

Sorry, I don't really understand what you mean.  "Str:U" means
an undefined string - that's what you're calling .starts-with() on.
"Str:D" means a defined string - that's what .starts-with() wants to
operate on.  What do you mean "change Str:U to Str:D" - the error
message says "you invoked it on an undefined string, it wants to be
invoked on a defined string", what do you want to change?

Now, if you meant "change Str:U to 'an undefined string'", , what
I was trying to explain is that the error message is generic, it covers
any wrong calls of functions on any types... it does not really try to
get into what the types are (it cannot, in the general case for any
other type).

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 reproduced one of the errors!

2020-05-29 Thread ToddAndMargo via perl6-users

On 2020-05-28 06:39, Peter Pentchev wrote:

On Wed, May 27, 2020 at 03:12:01PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-27 14:32, Andy Bach wrote:

#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
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 Contains.Test.pl6 line 3

  > The function should just complain that the variable is not initialized.





Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2
params; an undefined string ('Str:U:') and a defined one ('Str:D:')
failed - here's the list of the possible signatures raku currently has
..."

I'd not be surprise if you could write your own "starts-with(Str:U:
Str:D); " method in raku and take care of this.  You could probably even
have it "say"
You have an undefined String var in this call, not going to be able to
do much useful matching against that.  Did you forget to initialize
something?


Hi Andy,

The function should just complain that you need to feed it an
initialized value instead of sending you on a wild goose chase,


It does say that you are trying to call "starts-with()" as a method on
a value of type Str:U (undefined string), and it cannot find such
a method. It also tells you what methods it can find.

It gives the same error message no matter what types the function/method
can handle and no matter what type you are trying to call it on.
 From that point on Raku kind of expects you to know what Str:U means and
that the :U part means "undefined". It would give the same *type* of
message if you were trying to call a method that only works on undefined
strings and you were trying to call it on a defined string, only then it
would say that it can't find such a method for Str:D. In the eyes of
Raku, these errors are of the same kind, and it has provided you with
the types.

G'luck,
Peter




Hi Peter,

No doubt it is operating as designed.

It would be a lot more friendly if "Str:U" was
changed to "Str:D". Oh please!   Oh Please!

Then the error message would be a lot more useful.

-T


Re: I reproduced one of the errors!

2020-05-28 Thread Peter Pentchev
On Wed, May 27, 2020 at 03:12:01PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-27 14:32, Andy Bach wrote:
> > > #!/usr/bin/env raku
> > > my Str $x;
> > > if $x.starts-with( "[" )  &&
> > > $x.contains( "]" )
> > > { say "Passed"; } else { say "Failed"; }
> > > 
> > > K:\Windows\NtUtil>raku Contains.Test.pl6
> > > 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 Contains.Test.pl6 line 3
> > > 
> > >  > The function should just complain that the variable is not initialized.
> > > 
> 
> 
> > Well, it is:
> > Cannot resolve caller starts-with(Str:U: Str:D);
> > ...
> > in block  at Contains.Test.pl6 line 3
> > 
> > it says:
> > For line 3:
> > if $x.starts-with( "[" )
> > looking for a possible method 'starts-with' with a signature of 2
> > params; an undefined string ('Str:U:') and a defined one ('Str:D:')
> > failed - here's the list of the possible signatures raku currently has
> > ..."
> > 
> > I'd not be surprise if you could write your own "starts-with(Str:U:
> > Str:D); " method in raku and take care of this.  You could probably even
> > have it "say"
> > You have an undefined String var in this call, not going to be able to
> > do much useful matching against that.  Did you forget to initialize
> > something?
> 
> Hi Andy,
> 
> The function should just complain that you need to feed it an
> initialized value instead of sending you on a wild goose chase,

It does say that you are trying to call "starts-with()" as a method on
a value of type Str:U (undefined string), and it cannot find such
a method. It also tells you what methods it can find.

It gives the same error message no matter what types the function/method
can handle and no matter what type you are trying to call it on.
From that point on Raku kind of expects you to know what Str:U means and
that the :U part means "undefined". It would give the same *type* of
message if you were trying to call a method that only works on undefined
strings and you were trying to call it on a defined string, only then it
would say that it can't find such a method for Str:D. In the eyes of
Raku, these errors are of the same kind, and it has provided you with
the types.

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 reproduced one of the errors!

2020-05-27 Thread ToddAndMargo via perl6-users

On 2020-05-27 14:32, Andy Bach wrote:

#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
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 Contains.Test.pl6 line 3

 > The function should just complain that the variable is not initialized.





Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2 
params; an undefined string ('Str:U:') and a defined one ('Str:D:') 
failed - here's the list of the possible signatures raku currently has ..."


I'd not be surprise if you could write your own "starts-with(Str:U: 
Str:D); " method in raku and take care of this.  You could probably even 
have it "say"
You have an undefined String var in this call, not going to be able to 
do much useful matching against that.  Did you forget to initialize 
something?


Hi Andy,

The function should just complain that you need to feed it an
initialized value instead of sending you on a wild goose chase,

In that snippet, I deliberately did not initialize the variable
to trigger the weird behavior.

When I first encountered this error, I was testing a similar
uninitialized variable.  I thought it was populated because "say" said 
so.  "say" just had some shadow of another variable I had used to 
populate the uninitialized variable.


The value looked correct.  I spend a lot of time chasing
the wrong rabbit down the wrong rabbit hole.

-T


Re: I reproduced one of the errors!

2020-05-27 Thread Andy Bach
#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }

K:\Windows\NtUtil>raku Contains.Test.pl6
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 Contains.Test.pl6 line 3

>  The function should just complain that the variable is not initialized.

Well, it is:
Cannot resolve caller starts-with(Str:U: Str:D);
...
in block  at Contains.Test.pl6 line 3

it says:
For line 3:
if $x.starts-with( "[" )
looking for a possible method 'starts-with' with a signature of 2 params; an 
undefined string ('Str:U:') and a defined one ('Str:D:') failed - here's the 
list of the possible signatures raku currently has ..."

I'd not be surprise if you could write your own "starts-with(Str:U: Str:D); " 
method in raku and take care of this.  You could probably even have it "say"
You have an undefined String var in this call, not going to be able to do much 
useful matching against that.  Did you forget to initialize something?

____
From: ToddAndMargo via perl6-users 
Sent: Wednesday, May 27, 2020 4:05 PM
To: perl6-users 
Subject: I reproduced one of the errors!

I managed to reproduce one of the errors I was getting.
I specifically did not initialize $x.  If I do, the
error goes away.  In my code, I did a "say $x" and it
said $x had something in it.  That is what threw me off


K:\Windows\NtUtil>raku -v
This is Rakudo version 2020.05.1 built on MoarVM version
2020.05 implementing Raku 6.d.



#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
$x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



K:\Windows\NtUtil>raku Contains.Test.pl6
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 Contains.Test.pl6 line 3


The function should just complain that the variable is
not initialized.



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


I reproduced one of the errors!

2020-05-27 Thread ToddAndMargo via perl6-users

I managed to reproduce one of the errors I was getting.
I specifically did not initialize $x.  If I do, the
error goes away.  In my code, I did a "say $x" and it
said $x had something in it.  That is what threw me off


K:\Windows\NtUtil>raku -v
This is Rakudo version 2020.05.1 built on MoarVM version
2020.05 implementing Raku 6.d.



#!/usr/bin/env raku
my Str $x;
if $x.starts-with( "[" )  &&
   $x.contains( "]" )
{ say "Passed"; } else { say "Failed"; }



K:\Windows\NtUtil>raku Contains.Test.pl6
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 Contains.Test.pl6 line 3


The function should just complain that the variable is
not initialized.



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~