Message: previous - next
Month: April 2012

Re: [trinity-devel] k3b -bug ('K3bAudioEditorWidget::Range* r' previously declared here)

From: "E. Liddell" <ejlddll@...>
Date: Wed, 18 Apr 2012 16:37:52 -0400
On Wed, 18 Apr 2012 14:33:36 -0500
"David C. Rankin" <drankinatty@...> wrote:

> Darrell, E (don't know first name)

E is fine.  I'm not all that fond of my first name, and prefer not to use it.

>   I agree with all your comment and both proposals above, but like Darrell, I
> don't have a c++ background to know the 'best' way to do this. I certainly agree
> what declaration within the conditional looks bad, but I was not going to take
> the liberty and re-write it given the conservative approach I take when
> monkeying with the code (though I like the declaration outside the if statement
> much better as suggested). I know they are not big changes, but I don't know
> enough to know if they were declared in the if for some other reason.

I don't exactly have a C++ background either (I coded trivial stuff in it for about 
a year and a half as a CS grad student, going on fifteen years ago), but my suspicion
in this case is that the original programmer was trying to save himself keystrokes
and/or had taken up that idiom in order to save memory back in the days when
RAM was measured in kilobytes (declaring r outside the if statement would keep it in
scope just a little bit longer in most languages).  Either that, or I've forgotten some
obscure but vital point about C++ conditionals and scoping.