typedefs and structs

Vadim Lobanov vlobanov at speakeasy.net
Thu Nov 10 09:47:17 EST 2005


Trimmed linux-pci so as not to annoy those who don't want to listen to
all of this. Anyone else who wants off the CC list should yell also. :-)

On Wed, 9 Nov 2005, linux-os \(Dick Johnson\) wrote:

>
> On Wed, 9 Nov 2005, Vadim Lobanov wrote:
>
> > On Wed, 9 Nov 2005, linux-os \(Dick Johnson\) wrote:
> >
> >>
> >> On Wed, 9 Nov 2005, linas wrote:
> >>
> >>> On Wed, Nov 09, 2005 at 08:22:15AM -0800, Vadim Lobanov was heard to remark:
> >>>> On Wed, 9 Nov 2005, J.A. Magallon wrote:
> >>>>
> >>>>> void do_some_stuff(T& arg1,T&  arg2)
> >>>>
> >>>> A diligent C programmer would write this as follows:
> >>>> 	void do_some_stuff (struct T * a, struct T * b);
> >>>> So I don't see C++ winning at all here.
> >>>
> >>> I guess the real point that I'd wanted to make, and seems
> >>> to have gotten lost, was that by avoiding using pointers,
> >>> you end up designing code in a very different way, and you
> >>> can find out that often/usually, you don't need structs
> >>> filled with a zoo of pointers.
> >>>
> >>
> >> But you can't avoid pointers unless you make your entire
> >> program have global scope. That may be great for performance,
> >> but a killer if for have any bugs.
> >
>
> Maybe you tried to trick me by showing the variable was not going
> to be changed (const *). In that case, the compiler may not re-read
> the variable. However, it can re-read the variable.
>
> A "smart" compiler might just do: write(1, "0\n", 2);
> ... for the first printf() as well. Such compilers make
> debugging difficult.

It wasn't meant to be a trick. In fact, I _want_ the compiler to cache
the myvar value in the second case -- I was merely wondering if there
was some fact that I overlooked that would prevent such an optimization.
The ultimate point of this was to show that globals can actually be
slower than locals (imagine the int in the example replaced by a
gigantic struct), contrary to the implication of your original
statement. :-)

>
> Cheers,
> Dick Johnson
> Penguin : Linux version 2.6.13.4 on an i686 machine (5589.55 BogoMips).
> Warning : 98.36% of all statistics are fiction.
> .
>
> ****************************************************************
> The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors at analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.
>
> Thank you.
>

-Vadim Lobanov



More information about the Linuxppc64-dev mailing list