Thread View: comp.std.c++
1 messages
1 total messages
Started by Limsoon Wong
Mon, 06 Aug 1990 16:04
the most dissatisfying part of c++
Author: Limsoon Wong
Date: Mon, 06 Aug 1990 16:04
Date: Mon, 06 Aug 1990 16:04
74 lines
2716 bytes
2716 bytes
first a message from jeremy grodberg,
--------------------------------X----------------------------
Sorry I can't post this, but our posting software is broken. You can post this
for me if you like.
Why would you want to have a function that returns an a& be allowed to
replace a b object *as a default*. It is inherently dangerous, since
the function only affects the "a" part of b, which, for operators like
+ and = is probably not sufficient. The sample code you wrote shows that
the function test really should be defined as returning void, so that you
would write:
B.test();
B = B;
--
Jeremy Grodberg
jgro@apldbio.com "Beware: free advice is often overpriced!"
--------------------------------X----------------------------
my reply:
the suggestion is a valid alternative, though the assignment
`B = B' is unnecessary. however, that is not what
i am getting at.
i am mere pointing out what i consider the part of c++ that
requires improvement: unnecessary loss of type information.
it is clear that before and after performing `B.test()',
the object identity of `B' remains invariant. hence, `B'
and `B.test()' should be given the same type. but `B.test()'
is given type `a', which is much weaker than `b'.
it is very annoying to have an object that gets progressively
weaker every time you do something to it.
more comments on other replies:
the template suggestion was a very good try. but it does
not work in general. nevertheless, modifications to c++'s
type specification along tha line seems to be the most
satisfactory solution.
i would like a keyword `SUB' to be used as type in class
specification in the following way.
class C { public:
(...SUB...) f(..);
A p(..SUB...);
};
class D : public C {
something
};
where `(...SUB...)' is any type expression involving `SUB'.
let `d' be a class `D' object. i want
d.f be given the type * (..) -> (...D...)
d.p be given the type * (..D...) -> A
that is, `SUB' is a place holder. it gets replaced by the
corresponding subclass. i think it does not complicate type
checking or implementation; in particular, its with multiple
inheritance. therefore, i do wish something like this be provided.
limsoon.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads