[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] do... while? SPOILER



>>>>> "Chris" == Chris Winters <cwinters@intes.net> writes:

Chris> Just lop off {attribs} if you want the attributes to be off
Chris> the root. To add new attributes to the class, all you need
Chris> to do is add new key/value pairs to %ATTRIBS. I think I
Chris> cribbed this entire thing from Tom Christiansen's perltoot
Chris> (perldoc perltoot), but it's been so long I can't be sure.

There are reasons why I don't send people to read perltoot.  One of
them is that it was written by someone who seems to hate Perl, and
does everything as a workaround in spite of Perl.

Another is that it was written in 5.000 days, and hasn't tracked all
the cool things that people have discovered since.

Damian Conway has an *excellent* OO Perl book coming out, written by
someone who handles both of the above concerns.  Damian's been
teaching OO longer than tchrist has been programming (unless I got my
dates wrong), and actually *enjoys* the flexibility and power that
Larry designed into Perl's late-added OO features.

I'm thinking of writing "Randal's Object Oriented Tutorial"
(perlroot.pod) based on a summary of what I'm now teaching in my OO
Perl class (and some of what I learned reading Damian's forthcoming
book), but sadly it will probably never make the standard Perl
distribution.

For one thing, I've found that teaching things in this order one
separate example at a time:

    polymorphism
    class methods via ->
    inheritance
    overriding
    SUPER
    instances via blessed scalars
    instance methods
    constructors
    ref to detect class vs. instance method
    instances via blessed hashes
    indirect object form (discouraged)

actually improves the plan for beginning or intermediate OO hackers,
so that you don't have to wade through five of those ten things in:

sub new {
  my $this = shift; my $class = ref $this || $this; bless { @_ }, $class;
}

I mean, that's in a *tutorial* as the first example of "what is an
object"?  You've got to be kidding. :) No wonder people think Perl's
OO is hard.

If I get some encouragement, I'll write perlroot.pod whether or not
it ends up in the dist.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe