From: "Martin Krischik" <krischik@users.sourceforge.net>
Subject: Re: Ada requires too much typing!
Date: Mon, 07 Jun 2010 11:25:46 +0200
Date: 2010-06-07T11:25:46+02:00 [thread overview]
Message-ID: <op.vdxa48vdz25lew@macpro-eth1.krischik.com> (raw)
In-Reply-To: af8f8146-08a9-4ad9-8eed-edbc1a6bbc55@y11g2000yqm.googlegroups.com
Am 07.06.2010, 10:34 Uhr, schrieb Maciej Sobczak
<see.my.homepage@gmail.com>:
> On 6 Cze, 14:04, "Martin Krischik" <krisc...@users.sourceforge.net>
> wrote:
>
>> > I suppose there must be some cost to doing this? or the language
>> > definition would require it to be always so.
>>
>> Yes indeed, you have virtual dispatch not only on the methods but on
>> the instance variables as well.
>
> No, such concept does not even make sense - instance variables
> themselves have no behavior and therefore cannot be "overriden". With
> virtual inheritance there is only one copy of the given instance
> variable within the whole object, so even the word "dispatch" cannot
> be applied there, as "dispatch" relates to "choice" and there is no
> choice.
>
>> Main problem with multiple inheritance was in C++ itself where default
>> is “fast” not ”save”.
>
> No. Neither of these (non-virtual vs. virtual) is "fast" or "safe" in
> itself.
There is a difference between x.y and x->y. I don't care - but the CPU
cycle counters who designed C++ did.
> Considering the performance aspect, the layout of variables within the
> object is determined *statically* (I have already explained that there
> is no "dispatch" involved), which means that there is no run-time cost
> in finding the given data item. All instance variables have some
> offset from the "beginning" of the object and that offset is computed
> statically, whether inheritance is virtual or not. There is no
> particular reason for any performance difference in data access, so it
> does not make any sense to say than one mode is "fast", while the
> other is not. Both are "fast" (it's C++, remember? ;-) ).
Interesting opinion. Say we have (all lines in different compilation
units, so no fancy optimizer tricks):
class Parent {public: int x};
class Child1: public virtual Parent;
class Child2 : public virtual Parent;
class Incest : public virtual Child1, public virtual Child2;
auto Incest* incest = new Incest();
auto Child1* child1 = static_cast <Child1*> (incest);
auto Child2* child2 = static_cast <Child2*> (incest);
So now tell me how the compiler staticly determines:
child1->x;
child2->x;
As a hint, at any time you could do a:
child1=new Child1();
child2=new Child2();
as well.
> Considering the safety aspect, the choice between non-virtual and
> virtual is design-dependent.
>> but main problem stay: not enough C++ programmer have known about
>> virtual inheritance
>
> Again, that knowledge would not necessarily help them, as the use of
> virtual inheritance is not automatically justified.
Like the use if virtual destructors is not automaticly justified? Only:
count in your source the amount virtual destructors vs. non virtual
destructors. Why is what you need most not default? In my C++ time the
ratio between virtual and non virtual inheritance was similar - and it
served me well.
>> The real lesson learned: “doing it right” must be default
>
> Both ways are right. The default one is consistent with the overall
> object model.
>
>> and “make it fast” must be an optional extra
>
> Both are fast.
As I said fast enough for me.
Martin
--
Martin Krischik
mailto://krischik@users.sourceforge.net
https://sourceforge.net/users/krischik
next prev parent reply other threads:[~2010-06-07 9:25 UTC|newest]
Thread overview: 123+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-28 5:25 Ada requires too much typing! Luis Espinal
2010-05-28 6:47 ` Yannick Duchêne (Hibou57)
2010-05-28 15:52 ` John B. Matthews
2010-05-28 17:31 ` Dmitry A. Kazakov
2010-05-28 19:05 ` Georg Bauhaus
2010-05-28 19:39 ` Dmitry A. Kazakov
2010-05-28 9:48 ` Georg Bauhaus
2010-05-28 10:10 ` Alex R. Mosteo
2010-06-01 21:30 ` Luis Espinal
2010-06-02 11:08 ` Alex R. Mosteo
2010-06-05 19:58 ` Luis Espinal
2010-06-02 13:09 ` Yannick Duchêne (Hibou57)
2010-06-05 20:13 ` Luis Espinal
2010-06-06 4:25 ` Yannick Duchêne (Hibou57)
2010-06-06 8:55 ` Martin Krischik
2010-06-06 10:13 ` Simon Wright
2010-06-06 11:03 ` Dmitry A. Kazakov
2010-06-06 12:04 ` Martin Krischik
2010-06-07 8:34 ` Maciej Sobczak
2010-06-07 9:25 ` Martin Krischik [this message]
2010-06-07 12:04 ` Colin Paul Gloster
2010-06-07 12:17 ` Maciej Sobczak
2010-06-07 12:26 ` Dmitry A. Kazakov
2010-06-07 15:00 ` Martin Krischik
2010-06-08 7:46 ` Maciej Sobczak
2010-06-08 8:53 ` Martin Krischik
2010-06-09 7:50 ` Maciej Sobczak
2010-06-09 8:10 ` Dmitry A. Kazakov
2010-06-09 8:43 ` Maciej Sobczak
2010-06-09 9:24 ` Dmitry A. Kazakov
2010-06-09 13:54 ` Maciej Sobczak
2010-06-09 14:29 ` Dmitry A. Kazakov
2010-06-09 15:02 ` Georg Bauhaus
2010-06-09 15:53 ` Dmitry A. Kazakov
2010-06-09 18:00 ` Yannick Duchêne (Hibou57)
2010-06-09 19:10 ` Dmitry A. Kazakov
2010-06-09 21:09 ` Yannick Duchêne (Hibou57)
2010-06-10 8:07 ` Dmitry A. Kazakov
2010-06-10 8:44 ` Yannick Duchêne (Hibou57)
2010-06-10 9:07 ` Dmitry A. Kazakov
2010-06-10 10:10 ` Georg Bauhaus
2010-06-10 10:28 ` Dmitry A. Kazakov
2010-06-09 21:22 ` Maciej Sobczak
2010-06-09 23:09 ` Yannick Duchêne (Hibou57)
2010-06-10 8:15 ` Dmitry A. Kazakov
2010-06-10 13:37 ` Maciej Sobczak
2010-06-10 13:57 ` Dmitry A. Kazakov
2010-06-09 14:31 ` Yannick Duchêne (Hibou57)
2010-06-09 15:57 ` Dmitry A. Kazakov
2010-06-09 17:51 ` Yannick Duchêne (Hibou57)
2010-06-10 6:13 ` Randy Brukardt
2010-06-10 6:19 ` AdaMagica
2010-06-10 21:59 ` Randy Brukardt
2010-06-10 6:34 ` Vadim Godunko
2010-06-10 6:54 ` Yannick Duchêne (Hibou57)
2010-06-10 7:36 ` Vadim Godunko
2010-06-10 8:21 ` Dmitry A. Kazakov
2010-06-10 8:51 ` Vadim Godunko
2010-06-10 9:20 ` Dmitry A. Kazakov
2010-06-10 8:51 ` Yannick Duchêne (Hibou57)
2010-06-10 22:08 ` Randy Brukardt
2010-06-11 9:13 ` Stephen Leake
2010-06-10 7:20 ` AdaMagica
2010-06-10 8:57 ` Vadim Godunko
2010-06-10 10:12 ` Georg Bauhaus
2010-06-10 13:47 ` Alex R. Mosteo
2010-06-10 19:18 ` Vadim Godunko
2010-06-10 22:08 ` Gautier write-only
2010-06-10 22:17 ` Randy Brukardt
2010-06-11 18:38 ` Simon Wright
2010-06-29 2:13 ` Randy Brukardt
2010-06-11 9:14 ` Stephen Leake
2010-06-11 18:03 ` Jeffrey R. Carter
2010-06-11 9:11 ` Stephen Leake
2010-06-10 7:21 ` Maciej Sobczak
2010-06-10 19:33 ` Simon Wright
2010-06-10 22:23 ` Randy Brukardt
2010-06-07 8:13 ` Maciej Sobczak
2010-06-07 8:35 ` Martin Krischik
2010-06-07 8:43 ` Martin Krischik
2010-06-06 8:06 ` Martin Krischik
2010-06-07 18:30 ` Luis Espinal
2010-06-08 6:43 ` Martin Krischik
2010-06-08 7:10 ` Georg Bauhaus
2010-06-08 9:00 ` Martin Krischik
2010-06-10 13:56 ` Alex R. Mosteo
2010-06-10 14:29 ` J-P. Rosen
2010-06-11 11:57 ` Alex R. Mosteo
2010-06-08 10:10 ` Niklas Holsti
2010-06-08 11:35 ` Georg Bauhaus
2010-06-10 13:58 ` Alex R. Mosteo
2010-06-10 19:45 ` Simon Wright
2010-06-10 20:09 ` Niklas Holsti
2010-06-10 18:21 ` Yannick Duchêne (Hibou57)
-- strict thread matches above, loose matches on Subject: below --
2010-05-26 12:57 Peter C. Chapin
2010-05-26 13:29 ` Ludovic Brenta
2010-05-26 15:56 ` Peter Hermann
2010-05-26 16:12 ` Ludovic Brenta
2010-05-26 18:57 ` Pascal Obry
2010-05-26 19:30 ` Yannick Duchêne (Hibou57)
2010-05-26 14:48 ` Jeffrey R. Carter
2010-05-27 17:10 ` Warren
2010-05-27 22:15 ` Adam Beneschan
2010-05-28 15:26 ` Warren
2010-05-30 0:49 ` BrianG
2010-05-30 7:27 ` Dmitry A. Kazakov
2010-05-30 9:17 ` Yannick Duchêne (Hibou57)
2010-05-30 9:51 ` Simon Wright
2010-06-02 1:42 ` BrianG
2010-05-26 15:23 ` Adam Beneschan
2010-05-26 17:20 ` Georg Bauhaus
2010-05-26 19:33 ` Yannick Duchêne (Hibou57)
2010-05-26 21:55 ` Simon Wright
2010-05-26 23:36 ` Georg Bauhaus
2010-05-27 2:07 ` Fritz Wuehler
2010-05-27 4:19 ` Yannick Duchêne (Hibou57)
2010-05-27 19:51 ` Warren
2010-06-03 16:54 ` Colin Paul Gloster
2010-06-03 16:09 ` Yannick Duchêne (Hibou57)
2010-06-03 16:11 ` Yannick Duchêne (Hibou57)
2010-06-04 11:40 ` Nicolas Cóilin Paul de Gloucester
2010-06-04 13:54 ` Ludovic Brenta
2010-06-04 11:29 ` Nicholas Collin Paul de Gloucester
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox