What does "object-oriented [programming]" mean to you?
(No tutorial-like introduction is needed, just a short
explanation [like "programming with inheritance,
polymorphism and encapsulation"] in terms of other concepts
for a reader familiar with them, if possible. Also, it is
not neccessary to explain "object", because I already have
sources with your explanation of "object" from
"Early History of Smalltalk".)
I've read the Early History of Smalltalk, by the way. I think I
understand what he means by ``messaging'', ``local retention and
protection'' and ``hiding of state-process''. My knowledge reaches its >limits a bit in ``extreme late-binding of all things'' and I get
certainly puzzled in ``it can be done in Smalltalk and in LISP'' given
that he is ``not aware of [others]''.
Now, to address my main puzzle. The email is from 2003. Alan Kay was >certainly aware of Python, Java and so on. Why would his notion of OOP
be impossible in Python or Java?
ifTrue: aBlock
^aBlock value
and "False" with
ifTrue: aBlock
^nil
Maybe he requires metaclasses. Well, Python has them!
I think he mentions late-binding because I suppose that is required for
OOP in static languages like C++, say.
Now, to address my main puzzle. The email is from 2003. Alan Kay was certainly aware of Python, Java and so on. Why would his notion of OOP
be impossible in Python or Java?
Salvador Mirzo <smirzo@example.com> wrote or quoted:
I've read the Early History of Smalltalk, by the way. I think I
understand what he means by ``messaging'', ``local retention and >>protection'' and ``hiding of state-process''. My knowledge reaches its >>limits a bit in ``extreme late-binding of all things'' and I get
certainly puzzled in ``it can be done in Smalltalk and in LISP'' given
that he is ``not aware of [others]''.
Object-oriented programs contain expressions to describe the sending
of messages at runtime. Here's an example of such an expression:
o s: x
. "o" is the receiver object, "s" the selector (keyword) of the
message, and x is an argument.
"Extreme late-binding of all things" to me (S. R.) means
that it is possible to give the the values of "o" and "x"
(including their types) only as late as immediately before
"o s: x" is being evaluated (executed).
Now, to address my main puzzle. The email is from 2003. Alan Kay was >>certainly aware of Python, Java and so on. Why would his notion of OOP
be impossible in Python or Java?
He might have some criteria he has not mentioned.
For example, in Smalltalk, blocks of code are objects, too,
and you can define your own custom bool type and "if" statement
using Smalltalk and such blocks. Maybe he requires that, in
an object-oriented language, blocks of code are objects, too. [1]
In LISP, you can have code values using "LAMBDA", and maybe
that's the criterion Alan Kay used, as both Smalltalk and LISP
have code block as run-time values.
In Python and in Java there also are non-object-oriented features,
and maybe he requires that, in an object-oriented programming
language, everything has to be done in an object-oriented way;
what might be called a "/pure(ly)/ object-oriented language".
[1]
So, you define two classes "True" with
ifTrue: aBlock
^aBlock value
and "False" with
ifTrue: aBlock
^nil
. Now we have implemented an if statement using polymorphism
that can be used as:
a > 0 ifTrue: [a := 0]
. I have not checked this code on a Smalltalk implementation.
Maybe it needs some additions or modifications, but it gives
the general idea.
An attempt to emulate this in Python:
main.py
class True_:
def if_true( self, block ):
exec( block )
class False_:
def if_true( self, block ):
pass
class Boolean_:
def __new__( self, value ):
return True_() if value else False_()
a = -2; Boolean_( a < 0 ).if_true( "print( 'It is true!' )" )
a = +2; Boolean_( a < 0 ).if_true( "print( 'It is true!' )" )
output
It is true!
Interesting. What is the class of these objects that are blocks of
code? (Thanks for the awesome example in [1].)
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,028 |
Nodes: | 10 (0 / 10) |
Uptime: | 135:42:22 |
Calls: | 13,330 |
Calls today: | 2 |
Files: | 186,574 |
D/L today: |
747 files (185M bytes) |
Messages: | 3,355,476 |