Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[svn:parrot-pdd] r16965 - trunk/docs/pdds/draft

4 views
Skip to first unread message

all...@cvs.perl.org

unread,
Feb 13, 2007, 5:00:12 AM2/13/07
to perl6-i...@perl.org
Author: allison
Date: Tue Feb 13 02:00:10 2007
New Revision: 16965

Modified:
trunk/docs/pdds/draft/pdd15_objects.pod

Log:
[pdd]: Update to reflect core conceptual changes to Objects PDD.


Modified: trunk/docs/pdds/draft/pdd15_objects.pod
==============================================================================
--- trunk/docs/pdds/draft/pdd15_objects.pod (original)
+++ trunk/docs/pdds/draft/pdd15_objects.pod Tue Feb 13 02:00:10 2007
@@ -5,381 +5,251 @@

docs/pdds/pdd15_objects.pod - Object and Class semantics for Parrot

-=head1 REQUIREMENTS
-
-This PDD is due an overhaul. This requirements section is for language
-implementers to list the OO-related needs of their language in so as to aid
-that.
-
-=head2 PMCS
-
-Ruby: Just like small talk, everything is an object. I'm hoping to be able to
-implement core Ruby classes(String, Array, Hash, Module, etc) something like this.
-
-ParrotClass
- |
- RubyClass String
- | |
- \ /
- RubyString
-
-=head2 Objectspace
-
-Ruby: Objectspace in ruby allows the programmer to iterate through every live object
-in the system. There is some debate about how to make this play nice with different
-garbage collection schemes.
-
-=head2 Classes
-
-A class is a collection of methods and attributes. It would be desirable, for
-those classes whose definition is fully known at compile time, to have a
-convenient way to have the class along with its attributes and methods stored
-into a PBC file rather than created at runtime. However, creation of new
-classes at runtime will be needed too.
-
-=head2 Meta-classes
-
-Ruby: Ruby has meta classes. It would be nice if classes were objects in Parrots OO model.
-
-=head2 Attributes
-
-Attributes are instance data associated with a class (or role, however those
-are supported). They may not always be of a type specified by a PMC, though
-boxing/unboxing is of course an option.
-
-Perl 6: All attributes are opaque (not externally visible, even to any
-subclasses).
-
-.Net: Attributes may be private (not externally visible), public (always
-externally visible), protected (only visible to subclasses) and internal
-(only visible inside the current assembly - the closest correspondence in
-Parrot is perhaps only visible inside the same PBC file). Additionally, it
-is allowable for a subclass to introduce an attribute of the same name as
-the a parent class has, and they both exist depending on what type an
-instance of the class is currently viewed as being (read: there is a
-difference between the type of the reference and the type of the value).
+=head1 ABSTRACT

-Ruby: Attributes can be dynamically added and removed at runtime.
+This PDD describes the semantics of Parrot's object and class systems.

-=head2 Methods
+=head1 VERSION

-Perl 6: Methods may be public (anyone can invoke them) or private (only
-invokable by the class they are defined in). Additionally, submethods are
-methods that do not get inherited.
+$Revision$

-.Net: Like attributes, methods may be public, private, protected or internal.
+=head1 DEFINITIONS

-Ruby: has a method_missing that gets called when method resolution fails to find a method.
-Methods can be dynamically added and removed at runtime.
+=head2 Class

-=head2 Constructors
-
-A constructor is run when an object is instantiated.
+=head2 Object

-.Net: There may be many constructors for an object (provided they all have
-different signatures), and the correct one is called based upon the passed
-parameters.
+=head2 Attribute

-=head2 Inheritance
+An attribute is a slot in an object that contains a value, generally a
+PMC. Attributes are referenced by class name/attribute name pairs.

-Perl 6: Multiple inheritance.
+Attributes are set on a class-wide basis, and all the objects of a class
+will have the same set of attributes. Most OO languages don't allow
+attribute changes to existing classes, but Parrot's base attribute
+system does allow it. In order to safely support advanced dynamic
+features in HLLs, attributes are not accesible via fixed attribute
+offsets, but only via named lookup.

-.Net: Single inheritance.
+=head2 Method

-Ruby: Single inheritance but support for mixins of ruby modules.
+A method is a piece of code that you invoke by name through an object.

-=head2 Interfaces
+=head2 Parent class

-An interface specifies a set of methods that must be implemented by a class
-that inherits (or implements) the interface, but does not provide any form of
-implementation for them.
-
-.Net: Interfaces are pretty much what was just describe above. XXX Need to
-check behavior of you implement two interfaces with methods of the same name.
-
-=head2 Roles
-
-A role consists of a set of methods and attributes. It cannot be instantiated
-on its own, but must be composed into a class. When this happens its methods
-and attributes become of that classes methods and attributes. This may happen
-at compile time or runtime, however when a role is composed into a class at
-runtime then what really happens is that a new anonymous class is created with
-the role composed into it and then the namespace entry for the existing class is
-updated to refer to the new one. Note that this means classes must be garbage
-collectable, with all those referred to by a namespace or with objects of that
-class existing being marked live.
-
-Perl 6: Roles pretty much are a Perl 6 thing, so the definition above contains
-all that is needed. An open question is whether Parrot worry about collision
-detection? For compile time composition that's easy to punt to the compiler;
-for runtime composition, that's not so easy though.
-
-=head2 Introspection (aka Reflection)
-
-Perl 6: Reflection provides access to a list of methods that a class has, its
-parent classes and the roles it does, as well as the name of the class and its
-memory address. For methods, their name, signature, return type and whether
-the method is declared multi are available.
-
-.Net: Reflection provides access to a list of attributes and methods as well as
-the name of the class and its parent. The types of attributes and signatures of
-methods are also available.
-
-=head2 Inner Classes
-
-An inner class is essentially a class defined within a class. Therefore it has
-access to things private to its outer class.
-
-Perl 6: Inner classes are allowed, and may also be private.
-
-.Net: Inner classes are allowed and may be private, public, protected or
-internal.
+Also called the super-class. The parent class is, in an inheritance situation,
+the class being derived from. If A derives from B, B is the parent class of A.

-=head2 Delegation
+=head2 Child class

-Delegation is where a method call is "forwarded" to another class. Parrot may
-provide support for simple cases of it directly, or could just provide a "no
-method matched" fallback method that the compiler fills out to implement the
-delegation.
-
-Perl 6: Delegation support is highly flexible, even allowing a regex to match
-method names that should be delegated to a particular object.
+Also called the sub-class. The child class is, in an inheritance situation, the
+class doing the deriving. If A derives from B, A is the child class.

-=head2 Prototype-based OO
+=head2 Role

-Prototype-based OO has no classes. All objects are cloned from existing
-objects and modified. Requires lightweight singleton creation, without a
-needing separate class for every instance object. (Self, JavaScript, and
-Io are examples of prototype-based 00.)
+A role adds attributes and methods into a class without inheritance. The
+composed class retains a list of roles applied to it (so they can be
+checked with C<does>), but otherwise maintains no distinction between
+composed attributes and methods and those defined in the class.

-=head1 QUESTIONS
+=head2 Delegate

-Should we have a super or next opcode?
+An object that is transparently (to the user) embedded in another object.
+Delegate objects are used in those cases where we can't inherit from a class
+because the class is from a different object universe.

-=head1 NOTES
+=head2 Property

-=head2 Interaction with PMCs
+A property is a role that only adds attributes and accessors.

-The interaction between objects and PMCs is currently underspecified.
+Properties are generally assigned at runtime, and a particular property may or
+may not exist on a PMC at any particular time. Properties are not restricted to
+objects as such--any PMC may have a property attached to it.

+=item Interface

-=head1 ABSTRACT
+An interface is a role that only adds methods.

-This PDD describes the semantics of Parrot's object and class systems. The PDD
-is divided into two parts, the semantics expressed to user programs through
-PMCs, and the default back-end class scheme.
-
-Note that the class system is I<not> the single mandated class scheme, merely
-the one designed to express the semantics needed for Perl 6, ruby, and python.
-Alternate class systems are certainly possible, and direct compatibility with
-the system as described here isn't strictly necessary.

=head1 DESCRIPTION

-This is a reasonably straightforward object system. It assumes that objects
-have:
-
=over 4

-=item *
+=item - The object and class system provides the flexibility to
+implement a core set of dynamic languages (Perl 6, Ruby, Python, etc).
+Other class systems may be implemented later to support other languages.

-An array of attributes. Note that attribute values are I<always> PMCs.
+=item - Classes have an associated namespace. (Which may be anonymous)

-=item *
+=item - Classes have one or more immediate parent classes

-A parent class
+=item - Classes have a catalog of attribute names.

-=item *
+=item - Classes have a list of roles they implement

-A custom (though possibly class-wide) vtable
+=item - Classes can instantiate an object of their class

-=back
+=item - Classes can add and remove parent classes

-and that you can:
+=item - Classes can add and remove attributes

-=over 4
-
-=item *
-
-Call a method on an object
+=item - Classes can add (but not remove) roles

-=item *
+=item - Classes are instances of a meta-class and have their own sets of
+class methods and class attributes

-Get a method PMC for a method for an object (for deferred method calls)
+=item - Objects have an array of attributes. Attribute values may be
+PMCs or a low-level type.

-=item *
+=item - Objects have an associated class.

-Fetch the class for an object
+=item - Objects may have a custom vtable or use a class-wide vtable.

-=item *
+=item - Objects can call a method

-Subclass an existing object (note that objects may not necessarily be able to
-have their classes changed arbitrarily, but making a subclass and moving the
-object to it is allowable)
+=item - Objects can retrieve a method PMC for a method (for deferred
+method calls)

-=item *
+=item - Objects can fetch their class

-Get an attribute by name or offset
+=item - Objects can be subclassed (note that objects may not necessarily
+be able to have their classes changed arbitrarily, but making a subclass
+and moving the object to it is allowable)

-=item *
+=item - Objects can get an attribute by name

-Set an attribute by name or offset
+=item - Objects can set an attribute by name

=back

-Additionally we assume that I<all> objects can have properties on them, as all
-PMCs can have properties. The property get/set method may be overridden on a
-per-class basis as any other vtable method may be.
-
-For classes, we assume that:
-
-=over 4
-
-=item *
-
-Classes have an associated namespace. (Which may be anonymous)
-
-=item *
+=head1 IMPLEMENTATION

-Classes have one or more immediate parent classes
+There are four pieces to the object implementation. There are the PMCs for the
+classes and objects, the opcodes the engine uses to do objecty things, the
+specific vtable methods used to perform those objecty things, and the
+supporting code provided by the interpreter engine to do the heavy lifting.

-=item *
+Please note that Parrot, in general, does I<not> restrict operations on objects
+and classes. If a language has restrictions on what can be done with them, the
+language is responsible for making sure that disallowed things do not happen.
+For example, Parrot permits multiple inheritance, and will not stop code that
+adds a new parent to an existing class. If a language doesn't allow for
+multiple inheritance it must not emit code which would add multiple parents to
+a class. (Parrot may, at some point, allow imposition of runtime restrictions
+on a class, but currently it doesn't)

-Classes have a catalog of attribute names and offsets for all attributes.
+=head2 Class PMC API

-=item *
+There are two PMC classes, C<Class> and C<Object>. Class PMCs hold all
+the class-specific information. Instantiating a new OO class creates a
+new Class PMC, and enters the new OO class into Parrot's PMC class
+table, at which point it is indistinguishable from any other PMC class.

-Classes have a list of interfaces they implement
+It's important to note that 'standard' classes are Class PMC instances,
+or instances of a subclass of the Class PMC, and 'standard' objects are
+Object PMCs. It isn't necessary to create a brand new low-level PMC
+class for each OO class, and they all share the Class or Object vtable,
+respectively.

-=back

-And we further assume that classes can:
+An instance of the Class PMC has 5 attributes, which are:

=over 4

-=item *
-
-Instantiate an object of their class
-
-=item *
-
-Add parent classes
+=item 0

-=item *
+The class name

-Remove parent classes
+=item 1

-=item *
+A link to the class's associated namespace

-Add attributes
+=item 2

-=item *
+An array PMC of the immediate parent classes

-Remove attributes
+=item 3

-=item *
+A cached array of all parent PMCs, in search order (this is an optional
+optimization, and can be calculated from the class's rules of
+inheritance, the list of immediate parent classes, and the parent
+classes' rules of inheritance)

-Add interfaces
+=item 3

-=item *
+An array PMC of the composed roles

-Remove interfaces
+=item 4

-=back
+An array PMC of the methods defined in the class or composed into the
+class

-This list is likely not definitive, but it's enough to start with. It also
-doesn't address the semantics of method calls, which need to be dealt with,
-possibly separately. With that in mind, the object system supports these
-features with a combination of PMC classes (not to be confused with object
-classes) and opcodes.

-=head1 IMPLEMENTATION
+=item 5

-There are four pieces to the object implementation. There are the PMCs for the
-classes and objects, the opcodes the engine uses to do objecty things, the
-specific vtable methods used to perform those objecty things, and the
-supporting code provided by the interpreter engine to do the heavy lifting.
+The class attribute hash. Keys are the attribute names and the values
+are a hash of attribute characteristics, including name, type, and the
+class they're associated with.

-Please note that Parrot, in general, does I<not> restrict operations on objects
-and classes. If a language has restrictions on what can be done with them, the
-language is responsible for making sure that disallowed things do not happen.
-For example, Parrot permits multiple inheritance, and will not stop code that
-adds a new parent to an existing class. If a language doesn't allow for
-multiple inheritance it must not emit code which would add multiple parents to
-a class. (Parrot may, at some point, allow imposition of runtime restrictions
-on a class, but currently it doesn't)
+=back

-=head2 PMCs
+The attribute catalog holds only the attributes defined in a particular
+class. When instantiating an object, it is necessary to scan all parent
+classes as well as the instantiated class for attributes defined there.
+The inheritance rules for a particular HLL will determine which child
+class attributes override which parent class attributes.

-There are two PMC classes, C<ParrotClass> and C<ParrotObject>. ParrotObject
-PMCs are the actual objects, and hold all the per-object instance data.
-ParrotClass PMCs hold all the class-specific information. Instantiating a new
-OO class creates a new ParrotClass PMC, and enters the new OO class into
-Parrot's PMC class table, at which point it is indistinguishable from any other
-PMC class. (This doesn't mean that non-ParrotClass things can be subclassed or
-treated as an OO class. Neither is that forbidden. Just unimplemented)
-
-It's important to note that I<all> 'standard' classes are ParrotClass PMC
-instances, and I<all> 'standard' objects are ParrotObject PMCs. We do I<not>
-create a brand new PMC class for each OO class, and they all share the
-ParrotClass or ParrotObject vtable, respectively. This distinction is mostly an
-artifact of the implementation, and may change in the future.
-
-While the internals of the class and object PMCs should be considered black
-boxes, here's some documentation as to what they are for implementation
-purposes.
+We may also add a cache to the class object: a hash that contains all
+child and parent attribute characteristcs. Whether this is useful
+largely depends on how slow it is to scan through the list of parent
+classes, and how dynamic we want the system to be. (If a parent class
+changes its set of attributes, should that change appear in later
+instantiations of objects from child classes? Probably, in which case
+caching parent attributes is an obstacle.)

-The ParrotClass PMC holds a 6 element array, which is:
+Class PMCs also have the "I am a class" flag set on them.

-=over 4
+=head3 Methods

-=item 0
+=head2 name

-An array PMC of the immediate parent classes
+The accessor for the name attribute. With no argument, it simply returns
+the current value for name. When passed an argument, it sets the name of
+the class, and also sets the association with a namespace.

-=item 1
+=head2 new

-The class name PMC
+ obj = class.'new'( 'myattrib' => "Foo" )

-=item 2
+Create a new instance object from the class object. It takes an optional
+slurpy, named list of attributes and values to initialize the object.

-An array of all parent PMCs, in search order
+=head2 attributes

-=item 3
+An accessor for the attributes of the class. It returns the a Hash of
+all attributes, with a key of the attribute name, and a value of the
+Attribute object. The accessor is read-only.

-The class attribute section hash. Keys are the class name in language-defined
-format (so perl would be foo::bar, while java would be
-some.damn.long.thing.with.dots), values are the integer offset from the start
-of the attribute array where that class' attributes start.
+=head2 add_attribute

-=item 4
+Adds a single attribute to the class. It takes a simple string name, and
+a simple string value for type.

-The class attribute name hash. Keys are the fully qualified attribute names and
-the values are the offset from the beginning of the attribute array of the
-particular attribute.
+=head2 parents

-=item 5
+An accessor for the parents of the class. It returns an Array of all
+parents. The accessor is read-only.

-The class attribute array. This is an array of unqualified attribute names.
+=head2 add_parent

-=back
+Adds a single parent to the class. It takes a simple string name.

-Note that the attribute catalog holds I<all> the attributes for an object. This
-includes the attributes in the object's class as well as I<all> the attributes
-defined in all the parent classes. (Multiple inheritance makes this necessary
--- the offsets of a class' attributes will change from child class to child
-class)
-
-{{ NOTE: one feature I'd like to have is some way to access a list of
-the object's attributes. The particular use I have in mind is dumping
-the attributes of an object a la Data::Dumper. It abuses the notion
-of 'opaque object', so I could be persuaded it's not a good idea. On the
-other hand, it could be an introspective capability offered by Parrot
-but not directly exposed in the HLLs. }}
+=head2 Object PMC API

-ParrotClass PMCs also have the "I am a class" flag set on them.
+C<Object> PMCs are the actual objects, and hold all the per-object
+instance data.

-The ParrotObject PMC is an array of meta-information and attributes. The
+The Object PMC is an array of meta-information and attributes. The
elements of this array are:

=over 4
@@ -390,15 +260,27 @@

=item 1

-The class name PMC
+The class name

-=item 2+
+=item 2

-The attributes for the object
+The object attribute hash. Keys are the attribute names and the values
+are the attribute values. (The "hash" may be implemented as a typed
+structure following the CStruct proposal.)

=back

-Note that ParrotObject PMCs also have the "I am an object" flag set on them.
+A list of the object's attributes is accessible by extracting the keys
+from the object attribute hash. This direct introspetive capability may
+not be directly exposed in the HLLs (preserving the boundaries of an
+opaque object).
+
+Note that Object PMCs have the "I am an object" flag set on them.
+
+Object PMCs have no methods aside from those defined in their associated
+class. They do have vtable methods providing access to certain low-level
+information about the object, method call functionality, etc. See the
+sections below on L<Objects> and L<Vtables>.

=head2 Opcodes

@@ -409,7 +291,7 @@

=over 4

-=item classoffset Ix, Py, Sz
+=item classoffset Ix, Py, Sz [deprecated]

Returns the offset of the first attribute for class Sz in object Py.

@@ -451,9 +333,9 @@
method slot. If a method name isn't provided then we assume that things are
already properly set up.

-=item tailcallmethod (Unimplemented)
+=item tailcallmethod (Unimplemented) [deprecated]

-=item tailcallmethod Sx (Unimplemented)
+=item tailcallmethod Sx (Unimplemented) [deprecated]

Make a tailcall to method Sx. If no method name is given, we assume everything
is already set up properly.
@@ -487,7 +369,7 @@
Remove the attribute Sy from class Px, all objects of class Px, and all objects
of a child of class Px.

-=item instantiate Px, Py, Sz (Unimplemented)
+=item instantiate Px, Py, Sz (Unimplemented) [deprecated]

Instantiate a brand new class, based on the metadata in Py, named Sz.

@@ -503,7 +385,7 @@
then look up the offset attribute from it. (The class attributes are detailed
later) This is safe in general, since the only code reasonably querying a
class' attribute list is the class code itself, and if a class doesn't know
-whether it's a ParrotClass-style class or not you've got bigger problems.
+whether it's a Class-style class or not you've got bigger problems.

=over 4

@@ -530,7 +412,7 @@
Returns true or false to note whether the object in question implements the
interface passed in.

-=item get_attr(INTVAL)
+=item get_attr(INTVAL) [deprecated]

Returns the attribute at the passed-in offset for the object.

@@ -538,7 +420,7 @@

Returns the attribute with the fully qualified name for the object.

-=item set_attr(INTVAL, PMC *)
+=item set_attr(INTVAL, PMC *) [deprecated]

Sets the attribute for the passed-in offset to the passed-in PMC value

@@ -553,11 +435,11 @@
=back

Currently Parrot only supports mutating a class' metainformation for
-ParrotClass classes. This is a restriction which will be lifted at some point
+Class classes. This is a restriction which will be lifted at some point
soon.


-=head1 What The Bytecode Sees
+=head2 What The Bytecode Sees

The bytecode is isolated from most of the internal details of the
implementation. This allows both for flexibility in the implementation and
@@ -568,8 +450,8 @@

=head1 EXAMPLES

-The following examples all assume we're working with basic ParrotObject objects
-and ParrotClass classes.
+The following examples all assume we're working with basic Object objects
+and Class classes.

=head2 Creating a new class

@@ -598,10 +480,10 @@

Assuming we want an object of class C<Foo>:

- .local int FooType
+ .local pmc FooClass
.local pmc MyObject
- find_type FooType, "Foo"
- new MyObject, FooType
+ find_class FooClass, "Foo"
+ new MyObject, FooClass

=head2 Calling a method on an object

@@ -622,24 +504,14 @@

=head2 Accessing attributes from within a class

-Assuming we've an object that has class C<Foo> in it somewhere and want to get
-the second attribute C<b> out of it:
-
- .local int BaseOffset
- .local int BOffset
- classoffset BaseOffset, $P0, "Foo"
- BOffset = BaseOffset + 1
- getattribute $P1, $P0, BOffset
-
-Or with named access, if it isn't time critical:
+With named access:

getattribute $P1, $P0, "Foo\x0b"

=head1 Explanations

To get a new class, you can do a C<newclass>, which creates a new class with no
-parents besides parrot's default super-ish parent class. (Which doesn't appear
-in the class list anywhere, though arguably it ought to)
+parents besides parrot's default super-ish parent class.

To get a new child class, you have two potential options:

@@ -658,15 +530,7 @@
first class in the immediate parent list then use the C<addparent> op to add in
the rest of the immediate parents.

-Do be aware that, right now, you should I<not> add attributes or parents to a
-class that's been subclassed or has had objects instantiated. This will leave
-the internal structures of the classes and objects in an inconsistent state and
-things won't work at all the way you want them to. At the moment parrot won't
-warn if you do this, but it will soon. The restriction on parent list changes
-and attribute addition will be lifted in future releases, though doing so will
-be an expensive operation.
-
-=head1 VTABLE OVERLOADING
+=head2 VTABLE OVERLOADING

Classes may override the vtable methods, allowing objects of a class to behave
like a primitive PMC. Each vtable slot has a corresponding named method that
@@ -691,11 +555,11 @@

=over 4

-=item __init
+=item init

Called when the object is first created.

-=item __init_pmc
+=item init_pmc

Alternative entry point called when object is first created. Accepts a PMC
parameter used to initialize the given object. Interpretation of the PMC is
@@ -704,9 +568,9 @@
NOTE: It is strongly suggested that init_pmc(PMCNULL) be equivalent to
init(), though there will of necessity be exceptions.

-=item __morph
+=item morph

-=item __mark
+=item mark

Called when the DOD is tracing live PMCs. If this method is called then the
code must mark all strings and PMCs that it contains as live, otherwise they
@@ -715,430 +579,512 @@
This method is only called if the PMC is flagged as having a special mark
routine, and is not necessary for normal objects.

-=item __destroy
+=item destroy

Called when the object is destroyed. This method is only called if the PMC is
marked as having an active finalizer.

-=item __getprop
+=item getprop

-=item __setprop
+=item setprop

-=item __delprop
+=item delprop

-=item __getprops
+=item getprops

-=item __type
+=item type

-=item __type_keyed
+=item type_keyed

-=item __type_keyed_int
+=item type_keyed_int

-=item __type_keyed_str
+=item type_keyed_str

-=item __subtype
+=item subtype

-=item __name
+=item name

-=item __clone
+=item clone

-=item __find_method
+=item find_method

-=item __get_integer
+=item get_integer

Return the integer value of the object

-=item __get_integer_keyed
+=item get_integer_keyed

-=item __get_integer_keyed_int
+=item get_integer_keyed_int

-=item __get_integer_keyed_str
+=item get_integer_keyed_str

-=item __get_number
+=item get_number

Return the floating-point value of the object

-=item __get_number_keyed
+=item get_number_keyed

-=item __get_number_keyed_int
+=item get_number_keyed_int

-=item __get_number_keyed_str
+=item get_number_keyed_str

-=item __get_bignum
+=item get_bignum

Return the extended precision numeric value of the PMC

-=item __get_string
+=item get_string

Return the string value of the PMC

-=item __get_string_keyed
+=item get_string_keyed

-=item __get_string_keyed_int
+=item get_string_keyed_int

-=item __get_string_keyed_str
+=item get_string_keyed_str

-=item __get_bool
+=item get_bool

Return the true/false value of the PMC

-=item __get_bool_keyed
+=item get_bool_keyed

-=item __get_bool_keyed_int
+=item get_bool_keyed_int

-=item __get_bool_keyed_str
+=item get_bool_keyed_str

-=item __get_pmc
+=item get_pmc

Return the PMC for this PMC.

-=item __get_pmc_keyed
+=item get_pmc_keyed

-=item __get_pmc_keyed_int
+=item get_pmc_keyed_int

-=item __get_pmc_keyed_str
+=item get_pmc_keyed_str

-=item __get_pointer
+=item get_pointer

-=item __get_pointer_keyed
+=item get_pointer_keyed

-=item __get_pointer_keyed_int
+=item get_pointer_keyed_int

-=item __get_pointer_keyed_str
+=item get_pointer_keyed_str

-=item __set_integer_native
+=item set_integer_native

Set the integer value of this PMC

-=item __set_integer_same
+=item set_integer_same

-=item __set_integer_keyed
+=item set_integer_keyed

-=item __set_integer_keyed_int
+=item set_integer_keyed_int

-=item __set_integer_keyed_str
+=item set_integer_keyed_str

-=item __set_number_native
+=item set_number_native

Set the floating-point value of this PMC

-=item __set_number_same
+=item set_number_same

-=item __set_number_keyed
+=item set_number_keyed

-=item __set_number_keyed_int
+=item set_number_keyed_int

-=item __set_number_keyed_str
+=item set_number_keyed_str

-=item __set_bignum_int
+=item set_bignum_int

Set the extended-precision value of this PMC

-=item __set_string_native
+=item set_string_native

Set the string value of this PMC

-=item __set_string_same
+=item set_string_same

-=item __set_string_keyed
+=item set_string_keyed

-=item __set_string_keyed_int
+=item set_string_keyed_int

-=item __set_string_keyed_str
+=item set_string_keyed_str

-=item __set_bool
+=item set_bool

Set the true/false value of this PMC

-=item __assign_pmc
+=item assign_pmc

Set the value to the value of the passed in

-=item __set_pmc
+=item set_pmc

Make the PMC refer to the PMC passed in

-=item __set_pmc_keyed
+=item set_pmc_keyed

-=item __set_pmc_keyed_int
+=item set_pmc_keyed_int

-=item __set_pmc_keyed_str
+=item set_pmc_keyed_str

-=item __set_pointer
+=item set_pointer

-=item __set_pointer_keyed
+=item set_pointer_keyed

-=item __set_pointer_keyed_int
+=item set_pointer_keyed_int

-=item __set_pointer_keyed_str
+=item set_pointer_keyed_str

-=item __elements
+=item elements

Return the number of elements in the PMC, if the PMC is treated as an
aggregate.

-=item __pop_integer
+=item pop_integer

-=item __pop_float
+=item pop_float

-=item __pop_string
+=item pop_string

-=item __pop_pmc
+=item pop_pmc

-=item __push_integer
+=item push_integer

-=item __push_float
+=item push_float

-=item __push_string
+=item push_string

-=item __push_pmc
+=item push_pmc

-=item __shift_integer
+=item shift_integer

-=item __shift_float
+=item shift_float

-=item __shift_string
+=item shift_string

-=item __shift_pmc
+=item shift_pmc

-=item __unshift_integer
+=item unshift_integer

-=item __unshift_float
+=item unshift_float

-=item __unshift_string
+=item unshift_string

-=item __unshift_pmc
+=item unshift_pmc

-=item __splice
+=item splice

-=item __add
+=item add

-=item __add_int
+=item add_int

-=item __add_float
+=item add_float

-=item __subtract
+=item subtract

-=item __subtract_int
+=item subtract_int

-=item __subtract_float
+=item subtract_float

-=item __multiply
+=item multiply

-=item __multiply_int
+=item multiply_int

-=item __multiply_float
+=item multiply_float

-=item __divide
+=item divide

-=item __divide_int
+=item divide_int

-=item __divide_float
+=item divide_float

-=item __modulus
+=item modulus

-=item __modulus_int
+=item modulus_int

-=item __modulus_float
+=item modulus_float

-=item __cmodulus
+=item cmodulus

-=item __cmodulus_int
+=item cmodulus_int

-=item __cmodulus_float
+=item cmodulus_float

-=item __neg
+=item neg

-=item __bitwise_or
+=item bitwise_or

-=item __bitwise_or_int
+=item bitwise_or_int

-=item __bitwise_and
+=item bitwise_and

-=item __bitwise_and_int
+=item bitwise_and_int

-=item __bitwise_xor
+=item bitwise_xor

-=item __bitwise_xor_int
+=item bitwise_xor_int

-=item __bitwise_ors
+=item bitwise_ors

-=item __bitwise_ors_str
+=item bitwise_ors_str

-=item __bitwise_ands
+=item bitwise_ands

-=item __bitwise_ands_str
+=item bitwise_ands_str

-=item __bitwise_xors
+=item bitwise_xors

-=item __bitwise_xors_str
+=item bitwise_xors_str

-=item __bitwise_not
+=item bitwise_not

-=item __bitwise_shl
+=item bitwise_shl

-=item __bitwise_shl_int
+=item bitwise_shl_int

-=item __bitwise_shr
+=item bitwise_shr

-=item __bitwise_shr_int
+=item bitwise_shr_int

-=item __concatenate
+=item concatenate

-=item __concatenate_native
+=item concatenate_native

-=item __is_equal
+=item is_equal

-=item __is_same
+=item is_same

-=item __cmp
+=item cmp

-=item __cmp_num
+=item cmp_num

-=item __cmp_string
+=item cmp_string

-=item __logical_or
+=item logical_or

-=item __logical_and
+=item logical_and

-=item __logical_xor
+=item logical_xor

-=item __logical_not
+=item logical_not

-=item __repeat
+=item repeat

-=item __repeat_int
+=item repeat_int

-=item __increment
+=item increment

-=item __decrement
+=item decrement

-=item __exists_keyed
+=item exists_keyed

-=item __exists_keyed_int
+=item exists_keyed_int

-=item __exists_keyed_str
+=item exists_keyed_str

-=item __defined
+=item defined

-=item __defined_keyed
+=item defined_keyed

-=item __defined_keyed_int
+=item defined_keyed_int

-=item __defined_keyed_str
+=item defined_keyed_str

-=item __delete_keyed
+=item delete_keyed

-=item __delete_keyed_int
+=item delete_keyed_int

-=item __delete_keyed_str
+=item delete_keyed_str

-=item __nextkey_keyed
+=item nextkey_keyed

-=item __nextkey_keyed_int
+=item nextkey_keyed_int

-=item __nextkey_keyed_str
+=item nextkey_keyed_str

-=item __substr
+=item substr

-=item __substr_str
+=item substr_str

-=item __invoke
+=item invoke

-=item __can
+=item can

-=item __does
+=item does

-=item __isa
+=item isa

-=item __freeze
+=item freeze

-=item __thaw
+=item thaw

-=item __thawfinish
+=item thawfinish

-=item __visit
+=item visit

-=item __share
+=item share

=back

-=head1 TRANSLATION AND GLOSSARY
+=head1 LANGUAGE NOTES

-Since every object system on the planet shares a common set of terms but uses
-them completely differently, this section defines
+This PDD is due an overhaul. This requirements section is for language
+implementers to list the OO-related needs of their language in so as to aid
+that.

-=head2 Glossary
+=head2 PMCS

-=over 4
+Ruby: Just like small talk, everything is an object. I'm hoping to be able to
+implement core Ruby classes(String, Array, Hash, Module, etc) something like this.

-=item Property
+ParrotClass
+ |
+ RubyClass String
+ | |
+ \ /
+ RubyString

-A name and value pair attached to a PMC. Properties may be attached to the PMC
-in its role as a container or the PMC in its role as a value.
+=head2 Objectspace

-Properties are global to the PMC. That is there can only be one property named
-"FOO" attached to a PMC, and it is globally visible to all inspectors of the
-PMCs properties. They are I<not> restricted by class.
+Ruby: Objectspace in ruby allows the programmer to iterate through every live object
+in the system. There is some debate about how to make this play nice with different
+garbage collection schemes.

-Properties are generally assigned at runtime, and a particular property may or
-may not exist on a PMC at any particular time. Properties are not restricted to
-objects as such, and any PMC may have a property attached to it.
+=head2 Classes

-=item Attribute
+A class is a collection of methods and attributes. It would be desirable, for
+those classes whose definition is fully known at compile time, to have a
+convenient way to have the class along with its attributes and methods stored
+into a PBC file rather than created at runtime. However, creation of new
+classes at runtime will be needed too.
+
+=head2 Meta-classes

-An attribute is a slot in an object that contains a value, generally a PMC.
-(Containing non-PMCs leads to interesting garbage collection issues at the
-moment) Attributes are referenced either by slot number or by class
-name/attribute name pairs. (At least conceptually)
-
-Attributes are set on a class-wide basis, and all the objects of a class will
-have the same set of attributes. Generally attributes aren't added or removed
-from classes at runtime, as this would require resizing and moving the elements
-of the attribute arrays of existing objects, and potentially recompiling code
-with fixed attribute offsets embedded in it. Most OO languages don't allow
-attribute changes to existing classes, though parrot's base attribute system
-does allow this.
-
-The fully qualified name of an attribute is the classname, a null, and the
-attribute name. Parrot synthesizes the fully-qualified name where it needs to.
-
-=item Method
-
-In its strictest sense, a method is a chunk of code that you call with an
-object in the object slot of the calling conventions.
-
-More generally, a method is some piece of code that you invoke by name through
-an object. You call the object's "Invoke a method" vtable entry, passing in the
-method name (Assuming we don't just get it from the sub name register, per
-calling conventions). The object is then responsible for doing something with
-the method being requested. Presumably it calls the method, though this isn't
-strictly required.
+Ruby: Ruby has meta classes. It would be nice if classes were objects in Parrots OO model.

-=item Delegate
+=head2 Attributes

-An object that is transparently (to the user) embedded in another object.
-Delegate objects are used in those cases where we can't inherit from a class
-because the class is from a different object universe.
+Attributes are instance data associated with a class (or role, however those
+are supported). They may not always be of a type specified by a PMC, though
+boxing/unboxing is of course an option.

-As an example, assume you have a class A, which inherits from class B. The
-classes are incompatible, so Parrot can't automatically meld B into A, as it
-might if they were. When instantiating an object of class A, Parrot will
-automatically instantiate an object of class B and embed it in the object of
-class A. The object of class B is class A's delegate--when a method call comes
-in that A can't handle, that method call is delegated to B.
+Perl 6: All attributes are opaque (not externally visible, even to any
+subclasses).

-=item Parent class
+.Net: Attributes may be private (not externally visible), public (always
+externally visible), protected (only visible to subclasses) and internal
+(only visible inside the current assembly - the closest correspondence in
+Parrot is perhaps only visible inside the same PBC file). Additionally, it
+is allowable for a subclass to introduce an attribute of the same name as
+the a parent class has, and they both exist depending on what type an
+instance of the class is currently viewed as being (read: there is a
+difference between the type of the reference and the type of the value).

-Also called the super-class. The parent class is, in an inheritance situation,
-the class being derived from. If A derives from B, B is the parent class of A.
+Ruby: Attributes can be dynamically added and removed at runtime.

-=item Child class
+=head2 Methods
+
+Perl 6: Methods may be public (anyone can invoke them) or private (only
+invokable by the class they are defined in). Additionally, submethods are
+methods that do not get inherited.
+
+.Net: Like attributes, methods may be public, private, protected or internal.
+
+Ruby: has a method_missing that gets called when method resolution fails to find a method.
+Methods can be dynamically added and removed at runtime.
+
+=head2 Constructors
+
+A constructor is run when an object is instantiated.
+
+.Net: There may be many constructors for an object (provided they all have
+different signatures), and the correct one is called based upon the passed
+parameters.
+
+=head2 Inheritance
+
+Perl 6: Multiple inheritance.
+
+.Net: Single inheritance.
+
+Ruby: Single inheritance but support for mixins of ruby modules.
+
+=head2 Interfaces
+
+An interface specifies a set of methods that must be implemented by a class
+that inherits (or implements) the interface, but does not provide any form of
+implementation for them.
+
+.Net: Interfaces are pretty much what was just describe above. XXX Need to
+check behavior of you implement two interfaces with methods of the same name.
+
+=head2 Roles
+
+A role consists of a set of methods and attributes. It cannot be instantiated
+on its own, but must be composed into a class. When this happens its methods
+and attributes become of that classes methods and attributes. This may happen
+at compile time or runtime, however when a role is composed into a class at
+runtime then what really happens is that a new anonymous class is created with
+the role composed into it and then the namespace entry for the existing class is
+updated to refer to the new one. Note that this means classes must be garbage
+collectable, with all those referred to by a namespace or with objects of that
+class existing being marked live.
+
+Perl 6: Roles pretty much are a Perl 6 thing, so the definition above contains
+all that is needed. An open question is whether Parrot worry about collision
+detection? For compile time composition that's easy to punt to the compiler;
+for runtime composition, that's not so easy though.
+
+=head2 Introspection (aka Reflection)
+
+Perl 6: Reflection provides access to a list of methods that a class has, its
+parent classes and the roles it does, as well as the name of the class and its
+memory address. For methods, their name, signature, return type and whether
+the method is declared multi are available.
+
+.Net: Reflection provides access to a list of attributes and methods as well as
+the name of the class and its parent. The types of attributes and signatures of
+methods are also available.
+
+=head2 Inner Classes
+
+An inner class is essentially a class defined within a class. Therefore it has
+access to things private to its outer class.
+
+Perl 6: Inner classes are allowed, and may also be private.
+
+.Net: Inner classes are allowed and may be private, public, protected or
+internal.
+
+=head2 Delegation
+
+Delegation is where a method call is "forwarded" to another class. Parrot may
+provide support for simple cases of it directly, or could just provide a "no
+method matched" fallback method that the compiler fills out to implement the
+delegation.
+
+Perl 6: Delegation support is highly flexible, even allowing a regex to match
+method names that should be delegated to a particular object.
+
+=head2 Prototype-based OO
+
+Prototype-based OO has no classes. All objects are cloned from existing
+objects and modified. Requires lightweight singleton creation, without a
+needing separate class for every instance object. (Self, JavaScript, and
+Io are examples of prototype-based 00.)
+
+=head1 QUESTIONS
+
+Should we have a super or next opcode?
+
+=head1 NOTES
+
+=head2 Interaction with PMCs
+
+The interaction between objects and PMCs is currently underspecified.

-Also called the sub-class. The child class is, in an inheritance situation, the
-class doing the deriving. If A derives from B, A is the child class.

-=back

=head2 Translation

@@ -1195,61 +1141,9 @@

None.

-=head1 VERSION
-
-=head2 CURRENT
-
- Maintainer: Dan Sugalski
- Class: Internals
- PDD Number: 15
- Version: 1.2
- Status: Developing
- Last Modified: February 09, 2004
- PDD Format: 1
- Language: English
-
-=head2 HISTORY
+=cut

-=over 4
-
-=item Version 1.3
-
-April 3, 2004
-
-=item Version 1.2
-
-February 9, 2004
-
-=item Version 1.1
-
-March 11, 2002
-
-=item version 1
-
-None. First version
-
-=back
-
-=head1 CHANGES
-
-=over 4
-
-=item Version 1.3
-
-Removed some unimplemented notes. Changed vtables to get_*, set_* so that they
-match other vtable function syntax.
-
-=item Version 1.2
-
-A complete overhaul from the original spec.
-
-=item Version 1.1
-
-Removed attributes from the object interface and put them in the class
-interface section, where they belong.
-
-=item Version 1.0
-
-None. First version
-
-=back
+__END__
+Local Variables:
+ fill-column:78
+End:

0 new messages