POV-Ray : Newsgroups : povray.off-topic : C++ questions Server Time
7 Sep 2024 03:20:10 EDT (-0400)
  C++ questions (Message 114 to 123 of 123)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Warp
Subject: Re: C++ questions
Date: 30 Sep 2008 11:55:51
Message: <48e24c07@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
>   Actually if you have a function like:

>     std::vector<int> createVector(whatever) { ... }

> and then call it like:

>     std::vector<int> myVector = createVector(whatever);

> the compiler will most probably be able to optimize the copying away.

  Oh, and I forgot to say: The compiler doesn't even need to see the
implementation of 'createVector()' in order to do this optimization.
In other words, the compiler doesn't require to be able to inline that
function to do the optimization. The implementation of that function
could be in another compilation unit, or it could even be in a
precompiled library.

-- 
                                                          - Warp


Post a reply to this message

From: Mueen Nawaz
Subject: Re: C++ questions
Date: 30 Sep 2008 13:46:06
Message: <48e265de$1@news.povray.org>
Invisible wrote:
> Hmm, so vectors seem to be able to do some pretty death-defying stuff!
> They're variable size, but they manage their memory automatically.

	And they let you go out of bounds, too!


-- 
Vultures only fly with carrion luggage.


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

From: Warp
Subject: Re: C++ questions
Date: 30 Sep 2008 16:31:55
Message: <48e28cbb@news.povray.org>
Mueen Nawaz <m.n### [at] ieeeorg> wrote:
> Invisible wrote:
> > Hmm, so vectors seem to be able to do some pretty death-defying stuff!
> > They're variable size, but they manage their memory automatically.

>         And they let you go out of bounds, too!

  Well, you could use the at() member function if you want it to perform
bounds checks.

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: C++ questions
Date: 30 Sep 2008 20:59:44
Message: <48e2cb80@news.povray.org>
Mike Raiford wrote:
> "C allows you to shoot yourself in the foot. C++ allows you to shoot
> yourself in the foot and reuse the bullet"

I remember it differently.

"C makes it easy to shoot yourself in the foot. C++ makes it harder, but
when you do it blows the whole leg off."


Post a reply to this message

From: Mueen Nawaz
Subject: Re: C++ questions
Date: 30 Sep 2008 21:36:30
Message: <48e2d41e$1@news.povray.org>
Warp wrote:
> Mueen Nawaz <m.n### [at] ieeeorg> wrote:
>> Invisible wrote:
>>> Hmm, so vectors seem to be able to do some pretty death-defying stuff!
>>> They're variable size, but they manage their memory automatically.
> 
>>         And they let you go out of bounds, too!
> 
>   Well, you could use the at() member function if you want it to perform
> bounds checks.

	Well, if we're dealing with vectors, why not just check its size? Is at
more efficient?

	Anyway, I wasn't complaining - I just wanted to make sure he knew that
in C++, nothing stops you from going out of bounds (probably to maintain
efficiency of lookups). Many other popular languages will die if you try
that.

-- 
When you die, you lose a very important part of your life.
                -- Brooke Shields


                    /\  /\               /\  /
                   /  \/  \ u e e n     /  \/  a w a z
                       >>>>>>mue### [at] nawazorg<<<<<<
                                   anl


Post a reply to this message

From: Warp
Subject: Re: C++ questions
Date: 1 Oct 2008 09:19:46
Message: <48e378f2@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> "C makes it easy to shoot yourself in the foot. C++ makes it harder, but
> when you do it blows the whole leg off."

  I honestly don't understand what that is trying to say. I have no
experience (either personal or indirect) in C++ bugs being more severe
than C bugs.

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: C++ questions
Date: 1 Oct 2008 13:58:47
Message: <48e3ba56@news.povray.org>
Warp wrote:
>   I honestly don't understand what that is trying to say. I have no
> experience (either personal or indirect) in C++ bugs being more severe
> than C bugs.
> 

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but
when you do it blows your whole leg off".

"Yes, I said something like that (in 1986 or so). What people tend to miss,
is that what I said there about C++ is to a varying extent true for all
powerful languages. As you protect people from simple dangers, they get
themselves into new and less obvious problems. Someone who avoids the
simple problems may simply be heading for a not-so-simple one. One problem
with very supporting and protective environments is that the hard problems
may be discovered too late or be too hard to remedy once discovered. Also,
a rare problem is harder to find than a frequent one because you don't
suspect it."

from Bjarne Stroustrup's C++ FAQ.


Post a reply to this message

From: Orchid XP v8
Subject: Re: C++ questions
Date: 1 Oct 2008 17:08:12
Message: <48e3e6bc@news.povray.org>
Nicolas Alvarez wrote:
> Mike Raiford wrote:
>> "C allows you to shoot yourself in the foot. C++ allows you to shoot
>> yourself in the foot and reuse the bullet"
> 
> I remember it differently.
> 
> "C makes it easy to shoot yourself in the foot. C++ makes it harder, but
> when you do it blows the whole leg off."

...and by a spine-tingling twist of coincidence...

http://www-users.cs.york.ac.uk/susan/joke/foot.htm

(Because somebody way trying to figure out the appropriate translation 
for Haskell.)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Mike Raiford
Subject: Re: C++ questions
Date: 2 Oct 2008 09:40:58
Message: <48e4cf6a@news.povray.org>
Orchid XP v8 wrote:

> http://www-users.cs.york.ac.uk/susan/joke/foot.htm
> 
> (Because somebody way trying to figure out the appropriate translation 
> for Haskell.)
> 

I know you're a fan of Perl, so I couldn't help but quote this one:

PERL
     You stab yourself in the foot repeatedly with an incredibly large 
and very heavy Swiss Army knife.

-- 
~Mike


Post a reply to this message

From: Orchid XP v8
Subject: Re: C++ questions
Date: 2 Oct 2008 13:02:06
Message: <48e4fe8e$1@news.povray.org>
Mike Raiford wrote:

> I know you're a fan of Perl, so I couldn't help but quote this one:
> 
> PERL
>     You stab yourself in the foot repeatedly with an incredibly large 
> and very heavy Swiss Army knife.

My favourite Haskell suggestion so far:

     No instance for (Target Foot)
       arising from use of `shoot' at SelfInflictedInjury.hs:1:0
     Possible fix: add an instance declaration for (Target Foot)
     In the expression: shoot foot

(For those of you who aren't Haskell experts, this is pretty much 
_exactly_ what certain compiler errors look like.)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.