Re: Question about programming techniques
- From: Andreas Kostyrka <andreas ag or at>
- To: "Andrew V. Shuvalov" <andrew ecsl cs sunysb edu>
- cc: "gnome-list gnome org" <gnome-list gnome org>
- Subject: Re: Question about programming techniques
- Date: Sat, 27 Jun 1998 11:36:44 +0200 (CEST)
On Fri, 26 Jun 1998, Andrew V. Shuvalov wrote:
> Hi!
>
> > STL forbids mixed-type containers. That, IMHO, disqualifies it from
> > consideration for serious projects.
>
> How you believe it may be possible to store mixed-type containers?
> STL store objects from templates. When you store, say, a vector of < T >, all
> objects are stored in memory in sequence, not by pointers. So all objects
> must be of the same type and size.
That's an basic problem with C++.
C++ allows clients to use the size of an object, which is basically
broken, as the size of an object depends upon it private
implemantation.
Consider this one:
ObjectArray a = [ObjectArray with ("A String:",
[ObjectArray with ("1","2")])];
[[[stdio err] print a] nl];
Works like a charm in TOM ;)
(Ok the default output way is rather debug oriented, and outputs
it a bit lispish in my eyes. But then in TOM I may reimplement
all write methods even from the standard library even the application
without touching the library source ;) )
> But ok, in general, when you need polymorphism, say, to store some objects
> that are similar by all operations, that means that you may use base class
> and virtual functions.
What if the class hierarchy is in an library without source, so I cannot
change it's hierarchy to include a ``do-something-method''?
(And the without source somehow applies to GPL stuff to: The
do-something-method may be completly application specific: So
what do you do: change the general library? bad idea.
copy the library, patch it, and track all new versions? bad idea.
kludge around it? probably the most often used solution.)
> Example: if you use GTK--, you may create the vector of < Gtk_Widget * > (
> vector of pointers ) and store there avery kind of widgets. Sure, you can't
> store Widgets in vector by value. If you mean this when you speak about
> restrictions, ok, i agree.
It's not really an restriction: It basically makes no sense
to copy GtkWidgets. (How does it look at the screen? two buttons for
some time?)
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]