It was Friday, December 12, 2003 when Luke Palmer took the soap box, saying:
: So I'm seeing a lot of inconsistent OO-vocabulary around here, and it
: makes things pretty hard to understand.

Awesome.  I've taken your original, plus comments so far and created
perlvocab.pod.  Lets give it a couple go-rounds and it can be stored
in CVS for safe keeping (and maintaining).  Send me diffs if you like.

Document below sig.

  Casey West

-- 
Usenet is like Tetris for people who still remember how to read. 
  -- Button from the Computer Museum, Boston, MA

=pod

=head1 NAME

perlvocab - Perl Vocabulary and Glossary

=head1 SYNOPSIS

This document authoritatively defines many potentially ambiguous terms in Perl.

=head1 DESCRIPTION

=head2 Object Oriented Terminology

=over 4

=item attribute

A concrete data member of a class.  Declared with C<has>.

=item property

A run-time, out-of-band sticky note to be placed on a single object,
applied with with C<but>.

A property is a simple kind of role that supplies a single attribute.
The type of a property is identical to its role name.  Roles can have
subtypes that function as enums when the subtypes are constrained to a
single value.  You can use one of these subtypes without specifically
implying the role name.  So saying

    $bar but Red

might give you a value with the property Color.  You can write the corresponding
boolean test using the smart match operator:

    $bar ~~ Red

and it (smartly) picks out the Color property to compare with, provided
it's unambiguous.  You can use that syntax to compare against any
subtype or junction of subtypes:

    $bar ~~ Redish&Whiteish     # pinkish

=item trait

A compile-time sticky note to be placed on a wide variety of things. 
Used with C<is>.

=item role

A collection of methods and/or attributes to be incorporated into a class sans
inheritance (and maybe some other stuff, too).   A role can be applied to a class
at compile time via C<does>, or to an object at run time via C<but>.

So for example:

    class Dog
        does Boolean                # role
        is extended                 # trait
        is Mammal                   # base class
    {
        has $.tail;                 # attribute
        has @.legs;                 # attribute
    }

    my $fido = Dog.new
                but false;          # property

In this example, C<Mammal> is a base class, which is an overloaded use of C<is>.  
Though,
upon A12 release, we'll probably find out that it's not overloaded but
instead, elegantly unified, somehow. 

=head1 AUTHOR

Luke Palmer, Original Document

Contributions by Larry Wall, and Jonathan Scott Duff

Compilation by Casey West

=cut

Reply via email to