Topic: Design flaw overlooked by CFront 3.0 implementation.
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Wed, 17 Nov 1993 10:31:56 GMT Raw View
In article <rfgCGIyvD.J44@netcom.com> rfg@netcom.com (Ronald F. Guilmette) writes:
>
>The bottom line is that we lack an adequate algebra of dynamic types, and
>thus, the term "dynamic type" currently has little if any useful meaning.
I say it differently. Dynamic type is easy to understand,
what is missing is an object model. In my view, for 'class' objects,
an object has a type: that of the constructor that initialised it,
and dynamic type incorrectly referes to the type of an expression
instead of refering to the type of the object which the expression
denotes .. which is unambiguous and well defined if, and only if,
the proper notions of what an object is are put in place.
I'm working on it .. the hard bit is that C like objects
(eg standard types) dont have constructors,
so the 'class' object model doesnt cover them.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd, CSERVE:10236.1703
6 MacKay St ASHFIELD, Mem: SA IT/9/22,SC22/WG21
NSW 2131, AUSTRALIA
Author: jamshid@ses.com (Jamshid Afshar)
Date: Thu, 11 Nov 1993 00:07:01 GMT Raw View
In article <rfgCG07LD.82A@netcom.com>,
Ronald F. Guilmette <rfg@netcom.com> wrote:
>My usual question: Where do it say that??
>Looking at the 6/1/93 X3J16 draft, I see:
> "In the second alternative (delete array) if the dynamic type of
> the object to be deleted is a class that has a destructor and its
> static type is different from its dynamic type, the result is
> undefined."
>There only one problem here... Where are these terms "static type" and
>"dynamic type" defined? How can one know what the "static type" of the
>"object to be deleted" is? How can one know what it's "dynamic type" is
>(other than via intuition)?
In section 1.4 Definition of Terms (fancy that):
...
Static type -- The static type of an expression is the type
resulting from analysis of the program without consideration
of execution semantics. It depends only on the form of the
program and does not change.
Dynamic type -- The dynamic type of an expression is determined
by its curent value and may change during the execution of a
program. If a pointer whose static type is "pointer to class B"
is pointing to an object of class D ... the dynamic type of the
pointer is "pointer to D". References are treated similarily.
And they're referenced in the index.
Jamshid Afshar
jamshid@ses.com
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Mon, 15 Nov 1993 08:42:49 GMT Raw View
In article <CGAwBq.M3@ses.com> jamshid@ses.com (Jamshid Afshar) writes:
>In article <rfgCG07LD.82A@netcom.com>,
>Ronald F. Guilmette <rfg@netcom.com> wrote:
>>My usual question: Where do it say that??
>>Looking at the 6/1/93 X3J16 draft, I see:
>> "In the second alternative (delete array) if the dynamic type of
>> the object to be deleted is a class that has a destructor and its
>> static type is different from its dynamic type, the result is
>> undefined."
>>There only one problem here... Where are these terms "static type" and
>>"dynamic type" defined? How can one know what the "static type" of the
>>"object to be deleted" is? How can one know what it's "dynamic type" is
>>(other than via intuition)?
>
>In section 1.4 Definition of Terms (fancy that):
> ...
> Static type -- The static type of an expression is the type
> resulting from analysis of the program without consideration
> of execution semantics. It depends only on the form of the
> program and does not change.
>
> Dynamic type -- The dynamic type of an expression is determined
> by its curent value and may change during the execution of a
> program. If a pointer whose static type is "pointer to class B"
> is pointing to an object of class D ... the dynamic type of the
> pointer is "pointer to D". References are treated similarily.
>
>And they're referenced in the index.
Thank you Jamshid for correcting my error. Obviously, these terms *are*
defined... even if only vaguely.
My fundamental problem is with the definition of "dynamic type". Back in
the good old days of C, there was only one type for any expression, and it
was essentially equivalent to what is now being called the "static type".
But here we are in the New Age, and now we have expressions, each of which
can simultaneously have two different types, i.e. the static one and the
dynamic one.
I can easily look at a hunk of code and tell you what the "static type" of
that expression is (because I know the rules I must use to deduce this type)
but I am altogether less sure that *anyone* can reliably tell me what the
dynamic type of some given expression must be... even if given both the
complete source code for the entire program *and* the complete execution
history of the program up until the point when the question is asked.
Why do I say this? Well, quite simply, it is my claim that both the ARM
and the current X3J16 working paper are inadequate when it comes to specifying
the rules by which a given expression comes to have this dynamic type or
that dynamic type. As a simple example, given the declarations:
base *bp;
derived *dp;
and the assignment statement:
bp = dp;
where is it stated that after this assignment, the dynamic type of the ex-
pression `bp' is type `derived*'?
(This is just a trivial example... and one which may actually be covered by
the current text... but I feel confident that I can easily provide drastically
more compelling examples involving, for instance, dimond shaped inheritance
DAGs, etc.)
The bottom line is that we lack an adequate algebra of dynamic types, and
thus, the term "dynamic type" currently has little if any useful meaning.
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Fri, 5 Nov 1993 05:36:45 GMT Raw View
In article <27019@alice.att.com> ark@alice.UUCP () writes:
>In article <1993Oct27.212641.5793@datascope.com> p_p@.datascope.com (Patrick Palmer) writes:
>
>> The flaw is with the deletion of array of objects. The problem occurs when
>> using a pointer to an array of base classes to delete an array of derived
>> classes.
>
>You're not supposed to do that.
>
>When you say `delete,' you must use a pointer of the same type as you
>got from `new' or of a base class of that type. `array of base' is
>not a base class of `array of derived.'
My usual question: Where do it say that??
Looking at the 6/1/93 X3J16 draft, I see:
"In the second alternative (delete array) if the dynamic type of
the object to be deleted is a class that has a destructor and its
static type is different from its dynamic type, the result is
undefined."
There only one problem here... Where are these terms "static type" and
"dynamic type" defined? How can one know what the "static type" of the
"object to be deleted" is? How can one know what it's "dynamic type" is
(other than via intuition)?
Shouldn't these terms be defined somewhere? Also, if a given object really
can have two (or more) different types at the same time, shouldn't there
be some rules written down which tell me how to figure out what the dynamic
type of an object must be and (separately) what the static type(s) of that
object must be?
(Follow-ups to comp.std.c++ please.)
--
-- Ronald F. Guilmette, Sunnyvale, California -------------------------------
------ domain address: rfg@netcom.com ---------------------------------------
------ uucp address: ...!uunet!netcom.com!rfg -------------------------------