classes and objects questions

2020-12-14 Thread ToddAndMargo via perl6-users

Hi All,

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

 "A tutorial about creating and using classes
 in Raku"

So far so good.

 "Raku has a rich built-in syntax for defining
 and using classes."

U. Forgot something did we?  What is a "class"?


Next up:

 "A default constructor allows the setting of
 attributes for the created object:"

U.  Forgot something else, did we?  What is
an "object"?


The "tutorial" leaves "class" and "object" up to
the reader to guess at from what looks like an
interesting example.


But, again forgetting things, The tutorial also
leaves the syntax up for guess work as well.  Not
described are "$.", "$!", ":$", ^$" what are they
and what are the rules for using them.

Next up:

 my $r = Rectangle.new(
  lower => Point.new(x => 0, y => 0),
  upper => Point.new(x => 10, y => 10));


Why are we using ".new"?

Why are we using the syntax for a hash (=>)?

And:
 $!upper.x

What is the rules and purpose for such?  Why
the "!" and why the "."?


I do realize the documentation is not meant for
beginners, but rather a refresher for advanced
users that do not need it, but this link definitely
said "tutorial" -- fifth word in.

Would some kind soul please fill in the missing
parts of the "tutorial" for me?

Many thanks,
-T


Re: classes and objects questions

2020-12-14 Thread Aureliano Guedes
Hi Todd,

I'm a computational biologist and my knowledge is limited to what I need to
do data science and data analysis in my field.

So far, after a few years, I developed a very shy ability in programming
languages. Luckily, having Perl 5 as my first love.
Perhaps, at the time I was able to use Moose to support OO. Then I had to
do a job with Python and I didn't know the language itself at the time.
Perhaps, nowadays I have skills enough to Perl/Python/R also C/C++, but I
still missing skills in Raku, perhaps by the time or perhaps because I have
some language addiction.

But, as far I follow this group, trying to learn something, I saw you doing
some questions. And somehow I notice you have more knowledge than me in
this long waited new-born (after 15y) language.

That's why, as a community-developed language (including docs) I'd like to
suggest to you help to improve the docs.
This way, when I have - with some lucky - free time, I may learn with you
and all others that wrote these docs.

Regards,
acpguedes

PS: Perhaps, sorry for my really bad English

On Mon, Dec 14, 2020 at 7:34 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Hi All,
>
> https://docs.raku.org/language/classtut
>
>   "A tutorial about creating and using classes
>   in Raku"
>
> So far so good.
>
>   "Raku has a rich built-in syntax for defining
>   and using classes."
>
> U. Forgot something did we?  What is a "class"?
>
>
> Next up:
>
>   "A default constructor allows the setting of
>   attributes for the created object:"
>
> U.  Forgot something else, did we?  What is
> an "object"?
>
>
> The "tutorial" leaves "class" and "object" up to
> the reader to guess at from what looks like an
> interesting example.
>
>
> But, again forgetting things, The tutorial also
> leaves the syntax up for guess work as well.  Not
> described are "$.", "$!", ":$", ^$" what are they
> and what are the rules for using them.
>
> Next up:
>
>   my $r = Rectangle.new(
>lower => Point.new(x => 0, y => 0),
>upper => Point.new(x => 10, y => 10));
>
>
> Why are we using ".new"?
>
> Why are we using the syntax for a hash (=>)?
>
> And:
>   $!upper.x
>
> What is the rules and purpose for such?  Why
> the "!" and why the "."?
>
>
> I do realize the documentation is not meant for
> beginners, but rather a refresher for advanced
> users that do not need it, but this link definitely
> said "tutorial" -- fifth word in.
>
> Would some kind soul please fill in the missing
> parts of the "tutorial" for me?
>
> Many thanks,
> -T
>


-- 
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110


Re: classes and objects questions

2020-12-14 Thread ToddAndMargo via perl6-users

On 12/14/20 5:24 PM, Aureliano Guedes wrote:
That's why, as a community-developed language (including docs) I'd like 
to suggest to you help to improve the docs.
This way, when I have - with some lucky - free time, I may learn with 
you and all others that wrote these docs.


Hi Aureliano,

I absolutely adore Raku.  But the docs are truly awful.
They do not start out simple and build to the complex.
They throw terms out without defining them.  They use
things in examples that are require advanced level of
knowledge to understand, and so on and so forth.
They have broken virtually rule of technical writing.
The docs are simply refreshers for those that already
know what they are doing and do not need them.

I have tried several times to contribute to and get
the docs improved.  I have been told I am providing
too much detail or just get ignored.  So I have
stopped.  The culture of the "docs" is not something
I can change.

I would absolute love to see some kind of contributed
docs portal that any user could pick out a subject and
write on it with the ability for others to correct
mistakes or add content.

Once I get Classes and Object figured out, I will
write my own documentation of the subject.  If I
think it is good enough to share (some of my technical
writing stinks too), I will post it back here.

For starters, I need to have the definition of
"class" and "object".  Then I need their rules.

-T


Re: classes and objects questions

2020-12-14 Thread WFB
Hi ToddAndMargo,

Thanks for the effort to improve the Raku docs. However, this is a Raku not
OO (Object Oriented
) related
tutorial. As JJ already pointed out, these pages are to show the reader how
you get things done in Raku, not what OO or other programming concepts are.
There are probably thousands of OO books around and can teach you what a
class is and why you need them. See the Wikipedia link I linked above for
example. That's not in the scope of this tutorial.

The parts you are missing are already there, but unfortunately not linked.
You can find them in the Raku documentation:  =>
, $!
 and $.

:$ stands for a named parameter
 and
can be also found in the documentation.
^$ is used for ranges and is also already
there.

So the information you are missing is already there. You could argue that
the links are missing and I would agree with you. But again this tutorial
is for Raku classes not OO concept, Pairs, named parameters or ranges.

I hope that helped,
Wolfgang



On Tue, 15 Dec 2020 at 05:28, ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 12/14/20 5:24 PM, Aureliano Guedes wrote:
> > That's why, as a community-developed language (including docs) I'd like
> > to suggest to you help to improve the docs.
> > This way, when I have - with some lucky - free time, I may learn with
> > you and all others that wrote these docs.
>
> Hi Aureliano,
>
> I absolutely adore Raku.  But the docs are truly awful.
> They do not start out simple and build to the complex.
> They throw terms out without defining them.  They use
> things in examples that are require advanced level of
> knowledge to understand, and so on and so forth.
> They have broken virtually rule of technical writing.
> The docs are simply refreshers for those that already
> know what they are doing and do not need them.
>
> I have tried several times to contribute to and get
> the docs improved.  I have been told I am providing
> too much detail or just get ignored.  So I have
> stopped.  The culture of the "docs" is not something
> I can change.
>
> I would absolute love to see some kind of contributed
> docs portal that any user could pick out a subject and
> write on it with the ability for others to correct
> mistakes or add content.
>
> Once I get Classes and Object figured out, I will
> write my own documentation of the subject.  If I
> think it is good enough to share (some of my technical
> writing stinks too), I will post it back here.
>
> For starters, I need to have the definition of
> "class" and "object".  Then I need their rules.
>
> -T
>


Re: classes and objects questions

2020-12-14 Thread ToddAndMargo via perl6-users

For starters, I need to have the definition of
"class" and "object".  Then I need their rules.

-T




On 12/14/20 10:33 PM, WFB wrote:

Hi ToddAndMargo,

Thanks for the effort to improve the Raku docs. However, this is a Raku 
not OO (Object Oriented 
) related 
tutorial. As JJ already pointed out, these pages are to show the reader 
how you get things done in Raku, not what OO or other programming 
concepts are. There are probably thousands of OO books around and can 
teach you what a class is and why you need them. See the Wikipedia link 
I linked above for example. That's not in the scope of this tutorial.


The parts you are missing are already there, but unfortunately not 
linked. You can find them in the Raku documentation: => 
, $! 
 and $. 

:$ stands for a named parameter 
 
and can be also found in the documentation.
^$ is used for ranges and is also 
already there.


So the information you are missing is already there. You could argue 
that the links are missing and I would agree with you. But again this 
tutorial is for Raku classes not OO concept, Pairs, named parameters or 
ranges.


I hope that helped,
Wolfgang


Hi Wolfgang,

Thank you for the links!

JJ may be right about the OO thing, but it makes the
tutorial pretty much useless.  How "class" and "object"
*relate* to Raku needs to be explained.

"The best is the enemy of the good".  It is better to
slum it a bit and make the tutorial useful. JJ will
hate it, but he will live.

-T


Re: classes and objects questions

2020-12-15 Thread WFB
JJ may be right about the OO thing, but it makes the
> tutorial pretty much useless.  How "class" and "object"
> *relate* to Raku needs to be explained.
>

When we are talking about describing Classes and Objects in a few words,
then I agree. Searching on the web reveals lots of tutorials for Java, C#
and so on with at least a few words about what classes and objects are.


>
> "The best is the enemy of the good".  It is better to
> slum it a bit and make the tutorial useful. JJ will
> hate it, but he will live.
>
I don't think JJ hates useful tutorials. But he has to find a balance. Look
in the Raku/doc repository
. Every week ~15
commits. And most of them on Sunday. Of course you can spend all day and
make the classtut perfect, at least what is your understanding of perfect.
But there is a lot more to be documented and maintained. You have to find a
level of detail that provides information for all readers and to have only
a limited amount of time and resources. That is JJ trying to do.
You are trying to shape the documentation for your needs. Sometimes the
best documentation is not your documentation.
In this case adding links for the Variables and a few sentences about
classes and objects would probably not hurt but I would listen to the
arguments JJ has. Because he knows the big pictures.

Best

>
> -T
>


Re: classes and objects questions

2020-12-15 Thread Parrot Raiser
Raku allows for several different programming paradigms; procedural,
functional, (as in languages like LISP), and object-oriented. It is
possible to write purely procedural Raku, while ignoring O-O features
completely, though it does take some dodging.

Object-oriented.programming first surfaced in the mid 1960s in
research projects, but was more generally visible by 1980. Like all
new programming concepts, it was going to cure cancer, bring about
world peace, and produce bug-free software. (And didn't, of course.)
It naturally had its specialised jargon, designed to ensure tribal
solidarity and repel infidels. It gradually spread with languages like
C++, (1979-83),  but remained a niche concept until Sun introduced
Java in 1995.

https://www.indeed.com/career-advice/career-development/what-is-object-oriented-programming

With the success of Java, later Javascript, and other new languages,
O-O and its jargon became
sufficiently mainstream that even many programmers working with other
languages learned the terminology. I suspect that many programmers
trained since the mid-90s assume that it's the only way to code, and
that objects and classes are inherent parts of everyone's universes.

If you were discussing the assembly language for bicycles, any
documentation could reasonably assume an understanding of frames,
wheels, pedals, and bell-cranks. Equally, any discussion of
object-oriented features can reasonably assume an understanding of
generic concepts like objects, classes, and inheritance, provided it
points out local weirdnesses. Repeating all the basics would make the
text cumbersome.

Perhaps the best approach would be a hyperlink to a generic
description (of which there are probably thousands already on the Web)
the first time a terms is introduced. The naive could follow it to
enligtenment, while the cognoscenti would not be distracted by it.


Re: classes and objects questions

2020-12-15 Thread ToddAndMargo via perl6-users

On 12/15/20 7:00 AM, Parrot Raiser wrote:

Raku allows for several different programming paradigms; procedural,
functional, (as in languages like LISP), and object-oriented. It is
possible to write purely procedural Raku, while ignoring O-O features
completely, though it does take some dodging.

Object-oriented.programming first surfaced in the mid 1960s in
research projects, but was more generally visible by 1980. Like all
new programming concepts, it was going to cure cancer, bring about
world peace, and produce bug-free software. (And didn't, of course.)
It naturally had its specialised jargon, designed to ensure tribal
solidarity and repel infidels. It gradually spread with languages like
C++, (1979-83),  but remained a niche concept until Sun introduced
Java in 1995.

https://www.indeed.com/career-advice/career-development/what-is-object-oriented-programming

With the success of Java, later Javascript, and other new languages,
O-O and its jargon became
sufficiently mainstream that even many programmers working with other
languages learned the terminology. I suspect that many programmers
trained since the mid-90s assume that it's the only way to code, and
that objects and classes are inherent parts of everyone's universes.

If you were discussing the assembly language for bicycles, any
documentation could reasonably assume an understanding of frames,
wheels, pedals, and bell-cranks. Equally, any discussion of
object-oriented features can reasonably assume an understanding of
generic concepts like objects, classes, and inheritance, provided it
points out local weirdnesses. Repeating all the basics would make the
text cumbersome.

Perhaps the best approach would be a hyperlink to a generic
description (of which there are probably thousands already on the Web)
the first time a terms is introduced. The naive could follow it to
enligtenment, while the cognoscenti would not be distracted by it.


That would be an excellent way of doing it!

Loved the prose in your writing too!

Thank you!

I have been reading Perl5 tutorials on what classes
and objects are.  Since we do not have references
pointers, its is going to be fun.


Re: classes and objects questions

2020-12-15 Thread ToddAndMargo via perl6-users

On 12/15/20 12:34 AM, WFB wrote:



JJ may be right about the OO thing, but it makes the
tutorial pretty much useless.  How "class" and "object"
*relate* to Raku needs to be explained.


When we are talking about describing Classes and Objects in a few words, 
then I agree. Searching on the web reveals lots of tutorials for Java, 
C# and so on with at least a few words about what classes and objects are.



"The best is the enemy of the good".  It is better to
slum it a bit and make the tutorial useful. JJ will
hate it, but he will live.

I don't think JJ hates useful tutorials. But he has to find a balance. 
Look in the Raku/doc repository 
. Every week ~15 
commits. And most of them on Sunday. Of course you can spend all day and 
make the classtut perfect, at least what is your understanding of 
perfect. But there is a lot more to be documented and maintained. You 
have to find a level of detail that provides information for all readers 
and to have only a limited amount of time and resources. That is JJ 
trying to do.
You are trying to shape the documentation for your needs. Sometimes the 
best documentation is not your documentation.
In this case adding links for the Variables and a few sentences about 
classes and objects would probably not hurt but I would listen to the 
arguments JJ has. Because he knows the big pictures.


Best


I like Parrots idea about using links, so advanced
users don't have to wade through  what they already
know and the rest of us can figure out what is going
on.

I have been looking at some Perl 5 Class tutorials
to try to get a hang on what is going on.  But since
we do not have reference pointers ...


Re: classes and objects questions

2020-12-15 Thread ToddAndMargo via perl6-users

On 12/14/20 2:33 PM, ToddAndMargo via perl6-users wrote:

Hi All,

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

  "A tutorial about creating and using classes
  in Raku"

So far so good.

  "Raku has a rich built-in syntax for defining
  and using classes."

U. Forgot something did we?  What is a "class"?


Next up:

  "A default constructor allows the setting of
  attributes for the created object:"

U.  Forgot something else, did we?  What is
an "object"?


The "tutorial" leaves "class" and "object" up to
the reader to guess at from what looks like an
interesting example.


But, again forgetting things, The tutorial also
leaves the syntax up for guess work as well.  Not
described are "$.", "$!", ":$", ^$" what are they
and what are the rules for using them.

Next up:

  my $r = Rectangle.new(
   lower => Point.new(x => 0, y => 0),
   upper => Point.new(x => 10, y => 10));


Why are we using ".new"?

Why are we using the syntax for a hash (=>)?

And:
  $!upper.x

What is the rules and purpose for such?  Why
the "!" and why the "."?


I do realize the documentation is not meant for
beginners, but rather a refresher for advanced
users that do not need it, but this link definitely
said "tutorial" -- fifth word in.

Would some kind soul please fill in the missing
parts of the "tutorial" for me?

Many thanks,
-T



Okay, here are some Perl 5 definitions for PerlDocs:

https://perldoc.perl.org/perlglossary

class

A user-defined type, implemented in Perl via a package that 
provides (either directly or by inheritance) methods (that is, 
subroutines) to handle instances of the class (its objects). See also 
inheritance.



class method

A method whose invocant is a package name, not an object reference. 
A method associated with the class as a whole. Also see instance method.



object

An instance of a class. Something that “knows” what user-defined 
type (class) it is, and what it can do because of what class it is. Your 
program can request an object to do things, but the object gets to 
decide whether it wants to do them or not. Some objects are more 
accommodating than others.



Anyone want to add Raku modifications to the above?  I
like their "user-defined type" description.

I don't know what to make of "more accommodating than others".


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


Re: classes and objects questions

2020-12-17 Thread ToddAndMargo via perl6-users

On 12/14/20 2:33 PM, ToddAndMargo via perl6-users wrote:

Hi All,

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

  "A tutorial about creating and using classes
  in Raku"

So far so good.

  "Raku has a rich built-in syntax for defining
  and using classes."

U. Forgot something did we?  What is a "class"?


Next up:

  "A default constructor allows the setting of
  attributes for the created object:"

U.  Forgot something else, did we?  What is
an "object"?


The "tutorial" leaves "class" and "object" up to
the reader to guess at from what looks like an
interesting example.


But, again forgetting things, The tutorial also
leaves the syntax up for guess work as well.  Not
described are "$.", "$!", ":$", ^$" what are they
and what are the rules for using them.

Next up:

  my $r = Rectangle.new(
   lower => Point.new(x => 0, y => 0),
   upper => Point.new(x => 10, y => 10));


Why are we using ".new"?

Why are we using the syntax for a hash (=>)?

And:
  $!upper.x

What is the rules and purpose for such?  Why
the "!" and why the "."?


I do realize the documentation is not meant for
beginners, but rather a refresher for advanced
users that do not need it, but this link definitely
said "tutorial" -- fifth word in.

Would some kind soul please fill in the missing
parts of the "tutorial" for me?

Many thanks,
-T



Well, so far I have:

"class" is a definition of a custom structure of
of variables.

"object" is when you declare a structure using
a "class".

And I am still working on a "method" definition,
and where they fit into the classes declaration,
although I use methods extensively

say (-5..5).rand.truncate.abs**3
64

This is Perl 5's definition of method:
class method

A method whose invocant is a package name, not
an object reference. A method associated with
the class as a whole.

Not sure how to translate that to Raku