develooper Front page | perl.moose | Postings from July 2011

Re: Moose documentation, "methods" and all that jazz...

Thread Previous
From:
Marius Olsthoorn
Date:
July 3, 2011 04:00
Subject:
Re: Moose documentation, "methods" and all that jazz...
Message ID:
CAGPy9h7CLS4=M8ih+rw2b7o7ZQzV2G-fKosnLjOZf-5kpg2tMg@mail.gmail.com
Hi,

You might want to look at the documentation of perl itself.

http://search.cpan.org/~jesse/perl-5.14.1/pod/perlobj.pod#A_Method_is_Simply_a_Subroutine

Good luck,
Marius

On Sun, Jul 3, 2011 at 11:52 AM, Meir Guttman <meir@guttman.co.il> wrote:
> Hi all!
>
>
>
> First I should mention that I am a Perl newbie, using Perl for less than two
> years! I learned Perl by doing, never attending a formal course. And
> although I am using objects daily (how can one NOT using these?), I never
> created an OO package. This is my first post to this list.
>
>
>
> I recently came to realize that it might be beneficial to implement a
> certain package as an OO one. My first stop was, as suggested by the CPAN
> Moose page, Moose::Manual and all its hyper-links. Here my enthusiasm
> waned...
>
>
>
> These pages deal a lot with "Attributes". In fact, four of these chapters,
> under different names, explain many aspects of these. Nevertheless, no
> explanation is offered as to the accessibility to these attributes. What are
> the scoping rules?
>
>
>
> As opposed to "attributes", "methods" get next to nothing treatment! The
> only coverage of methods is in the "concepts" chapter and it is literally
> this:
>
>
>
> --------------------
>
> Method
>
>
>
> A method is very straightforward. Any subroutine you define in your class is
> a method.
>
>
>
> Methods correspond to verbs, and are what your objects can do. For example,
> a User can login.
>
>
>
> sub login { ... }
>
>
>
> --------------------
>
>
>
> That's it folks! You will not find a "Methods" chapter there!
>
>
>
> I couldn't find a non-trivial example as to how to write a useful method or
> how to INVOKE one in your script. Yes, I did look at the "Cookbook"
> (Moose::Cookbook::Basics::Recipexxx)! But again, much about attributes
> there, very little about methods.
>
>
>
> One example: You see a lot of "my $self = shift;" in the code examples of
> some methods, but not a single word about what is it, of what use is it and
> why do you need it. (It seems to be a common convention to use this variable
> name...)
>
>
>
> Another: You will fleetingly find terms such as "privately accessible..."
> (those entities with a name starting in an underscore?) and "publicly
> accessible..." (those that do not?). What do these mean? Why do you need and
> where do you use one or the other? Can you "privately access" a "publicly
> accessible" entity? Not a word!
>
>
>
> In short, a lot to be desired...
>
>
>
> Can somebody point me to a better source?
>
>
>
> Meir.
>
>
>
> Please, don't flame me! Even though I should know a lot more about many more
> things in Perl, basic and advanced, an introduction such as Moose::Manual
> should be peppered with hyper-links to even basic concepts such as packages,
> and so. Bear with me...
>
>

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About