Re: question about the multi in method

2020-06-08 Thread ToddAndMargo via perl6-users

On 2020-06-08 14:43, Mark Devine wrote:

Peter,

I applaud your excellent assistance with Raku.  Et. al. (you know the names)...

Outstanding community!

Mark


He is a force of nature, as are many on this list.


Re: question about the multi in method

2020-06-08 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 02:39:10PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-08 14:12, Peter Pentchev wrote:
> > On Mon, Jun 08, 2020 at 01:28:34PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-06-08 02:45, Richard Hainsworth wrote:
> > > > Ok Todd, let me have a go at this issue.
> > > > 
> > > >   From what I understand, you see 'multi' and think 'there are more than
> > > > one', which leads to the question 'where are they?'
> > > > 
> > > > My understanding of 'multi' is 'there COULD be more than one', which
> > > > leads to the question 'are there any?'
> > > > 
> > > > This is actually a very powerful aspect of Raku.
> > > > 
> > > > There are (as has been stated in this thread) four types of which  multi
> > > > = 'could be more than one' and only = 'only one' .
> > > > 
> > > > If the developer wrote 'only sub' then, no one else could write a sub
> > > > with that name. For a developer of a program or a module, that might be
> > > > OK, because it's unlikely anyone else would need/want to use that name.
> > > > But for a compiler, the probability is reversed. Someone will want to
> > > > use it. That is why in many other languages there are 'reserved words'
> > > > which you are not allowed to use.
> > > > 
> > > > In Raku, if you develop a new type, for example say a quodion, and you
> > > > want to 'add' quodions, then you CAN use + because it can be overloaded.
> > > > It is defined as a multi.
> > > > 
> > > > Or in your most overused example 'needle' can be rewritten to take a
> > > > quodion, which may yield a spectrum of results because that's what
> > > > quodions are for.
> > > > 
> > > > Since needle is defined as a 'multi', if you write a 'needle' method for
> > > > quodions, the needle for strings STILL exists, and Raku will correctly
> > > > call the method you wrote for quodions if a quodion is implied, but call
> > > > the default needle if a string (or any other type) is used.
> > > > 
> > > > Since you have developed the quodion method entirely for your paid
> > > > subscribers, the module is NOT available to the public, so you wont tell
> > > > anyone about it. So it doesn't have to be in the documentation.
> > > > 
> > > > Is this making any sense to you?
> > > > 
> > > > Richard
> > > 
> > > 
> > > Hi Richard,
> > > 
> > > You are perfectly clear and beautifully well written.
> > > You did make me look up "quodion".
> > > 
> > > :-)
> > > 
> > > And I am feeling guilty because I did already know all
> > > this and it looks like you spent a considerable amount of
> > > time getting into my head to formulate an answer that
> > > was perfect for me.
> > > 
> > > Here is the thing.  I have no objecting to the developer
> > > calling something a "multi" or an "only" depending on his
> > > needs.  That is entirely "HIS" call, "NOT" mine.
> > > 
> > > And I hope the above statement ends all the well meaning,
> > > helpful folks who are trying the re-explain the concept
> > > to me.  I got it a LONG time ago.
> > > 
> > > My objection is when there actually exists more than
> > > one and they are not experimental or otherwise hidden
> > > for some reason and are truly, actually part of the
> > > distribution, then they also should be documented.
> > > Updates to the documentation should be part of
> > > the code check in process, and in all probability, are.
> > > 
> > > So, basically what I am saying is when multiples are
> > > there and are open to the public, than it should be
> > > documented.  In this situation, why would the
> > > developer want his hard work hidden?
> > 
> > OK, let me try to give you another example. If I'm too long-winded,
> > there will be an abstract at the end :)
> > 
> > Say somebody is writing a library that should serve as the standard
> > library for the C language. Now, there is a published, adopted standard
> > for the C language that all C compilers and C standard libraries
> > follow[1].
> > 
> > Now, the C language standard says that there may be more than one
> > library - one called "libc" as "the C library" providing pretty much all
> > of the functions, and another one called "libm" as "the mathematics
> > library" providing some additional functions for more-or-less precise
> > mathematical operations[2]. The standard says that the C library must
> > provide a function called printf() that prints out all kinds of things
> > according to a specific format, and that the maths library must provide
> > a function called trunc() that pretty much rounds a real number down to
> > the nearest integer that is not larger than it (so trunc(3.0) would return
> > 3, trunc(4.5) would return 4, and trunc(-3.5) would return -4).
> > 
> > OK... So somebody is writing a "libc" that must provide the printf()
> > function, and they suddenly realize that, in order to be able to print
> > out real numbers with, say, two digits after the decimal point, one of
> > the easiest ways is to have a function that rounds a real number down.
> > 

RE: question about the multi in method

2020-06-08 Thread Mark Devine
Peter,

I applaud your excellent assistance with Raku.  Et. al. (you know the names)...

Outstanding community!

Mark

-Original Message-
From: Peter Pentchev  
Sent: Monday, June 8, 2020 17:13
To: perl6-us...@perl.org
Subject: Re: question about the multi in method

On Mon, Jun 08, 2020 at 01:28:34PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-08 02:45, Richard Hainsworth wrote:
> > Ok Todd, let me have a go at this issue.
> > 
> >  From what I understand, you see 'multi' and think 'there are more 
> > than one', which leads to the question 'where are they?'
> > 
> > My understanding of 'multi' is 'there COULD be more than one', which 
> > leads to the question 'are there any?'
> > 
> > This is actually a very powerful aspect of Raku.
> > 
> > There are (as has been stated in this thread) four types of which  
> > multi = 'could be more than one' and only = 'only one' .
> > 
> > If the developer wrote 'only sub' then, no one else could write a 
> > sub with that name. For a developer of a program or a module, that 
> > might be OK, because it's unlikely anyone else would need/want to use that 
> > name.
> > But for a compiler, the probability is reversed. Someone will want 
> > to use it. That is why in many other languages there are 'reserved words'
> > which you are not allowed to use.
> > 
> > In Raku, if you develop a new type, for example say a quodion, and 
> > you want to 'add' quodions, then you CAN use + because it can be overloaded.
> > It is defined as a multi.
> > 
> > Or in your most overused example 'needle' can be rewritten to take a 
> > quodion, which may yield a spectrum of results because that's what 
> > quodions are for.
> > 
> > Since needle is defined as a 'multi', if you write a 'needle' method 
> > for quodions, the needle for strings STILL exists, and Raku will 
> > correctly call the method you wrote for quodions if a quodion is 
> > implied, but call the default needle if a string (or any other type) is 
> > used.
> > 
> > Since you have developed the quodion method entirely for your paid 
> > subscribers, the module is NOT available to the public, so you wont 
> > tell anyone about it. So it doesn't have to be in the documentation.
> > 
> > Is this making any sense to you?
> > 
> > Richard
> 
> 
> Hi Richard,
> 
> You are perfectly clear and beautifully well written.
> You did make me look up "quodion".
> 
> :-)
> 
> And I am feeling guilty because I did already know all this and it 
> looks like you spent a considerable amount of time getting into my 
> head to formulate an answer that was perfect for me.
> 
> Here is the thing.  I have no objecting to the developer calling 
> something a "multi" or an "only" depending on his needs.  That is 
> entirely "HIS" call, "NOT" mine.
> 
> And I hope the above statement ends all the well meaning, helpful 
> folks who are trying the re-explain the concept to me.  I got it a 
> LONG time ago.
> 
> My objection is when there actually exists more than one and they are 
> not experimental or otherwise hidden for some reason and are truly, 
> actually part of the distribution, then they also should be 
> documented.
> Updates to the documentation should be part of the code check in 
> process, and in all probability, are.
> 
> So, basically what I am saying is when multiples are there and are 
> open to the public, than it should be documented.  In this situation, 
> why would the developer want his hard work hidden?

OK, let me try to give you another example. If I'm too long-winded, there will 
be an abstract at the end :)

Say somebody is writing a library that should serve as the standard library for 
the C language. Now, there is a published, adopted standard for the C language 
that all C compilers and C standard libraries follow[1].

Now, the C language standard says that there may be more than one library - one 
called "libc" as "the C library" providing pretty much all of the functions, 
and another one called "libm" as "the mathematics library" providing some 
additional functions for more-or-less precise mathematical operations[2]. The 
standard says that the C library must provide a function called printf() that 
prints out all kinds of things according to a specific format, and that the 
maths library must provide a function called trunc() that pretty much rounds a 
real number down to the nearest integer that is not larger than it (so 
trunc(3.0) would return 3, trunc(4.5) would return 4, and trunc(-3.5) would 
return -4).

OK... So somebody is writing a "libc" th

Re: question about the multi in method

2020-06-08 Thread ToddAndMargo via perl6-users

On 2020-06-08 14:12, Peter Pentchev wrote:

On Mon, Jun 08, 2020 at 01:28:34PM -0700, ToddAndMargo via perl6-users wrote:

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

Ok Todd, let me have a go at this issue.

  From what I understand, you see 'multi' and think 'there are more than
one', which leads to the question 'where are they?'

My understanding of 'multi' is 'there COULD be more than one', which
leads to the question 'are there any?'

This is actually a very powerful aspect of Raku.

There are (as has been stated in this thread) four types of which  multi
= 'could be more than one' and only = 'only one' .

If the developer wrote 'only sub' then, no one else could write a sub
with that name. For a developer of a program or a module, that might be
OK, because it's unlikely anyone else would need/want to use that name.
But for a compiler, the probability is reversed. Someone will want to
use it. That is why in many other languages there are 'reserved words'
which you are not allowed to use.

In Raku, if you develop a new type, for example say a quodion, and you
want to 'add' quodions, then you CAN use + because it can be overloaded.
It is defined as a multi.

Or in your most overused example 'needle' can be rewritten to take a
quodion, which may yield a spectrum of results because that's what
quodions are for.

Since needle is defined as a 'multi', if you write a 'needle' method for
quodions, the needle for strings STILL exists, and Raku will correctly
call the method you wrote for quodions if a quodion is implied, but call
the default needle if a string (or any other type) is used.

Since you have developed the quodion method entirely for your paid
subscribers, the module is NOT available to the public, so you wont tell
anyone about it. So it doesn't have to be in the documentation.

Is this making any sense to you?

Richard



Hi Richard,

You are perfectly clear and beautifully well written.
You did make me look up "quodion".

:-)

And I am feeling guilty because I did already know all
this and it looks like you spent a considerable amount of
time getting into my head to formulate an answer that
was perfect for me.

Here is the thing.  I have no objecting to the developer
calling something a "multi" or an "only" depending on his
needs.  That is entirely "HIS" call, "NOT" mine.

And I hope the above statement ends all the well meaning,
helpful folks who are trying the re-explain the concept
to me.  I got it a LONG time ago.

My objection is when there actually exists more than
one and they are not experimental or otherwise hidden
for some reason and are truly, actually part of the
distribution, then they also should be documented.
Updates to the documentation should be part of
the code check in process, and in all probability, are.

So, basically what I am saying is when multiples are
there and are open to the public, than it should be
documented.  In this situation, why would the
developer want his hard work hidden?


OK, let me try to give you another example. If I'm too long-winded,
there will be an abstract at the end :)

Say somebody is writing a library that should serve as the standard
library for the C language. Now, there is a published, adopted standard
for the C language that all C compilers and C standard libraries
follow[1].

Now, the C language standard says that there may be more than one
library - one called "libc" as "the C library" providing pretty much all
of the functions, and another one called "libm" as "the mathematics
library" providing some additional functions for more-or-less precise
mathematical operations[2]. The standard says that the C library must
provide a function called printf() that prints out all kinds of things
according to a specific format, and that the maths library must provide
a function called trunc() that pretty much rounds a real number down to
the nearest integer that is not larger than it (so trunc(3.0) would return
3, trunc(4.5) would return 4, and trunc(-3.5) would return -4).

OK... So somebody is writing a "libc" that must provide the printf()
function, and they suddenly realize that, in order to be able to print
out real numbers with, say, two digits after the decimal point, one of
the easiest ways is to have a function that rounds a real number down.
So they write such a function, let's call it printf_trunc(), and they
hide it, they make it internal to the "libc" library, so your programs
can't see it. Right? Everything's fine, there is an internal function
that nobody can access.

So the next thing they do is turn to the maths library, and they realize
that they have to write a trunc() function, and the lightbulb comes on:
they have *already written* a function that rounds a real number down,
but for various reasons that *only matter to the author of the library*,
not to the users of the library, that function needs to live in the
"libc" library, not in the "libm" library.

OK, but they do not want to do the work twice, they do not want to 

Re: question about the multi in method

2020-06-08 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 01:28:34PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-08 02:45, Richard Hainsworth wrote:
> > Ok Todd, let me have a go at this issue.
> > 
> >  From what I understand, you see 'multi' and think 'there are more than
> > one', which leads to the question 'where are they?'
> > 
> > My understanding of 'multi' is 'there COULD be more than one', which
> > leads to the question 'are there any?'
> > 
> > This is actually a very powerful aspect of Raku.
> > 
> > There are (as has been stated in this thread) four types of which  multi
> > = 'could be more than one' and only = 'only one' .
> > 
> > If the developer wrote 'only sub' then, no one else could write a sub
> > with that name. For a developer of a program or a module, that might be
> > OK, because it's unlikely anyone else would need/want to use that name.
> > But for a compiler, the probability is reversed. Someone will want to
> > use it. That is why in many other languages there are 'reserved words'
> > which you are not allowed to use.
> > 
> > In Raku, if you develop a new type, for example say a quodion, and you
> > want to 'add' quodions, then you CAN use + because it can be overloaded.
> > It is defined as a multi.
> > 
> > Or in your most overused example 'needle' can be rewritten to take a
> > quodion, which may yield a spectrum of results because that's what
> > quodions are for.
> > 
> > Since needle is defined as a 'multi', if you write a 'needle' method for
> > quodions, the needle for strings STILL exists, and Raku will correctly
> > call the method you wrote for quodions if a quodion is implied, but call
> > the default needle if a string (or any other type) is used.
> > 
> > Since you have developed the quodion method entirely for your paid
> > subscribers, the module is NOT available to the public, so you wont tell
> > anyone about it. So it doesn't have to be in the documentation.
> > 
> > Is this making any sense to you?
> > 
> > Richard
> 
> 
> Hi Richard,
> 
> You are perfectly clear and beautifully well written.
> You did make me look up "quodion".
> 
> :-)
> 
> And I am feeling guilty because I did already know all
> this and it looks like you spent a considerable amount of
> time getting into my head to formulate an answer that
> was perfect for me.
> 
> Here is the thing.  I have no objecting to the developer
> calling something a "multi" or an "only" depending on his
> needs.  That is entirely "HIS" call, "NOT" mine.
> 
> And I hope the above statement ends all the well meaning,
> helpful folks who are trying the re-explain the concept
> to me.  I got it a LONG time ago.
> 
> My objection is when there actually exists more than
> one and they are not experimental or otherwise hidden
> for some reason and are truly, actually part of the
> distribution, then they also should be documented.
> Updates to the documentation should be part of
> the code check in process, and in all probability, are.
> 
> So, basically what I am saying is when multiples are
> there and are open to the public, than it should be
> documented.  In this situation, why would the
> developer want his hard work hidden?

OK, let me try to give you another example. If I'm too long-winded,
there will be an abstract at the end :)

Say somebody is writing a library that should serve as the standard
library for the C language. Now, there is a published, adopted standard
for the C language that all C compilers and C standard libraries
follow[1].

Now, the C language standard says that there may be more than one
library - one called "libc" as "the C library" providing pretty much all
of the functions, and another one called "libm" as "the mathematics
library" providing some additional functions for more-or-less precise
mathematical operations[2]. The standard says that the C library must
provide a function called printf() that prints out all kinds of things
according to a specific format, and that the maths library must provide
a function called trunc() that pretty much rounds a real number down to
the nearest integer that is not larger than it (so trunc(3.0) would return
3, trunc(4.5) would return 4, and trunc(-3.5) would return -4).

OK... So somebody is writing a "libc" that must provide the printf()
function, and they suddenly realize that, in order to be able to print
out real numbers with, say, two digits after the decimal point, one of
the easiest ways is to have a function that rounds a real number down.
So they write such a function, let's call it printf_trunc(), and they
hide it, they make it internal to the "libc" library, so your programs
can't see it. Right? Everything's fine, there is an internal function
that nobody can access.

So the next thing they do is turn to the maths library, and they realize
that they have to write a trunc() function, and the lightbulb comes on:
they have *already written* a function that rounds a real number down,
but for various reasons that *only matter to the author of the library*,
not 

Re: question about the multi in method

2020-06-08 Thread ToddAndMargo

On 2020-06-08 08:05, Peter Pentchev wrote:

On Mon, Jun 08, 2020 at 10:45:21AM +0100, Richard Hainsworth wrote:

Ok Todd, let me have a go at this issue.


Thank you, Richard, for your help. I apologize to Todd and to everyone
on the list for my outburst in my last e-mail.

G'luck,
Peter




Hi Peter,

I was not offended in the least.  You are a mensch
and I am very, very grateful for your help.  I
also admire your technical skill, writing skill,
and thoughtfulness a great deal.

And I know I can be thick as a stone at times,
so I have to be tolerant of other's frustration
with me.

Wait, did you just get some fan mail from me?  Do I
have to wash my mouth out with soap?  or at
least wash my hands?  AHH 

:-)  :-)  :-)

-T

Why am I writing you again?  I hate when this
happens.  YOU KIDS GET OFF MY LAWN!!!  Is Teddy
still president?  I have a lawn?


Re: question about the multi in method

2020-06-08 Thread ToddAndMargo via perl6-users

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

Ok Todd, let me have a go at this issue.

 From what I understand, you see 'multi' and think 'there are more than 
one', which leads to the question 'where are they?'


My understanding of 'multi' is 'there COULD be more than one', which 
leads to the question 'are there any?'


This is actually a very powerful aspect of Raku.

There are (as has been stated in this thread) four types of which  multi 
= 'could be more than one' and only = 'only one' .


If the developer wrote 'only sub' then, no one else could write a sub 
with that name. For a developer of a program or a module, that might be 
OK, because it's unlikely anyone else would need/want to use that name. 
But for a compiler, the probability is reversed. Someone will want to 
use it. That is why in many other languages there are 'reserved words' 
which you are not allowed to use.


In Raku, if you develop a new type, for example say a quodion, and you 
want to 'add' quodions, then you CAN use + because it can be overloaded. 
It is defined as a multi.


Or in your most overused example 'needle' can be rewritten to take a 
quodion, which may yield a spectrum of results because that's what 
quodions are for.


Since needle is defined as a 'multi', if you write a 'needle' method for 
quodions, the needle for strings STILL exists, and Raku will correctly 
call the method you wrote for quodions if a quodion is implied, but call 
the default needle if a string (or any other type) is used.


Since you have developed the quodion method entirely for your paid 
subscribers, the module is NOT available to the public, so you wont tell 
anyone about it. So it doesn't have to be in the documentation.


Is this making any sense to you?

Richard



Hi Richard,

You are perfectly clear and beautifully well written.
You did make me look up "quodion".

:-)

And I am feeling guilty because I did already know all
this and it looks like you spent a considerable amount of
time getting into my head to formulate an answer that
was perfect for me.

Here is the thing.  I have no objecting to the developer
calling something a "multi" or an "only" depending on his
needs.  That is entirely "HIS" call, "NOT" mine.

And I hope the above statement ends all the well meaning,
helpful folks who are trying the re-explain the concept
to me.  I got it a LONG time ago.

My objection is when there actually exists more than
one and they are not experimental or otherwise hidden
for some reason and are truly, actually part of the
distribution, then they also should be documented.
Updates to the documentation should be part of
the code check in process, and in all probability, are.

So, basically what I am saying is when multiples are
there and are open to the public, than it should be
documented.  In this situation, why would the
developer want his hard work hidden?

I am still marveling at the skill and thoughtfulness
you put into your letter.  Wow!

Feeling guilty,
-T


Re: question about the multi in method

2020-06-08 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 10:45:21AM +0100, Richard Hainsworth wrote:
> Ok Todd, let me have a go at this issue.

Thank you, Richard, for your help. I apologize to Todd and to everyone
on the list for my outburst in my last e-mail.

G'luck,
Peter

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


signature.asc
Description: PGP signature


Re: question about the multi in method

2020-06-08 Thread Richard Hainsworth

Ok Todd, let me have a go at this issue.

From what I understand, you see 'multi' and think 'there are more than 
one', which leads to the question 'where are they?'


My understanding of 'multi' is 'there COULD be more than one', which 
leads to the question 'are there any?'


This is actually a very powerful aspect of Raku.

There are (as has been stated in this thread) four types of which  multi 
= 'could be more than one' and only = 'only one' .


If the developer wrote 'only sub' then, no one else could write a sub 
with that name. For a developer of a program or a module, that might be 
OK, because it's unlikely anyone else would need/want to use that name. 
But for a compiler, the probability is reversed. Someone will want to 
use it. That is why in many other languages there are 'reserved words' 
which you are not allowed to use.


In Raku, if you develop a new type, for example say a quodion, and you 
want to 'add' quodions, then you CAN use + because it can be overloaded. 
It is defined as a multi.


Or in your most overused example 'needle' can be rewritten to take a 
quodion, which may yield a spectrum of results because that's what 
quodions are for.


Since needle is defined as a 'multi', if you write a 'needle' method for 
quodions, the needle for strings STILL exists, and Raku will correctly 
call the method you wrote for quodions if a quodion is implied, but call 
the default needle if a string (or any other type) is used.


Since you have developed the quodion method entirely for your paid 
subscribers, the module is NOT available to the public, so you wont tell 
anyone about it. So it doesn't have to be in the documentation.


Is this making any sense to you?

Richard

On 08/06/2020 09:25, Peter Pentchev wrote:

On Mon, Jun 08, 2020 at 12:12:07AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-06-07 22:39, Peter Pentchev wrote:

I thought I explained that. The Rakudo developers are*never*  finished
with the development of some methods. Somebody*will*  want to extend
them in their own module. The Rakudo developers*want*  to declare some
methods as "multi" to allow the Rakudo users to write Raku programs that
extend some existing classes to make them do interesting things.

You did and I understood it.  Your explanation was well
though out/

What you missed was my point that the developers have a
process for checking in new code.  Part of that process
is updating the documentation.  That is the proper
time for documentation to be updated.  The purpose of
the documentation is not to keep places open for unicorns.

Now you are absolutely correct that the software is NEVER finished.  But
Raku is not a "daily" release to the public.
They exist, but are not released to the general public.
Raku has releases.  When the new release his, the
documentation need to match the release.  It is
all part of the check in process.

Nothing. Needs. To be. Updated.

For the last time. The methods are "multi" for two reasons:
- to allow other parts of Rakudo to use them *internally*
- to allow *module authors* and *application writers* like you and me
   to extend them in our own classes

Both of these are very valid reasons to declare some methods as "multi".

Nothing needs to change in the documentation.


What did you learn from going to Github? That you may call
.starts-with() without the :i or :m parameters? Was that not written in
the documentation? Or that you may call .starts-with() with a $needle
being Cool and not Str? Again, was that not written in the
documentation? So what did you learn from going to Github that was not
in the documentation?

Nothing I remember.  But that was not my point.

What is your point then? What *exactly* is lacking in the documetation
of the Str.starts-with() method, *and why*? Examples, please.
And no, *don't* say "the internal method without the :i and :m" without
explaining *why* you want it to be "documented".

G'luck,
Peter



Re: question about the multi in method

2020-06-08 Thread Fernando Santagata
On Mon, Jun 8, 2020 at 10:15 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2020-06-08 00:48, Fernando Santagata wrote:
> > On Mon, Jun 8, 2020 at 9:12 AM ToddAndMargo via perl6-users
> > mailto:perl6-us...@perl.org>> wrote:
> >
> > On 2020-06-07 22:39, Peter Pentchev wrote:
> >> I addressed this in my original e-mail: the documentation is
> > currently:
> >> 1. a reference manual
> >
> > Targets at what audience?
> >
> > I think that that point has been stressed countless times: you
> > probably want a User Manual, not a Reference. The online Reference is
> > well written and it's what most people need. To learn more about Raku
> > please refer to the numerous books on the topic:
> >
> > https://perl6book.com/ https://raku.org/resources/
>
> User Manual and Reference Manual are synonyms.  Or
> as the Raku web site calls it: Documentation.
>

As far as I remember there were times when manuals were printed on real
paper and the Reference Manual was a dry thing used - well - as a
reference, while the User Manual addressed task-based topics.

For example, the User Manual would address the task of how to compile,
link, and run a simple program, while the Reference Manual would list all
the possible command line switches.

-- 
Fernando Santagata


Re: question about the multi in method

2020-06-08 Thread Peter Pentchev
On Mon, Jun 08, 2020 at 12:12:07AM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-07 22:39, Peter Pentchev wrote:
> > I thought I explained that. The Rakudo developers are*never*  finished
> > with the development of some methods. Somebody*will*  want to extend
> > them in their own module. The Rakudo developers*want*  to declare some
> > methods as "multi" to allow the Rakudo users to write Raku programs that
> > extend some existing classes to make them do interesting things.
> 
> You did and I understood it.  Your explanation was well
> though out/
> 
> What you missed was my point that the developers have a
> process for checking in new code.  Part of that process
> is updating the documentation.  That is the proper
> time for documentation to be updated.  The purpose of
> the documentation is not to keep places open for unicorns.
> 
> Now you are absolutely correct that the software is NEVER finished.  But
> Raku is not a "daily" release to the public.
> They exist, but are not released to the general public.
> Raku has releases.  When the new release his, the
> documentation need to match the release.  It is
> all part of the check in process.

Nothing. Needs. To be. Updated.

For the last time. The methods are "multi" for two reasons:
- to allow other parts of Rakudo to use them *internally*
- to allow *module authors* and *application writers* like you and me
  to extend them in our own classes

Both of these are very valid reasons to declare some methods as "multi".

Nothing needs to change in the documentation.

> > What did you learn from going to Github? That you may call
> > .starts-with() without the :i or :m parameters? Was that not written in
> > the documentation? Or that you may call .starts-with() with a $needle
> > being Cool and not Str? Again, was that not written in the
> > documentation? So what did you learn from going to Github that was not
> > in the documentation?
> 
> Nothing I remember.  But that was not my point.

What is your point then? What *exactly* is lacking in the documetation
of the Str.starts-with() method, *and why*? Examples, please.
And no, *don't* say "the internal method without the :i and :m" without
explaining *why* you want it to be "documented".

G'luck,
Peter

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


signature.asc
Description: PGP signature


Re: question about the multi in method

2020-06-08 Thread ToddAndMargo via perl6-users

On 2020-06-08 00:48, Fernando Santagata wrote:
On Mon, Jun 8, 2020 at 9:12 AM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


On 2020-06-07 22:39, Peter Pentchev wrote:

I addressed this in my original e-mail: the documentation is

currently:

1. a reference manual


Targets at what audience?


I think that that point has been stressed countless times: you
probably want a User Manual, not a Reference. The online Reference is
well written and it's what most people need. To learn more about Raku
please refer to the numerous books on the topic:

https://perl6book.com/ https://raku.org/resources/



User Manual and Reference Manual are synonyms.  Or
as the Raku web site calls it: Documentation.

The "online documentation" (not reference, if we are
slicing the baloney real thin) is what I am complaining
about.  It is not useful to beginners.

I have seen a lot of programming reference in my day.
I do not remember any one of them deliberately trying
to go over users heads.  (Does not mean they did not
at times, but it was not on purpose.)

By the way, I do use any reference I can get my hands
on.  Duck Duck Go and Google get hit a lot. And I
always have the documentation open in a window and
frequently refer to it.  And when I have to figure
out something the hard way, I write it down.  You
will see me posts these here at times.


Re: question about the multi in method

2020-06-08 Thread Fernando Santagata
On Mon, Jun 8, 2020 at 9:12 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2020-06-07 22:39, Peter Pentchev wrote:
> > I addressed this in my original e-mail: the documentation is currently:
> > 1. a reference manual
>
> Targets at what audience?
>

I think that that point has been stressed countless times: you probably
want a User Manual, not a Reference.
The online Reference is well written and it's what most people need. To
learn more about Raku please refer to the numerous books on the topic:

https://perl6book.com/
https://raku.org/resources/

-- 
Fernando Santagata


Re: question about the multi in method

2020-06-08 Thread ToddAndMargo via perl6-users

On 2020-06-07 22:39, Peter Pentchev wrote:

I thought I explained that. The Rakudo developers are*never*  finished
with the development of some methods. Somebody*will*  want to extend
them in their own module. The Rakudo developers*want*  to declare some
methods as "multi" to allow the Rakudo users to write Raku programs that
extend some existing classes to make them do interesting things.


You did and I understood it.  Your explanation was well
though out/

What you missed was my point that the developers have a
process for checking in new code.  Part of that process
is updating the documentation.  That is the proper
time for documentation to be updated.  The purpose of
the documentation is not to keep places open for unicorns.

Now you are absolutely correct that the software is NEVER finished.  But 
Raku is not a "daily" release to the public.

They exist, but are not released to the general public.
Raku has releases.  When the new release his, the
documentation need to match the release.  It is
all part of the check in process.




What did you learn from going to Github? That you may call
.starts-with() without the :i or :m parameters? Was that not written in
the documentation? Or that you may call .starts-with() with a $needle
being Cool and not Str? Again, was that not written in the
documentation? So what did you learn from going to Github that was not
in the documentation?


Nothing I remember.  But that was not my point.


I addressed this in my original e-mail: the documentation is currently:
1. a reference manual


Targets at what audience?


2. some tutorials with more being written.


Always appreciated.


Yes, the documentation needs more work. Yes, it is being worked on.


But for what target audience?


The Perl 5 documentation has been worked on for literally 20 more years
than the Raku one. 


Good point.  Although I do not see the target audience
being altered for both the beginner and the advanced
user.  Just the advanced user that already know how to
use it and don't need it, except for a refresher.

Reminds me of that saying bad teachers in college use to
use: "It is intuitively obvious and let up to the student
figure out."

I love your writing by the way.

-T


Re: question about the multi in method

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

Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

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

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

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

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

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


Hi All,

Dumb question:

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

Or, are the all methods "multi methods".

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


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

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


[snip]


Please note that I'm not criticizing the documentation,


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


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

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

G'luck,
Peter




Hi Peter,

Pretty close.

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

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

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

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

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

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

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

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

JJ closed the ticket with the following answer:

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


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

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


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

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

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


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

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


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


So what do we see here?

- first, we see a method that accepts a string 

Re: question about the multi in method

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

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

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

Re: question about the multi in method

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

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

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

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

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

Let's go back to that 

Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

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

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


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

:-)


Re: question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

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

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

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


Hi All,

Dumb question:

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

Or, are the all methods "multi methods".

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


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

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

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

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

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

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

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


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

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

[roam@straylight ~]$

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

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

[roam@straylight ~]$

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

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

Please note that I'm not criticizing the documentation, 


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


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

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

G'luck,
Peter




Hi Peter,

Pretty close.

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

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

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

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

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

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

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

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

JJ closed the ticket with the following answer:

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

Re: question about the multi in method

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

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

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

Re: question about the multi in method

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

Ah nevermind, I figured it out. Stupid me!

That *is* what Cool does!

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

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

Re: question about the multi in method

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

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

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

[roam@straylight ~]$

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

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

[roam@straylight ~]$

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

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

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

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

G'luck,
Peter

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


signature.asc
Description: PGP signature


Re: question about the multi in method

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

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

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

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

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

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

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

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

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


question about the multi in method

2020-06-07 Thread ToddAndMargo via perl6-users

Hi All,

Dumb question:

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

Or, are the all methods "multi methods".

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

Many thanks,
-T