Re: identity...... Was: The wisdom of the object mentors
- From: "Mark Nicholls" <Nicholls.Mark@xxxxxxxxx>
- Date: 8 Jun 2006 03:55:19 -0700
Dmitry A. Kazakov wrote:
On 7 Jun 2006 04:10:05 -0700, Mark Nicholls wrote:
Dmitry A. Kazakov wrote:
On 6 Jun 2006 09:41:57 -0700, Mark Nicholls wrote:
Dmitry A. Kazakov wrote:
And the value returned is what?
the current state.....if my model is of a 2D vector...then an ordered
pair <x,y>
Is it the value of the object's type or of some different type?
Do I understand the question....it is the objects state.
if the vector is <2,3> then among one of it's many of it's types is
{ "(a.XCoord() == 2) && (a.YCoord() == 3)" }
To me a type is just a set of propositions that are true.....it is a
description independent of the universe of objects.....we can observe
what objects with a universe obey this type definition and if I go....
Hmm, how are you going to check such types? I mean the propositions that
are true but cannot be proved, due to incompleteness?
then you have objects that potentially are conformant with a type
definition but not provably....some things are true and not
provable.....makes compiler design a tad hard.
In the real world I should think most (executable) computer models
(rather than the analysis models) are complete, though you could have a
few hard things to prove in there!
At least in C++ 'this' does not return the object's value, but a pointer.
What you refer is in C++ the following:
void Bar::Foo
{
this->Bar::Baz ();
// Get a pointer to an object of class Bar (=this)
// Dereference the pointer (gives an object of class Bar)
// Get a value of Bar, yields an object of type Bar
// Call Baz on the object of type Bar
}
!
what I am refering to is...
class 2DVector
{
// this is it's state
private int[] state = new int[2] { 0,0 };
....
....
// this is it's implementation/mapping from a hidden domain of {int x int}
void SetYCoord(int newY)
{
// !!!!! how does the implementation access it's state....noone else.s....
// the state that is uniquely *identified* with the object?
// answer using "this".
this->state[2] = newY;
}
}
Fine. Now, I see the word "int" there. What is the states of? What is the
state of state[2]? What is the state of the result of "new int[2]"? What is
the state of 2?
I don't care what it's internal state is, only it's behaviour.
Ultimately I will get down to some state representation in terms of
sets.....(if I choose ZFC).....or bits (if I choose digital
computers).....tape if I choose Turing machines.....integers are far
enough really....I 'believe' in them enough not to worry too much.
In many languages there is
nothing like that. 'This' is an artefact of prefix notation. The name for a
hidden parameter of a subprogram.
in these languages how does an object implementation access it's state?
How do you access the state otherwise? Using methods.
using methods on what? on 'this'....on it's identity.
On the object. 'This' returns a pointer to. After derefencing it you get an
object (usually the "same" as it was before) and can apply methods on it.
this is splitting hairs, you're arguing about the syntax of '->'
against '.', you can have it either way...I'm not fussed.
No. My problem is that it is not obvious to me how does your model handle
pointers and ints. It looks like you have postulated them. I find it
unsatisfactory. I don't want to postulate anything except, maybe, cells on
the Turing machine's tape.
I can construct the integers using ZFC in the normal manner....it is
consistent with the model.
lets not use '->' lets use '.', and then I don't need pointers for the
moment.
I am not claiming to know all the answers and be able to write an OOP
tomorrow that supports all this....I am simply claiming to have some
interpretations of concepts that are useful and incisive (to me), but
seem differently labelled to yours.
void Bar::Foo
{
this->Baz ();
// Get a pointer to an object of class Bar (=this)
// Dereference the pointer (gives an object of class Bar)
// Call method Baz on the object of class Bar (dispatch)
Baz (); // A syntax sugar for the above
}
I am not really interested in private interfaces except in the context
of accessing state....then we can simply define 2
methods....GetState(), SetState()......all else is just implementation
detail.
OK, but that detail is written in a language, so there must be an
interpretation of that's going on.
I'm not very good with the interpretation of variables, I've never
really got my head around it.
I think I like to think of them as prefixed labels.
e.g.
the variable I is really In.....i.e. when we go I = I + 1....
we're really going I<n+1> = I<n> + 1
SetState(value)....would then be going....
State<n+1> = value.
GetState(value) would return the 'current' State<n>....
what does my head in is GetState needs to know the current 'latest'
value of 'n'.
n now is a variable and thus the construction seems to fail......it
seems pretty trivial...but I'm missing something.....or worrying about
nothing.
So when you say "type", I will read "class type", or "implementation
type".
The question is about the minimal set of simple concepts we could reduce
the variety of concepts found in programming languages.
that is why I defined the things below.....these are my basic concepts.
The language confusion is doing my head in.
loosely.
type = { set of propositions }
I'd say that the set of all propositions is language defined behavior or
semantics.
?
a type is just a set of propositions in the language....not the set of
all propositions.
If I choose peano's postulates.....then I end up with a type that N
obeys.
interface = { set of signatures i.e. a language }
class = { definition of a set of objects in a universe, that
'implement' a language/interface }......
implementation = { mapping from some hidden universe of values/state }
object = member of a class.
I'm not completely happy with these definition....it's much easier to
drop 'object'....and talk about sets of values.....the difference (to
me) is minimal.
I think that the difference is that object is a run-time thing described by
the language.
my problem is variables.
OO has this notion of objects having variable state....to me actually
the power of OO is largely independent of this notion.....but I can't
get my head around variables.
Variables would exist in the language.....so objects would.
It probably is possible to talk about classes and leave the
implementation blank.
It is possible to talk about types, but not to actually know what
universe of objects it is going to apply to.
So values can't change type.
Objects can change type.
classes cannot change type.
I don't see how it happens. If class does not change the type and object is
a member of class... is type_of transitive along member_of?
types of objects, no.
i.e. the integer 1 obeys the type
A = { "a == 1" }
so typeof(a,A) == true......a is of type A (and many many many other
types)
then we go a = a+1
typeof(a,A) == false........a has changed some of it's types....A in
this example
If I consider a type that (all) the (members) of the class integer
obey.
e.g.
B = { "there exists and interger b s.t. b = a+1" }
then any 'object' representing an int will obey this definition
whatever we do to it...a member cannot change it's class (this is a
mathematical int, not a computer int).
Polymorphic object: (class, (type, value))
polymorphism to me is the substitution of a different
(implementation,value).
Before substitution you have to define "polymorphic object." Are all
objects polymorphic?
ummmmm.....yes....for the moment anyway.
Are true, 123, "a" polymorphic?
true is a member of the language, you are free to define a seperate
class 'boolean'...but it is *not* the same.....else stratification is
broken.
"a".....depends what you mean......."a" as a label exists in the
language, but again you are free to define a class 'string' with can
represent an "a".....just don't try to equate them, as you could be in
danger.
Class need to be known only if the object is
polymorphic. What is the class of integer? Is it numeric, real, complex,
vector, matrix? When you do '+' on integers is the class relevant?
what is a 'class'?
A new type constructed from some set of types. Each value of the class is a
par (type, value), where type is one of the set and value is of the type.
Such values of the class are called polymorphic.
Plain type int can have values 1, 2, 452 etc.
Class numeric built out of int and real can have values (int, 1), (int 2),
(int 452), (real, 1.0), (real, 2.0), (real, 452.0) etc. When you call +
defined on numeric it takes parameters from the class, i.e. you can add
(int, 1) + (int, 2), this will dispatch to integer 1 + 2. When you add
(int. 1) + (real, 2) you have multiple dispatch. Note that in 1 + 2, there
is no any class. The identity of 1 is lost. You don't know the history, how
it came to int 1. It could be (string, "1") before, from the class
UDP_packet. Why should + care?
You can loose class
identity upon dispatch. You shall loose it if you deal with int, Boolean
etc classes.
you'll have to demonstrate that.
That's easy. Boolean object has no place to keep the class identity. It is
only one bit long. So the only way is to know it is to do it statically.
But if it is statically known why would you dispatch?
isn't this an implementation detail.
OK. How can you distinguish true of Boolean from true of some Boolean
descendant? Consider an endless derivation chain:
Boolean <- Boolean1 <- Boolean2 ...
Now write a program that takes true and tells if it is Boolean34532.
If I'd wish to do this I would define a method on the interface
IsBoolean1, extend the next one IsBoolean2, next IsBoolean3.....etc...
So as long as IsBoolean2 isn't defined BooleanX == Boolean2? It is
inconsistent, You want identity of objects but so far you have lost one of
types!
not with this....actually my constuction was slightly amiss....
class Bool1
{
bool IsBool1() { return true; }
bool IsBool2() { return false; }
bool IsBool3() { return false; }
bool IsBool4() { return false; }
.....etc
}
class Bool2 : Bool1
{
override bool IsBool2() { return true; }
}
class Bool<N+1> : Bool<N>
{
override bool IsBool<N+1>() { return true; }
}
You have constructed some types which aren't Boolean. Let's talk about
bool. Let I change the first declaration to:
class Bool1 : public bool
{
bool IsBool1() { return true; }
...
};
Is true Bool1 and what does true.IsBool1() return?
according to that construction it is not defined....compile errror.
lets try
class Bool1
{
// implementation of a boolean variable.
Bool1 And(Bool1,Bool1);
.......
Bool1 IsBool1() { return new Bool1(1); }
Bool1 IsBool2() { return new Bool1(0); }
...
};
class Bool2 : Bool1
{
override bool IsBool2() { return new Bool1(1); }
}
.....
true.IsBool1() is not defined.....in fact in this model true (in the
model) does not exist.
If you want we can label a special member of Bool1 as 'true'.....how
about Bool1(1).
so true.IsBool1() is defined to return true (i.e. IsBool1(1)).
I can't remember what the point was?
I don't really like implementation inheritance, so the above
construction irks me somewhat, so you're really asking an aethiest to
construct the concepts of good and evil in theological terms.
I don't have a lot of the answers, and the ones I have may be
wrong....I have a fuzzy picture of whats going on, but there are some
big gaps.....variables being the biggest.....I never did llamda
calculus.......thus my dislike to volatile state.....without volatile
state it all seems relatively trivial.......relative to something
really really hard.
.
- Follow-Ups:
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- References:
- identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- Re: identity...... Was: The wisdom of the object mentors
- From: Mark Nicholls
- Re: identity...... Was: The wisdom of the object mentors
- From: Dmitry A. Kazakov
- identity...... Was: The wisdom of the object mentors
- Prev by Date: Re: What is polymorphism?
- Next by Date: Re: What is polymorphism?
- Previous by thread: Re: identity...... Was: The wisdom of the object mentors
- Next by thread: Re: identity...... Was: The wisdom of the object mentors
- Index(es):
Relevant Pages
|
|