[Grace-core] Semantics of object/classes

Marco Servetto marco.servetto at gmail.com
Thu Aug 9 16:06:30 PDT 2012


>>
>>In terms of the fundamental issues, I (not surprisingly) have some differences with Andrew.  While I agree 100% that the public >>interface of an object is the methods, I believe we all think of objects as consisting of behavior and state.  Put differently, objects will >>need an initial state, and that state may be changed via method requests on the object.
>>
>>When we create objects we need to allocate the state, initializing it appropriately, and install the behaviors by associated actions with >>the method names.

I do not think all " think of objects as consisting of behavior and state"
For example in the object calculus objects have only methods,
(including constant methods)
and methods can be updated.
So one can rephrase your sentence talking only about behaviour in the
following way:
---------
|objects will need an initial behaviour, and that behaviour may be
changed via method requests on the object.
|When we create objects we need to choose the initial behaviour appropriately.
--------
I think this kind of formulation is more appropriate for languages
like newspeak and grace.

----------------------------------------------------
Answering to James:
>>inheriting from the result of a factory method
As more I think about it as more I found it very misleading.
I think what we **really* would like to say is:
inheriting from a *non yet used* object

--This pushed me to provide yet another variation:
we could imagine a semantic model where we have this init method, and
when the object is created then the method is NOT executed.
when for the first time a message is sent to the object, then the init
method is executed, the object is marked as ready, and then the
message(s) can be processed.
In this way our semantic could provide an error if one inherits from
an object that is already init(ialized) and,
on the other side, while extending the object we can redefine init to
do the right think.
This will break the
 "inherit from any object" and turn it into
"inherit from any not yet used object"

This logic would require "in line initializer" to NOT use self, and
they are going to be executed when the object creation expression is
evaluated, while other initialized can be inside the init method, and
using self.


More information about the Grace-core mailing list