Michal Wallace <[EMAIL PROTECTED]> wrote:
> On Thu, 8 Jan 2004, Leopold Toetsch wrote:

>> $ perldoc docs/pdds/pdd15_objects.pod
>> /TRANSLATION AND GLOSSARY

> So let me see if I have this right. Attributes
> are slots in a class, that get created on each
> instance. Properties don't have predefined slots,
> you can just attach whatever you want to any PMC.

Yep. The "whatever you want" is another PMC though.

> So: a language like java would probably use
> attributes, because the shape of the class is
> defined before hand, whereas python would tend
> to use properties... Right?

Yes. Yes.

> But when I actually go to fill in the slots,
> I still use getprop/setprop for both types,
> right? So if I setprop on an attribute-based-class
> it would fill in the attribute first, and then
> if the attribute slot isn't there, do something
> else (like throw an exception or just make a property?)

No: Attributes aren't filled with setprop, that just sets a property.
And: what's happening if a non-existing property is set depends on the
HLL. Python's throwing AFAIK a NameError or such exception. Attributes
and properties are 2 different things to achieve similar effects. Perl6
will have both. Python would very likely use properties only.

> I guess what I'm asking is: is getprop/setprop
> a universal interface, or will we need some kind
> of logic to know whether a particular object
> uses attributes instead?

We will have to know, if an object originated from Python or Perl6, if
we want to mix library code. But don't nail me down on that. This all
depends on namespaces too, the order how we lookup attributes (or
properties) but its primary up to the HLL code to do the right thing.

(All AFAIK, which isn't much when objects are concerned)

> Michal J Wallace

leo

Reply via email to