Erik Bågfors wrote:
> Garrett Goebel wrote:
>> Erik Bågfors wrote:
>>> Dan Sugalski wrote:
>>>> Okay, here's another shot at the semantics for objects. If
>>>> folks, especially non-perl folks, would look this over and chime
>>>> in, I'd much appreciate it.
>>>>
>>>> Objects have (all optional):
>>>>
>>>> *) Properties
>>>> *) Methods
>>>> *) Attributes
>>>
>>> Can you give a clear example of what the difference is between
>>> properties and attributes?
>>
>> My imperfect understanding is:
>>
>> "attribute" is only used in an OO context and refers to the data
>> members the class or object encapsulates.
>>
>> "property" has nothing inherently to do with OO. Properties are tags
>> against variables and values and are compile or run time specific.
>> Hints to the compiler and interpreter...
> 
> Ok, any example of such a property....?

Whether an object is 'true' or not is a property.

AFAIK, though, properties are only attatched to values (not variables),
and are entirely run-time things.

(Unless we want to re-use the word "property" to apply to variables,
in which case it would mean a type of compile-time behavior, too.)

And attributes are essentially member variables of objects, which you
can access as "$obj.foo".  Another possible description of them might be
lvalue methods which never take arguments, and which fetch and store
class-specific pieces of data.  Different classes may define their own
private ".foo" attribute, and these will be distinct even if a class
inherits from two classes who both have a .foo attribute.

In perl5, attributes are roughly implemented by class instances being
blessed hash members, and if more than one class uses a particular
member name, they will end up colliding.

-- 
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print

Reply via email to