From: Cor on
Tom,

Why C# and Java

You can do it in VB too

If (((Not X) = 1)) = False) then

However, it keeps showing for me the knowledge of the developer who did
this.

Cor

"Tom Shelton" <tom_shelton(a)comcast.invalid> wrote in message
news:i28dvd$35b$1(a)news.eternal-september.org...
> on 7/21/2010, ralph supposed :
>> On Wed, 21 Jul 2010 19:07:31 -0600, Tom Shelton
>> <tom_shelton(a)comcast.invalid> wrote:
>>
>>
>>>
>>> The only reason boolean returns came into it is because most modern
>>> languages force conditionals (if, while, etc) to only accept a statement
>>> that evaluates to a boolean - so the old constant == varialbe convention
>>> isn't a requirement.... You get a compiler error in either direction.
>>>
>>
>> But the question had nothing to do with *other languages* it was a
>> C/C++ example, and placing a Constant first has always been a nice
>> habit to get into when doing comparisons, period.
>>
>
> To prevent an ACCIDENTAL assignment. I understand that. And that is the
> basic answer...
>
>> In the example the other operand was a function, so an error was
>> likely in either case, but likely had nothing to do with the
>> programmer employing the convention.
>>
>> And where did you get the idea you CAN NOT do an assignment in a
>> conditional statement????
>>
>
> I didn't say you can't... I didn't even say you would want to. It is
> just a common old C/C++ bug to ACCIDENTLY do an assignment. The
> convention of constant first was simply to avoid that mistake.
>
> You can even do an assignent in C# and Java - it's jsut the result of your
> expresion must be a boolean.
>
> string line;
> while ((line = reader.ReadLine()) != null)
> {
> }
>
>
>
> --
> Tom Shelton
>
>
>
From: Henning on
And where is the assignement?

/Henning

"Cor" <Notmyfirstname(a)planet.nl> skrev i meddelandet
news:e9p1jtXKLHA.4240(a)TK2MSFTNGP06.phx.gbl...
> Tom,
>
> Why C# and Java
>
> You can do it in VB too
>
> If (((Not X) = 1)) = False) then
>
> However, it keeps showing for me the knowledge of the developer who did
> this.
>
> Cor
>
> "Tom Shelton" <tom_shelton(a)comcast.invalid> wrote in message
> news:i28dvd$35b$1(a)news.eternal-september.org...
>> on 7/21/2010, ralph supposed :
>>> On Wed, 21 Jul 2010 19:07:31 -0600, Tom Shelton
>>> <tom_shelton(a)comcast.invalid> wrote:
>>>
>>>
>>>>
>>>> The only reason boolean returns came into it is because most modern
>>>> languages force conditionals (if, while, etc) to only accept a
>>>> statement that evaluates to a boolean - so the old constant == varialbe
>>>> convention isn't a requirement.... You get a compiler error in either
>>>> direction.
>>>>
>>>
>>> But the question had nothing to do with *other languages* it was a
>>> C/C++ example, and placing a Constant first has always been a nice
>>> habit to get into when doing comparisons, period.
>>>
>>
>> To prevent an ACCIDENTAL assignment. I understand that. And that is the
>> basic answer...
>>
>>> In the example the other operand was a function, so an error was
>>> likely in either case, but likely had nothing to do with the
>>> programmer employing the convention.
>>>
>>> And where did you get the idea you CAN NOT do an assignment in a
>>> conditional statement????
>>>
>>
>> I didn't say you can't... I didn't even say you would want to. It is
>> just a common old C/C++ bug to ACCIDENTLY do an assignment. The
>> convention of constant first was simply to avoid that mistake.
>>
>> You can even do an assignent in C# and Java - it's jsut the result of
>> your expresion must be a boolean.
>>
>> string line;
>> while ((line = reader.ReadLine()) != null)
>> {
>> }
>>
>>
>>
>> --
>> Tom Shelton
>>
>>
>>


From: Cor on
Ever thought at the idea that X is a function likewise the C and C# sample
from Tom.

With option strict on you need to convert first to Boolean, but I did not
find that real relevant for this newsgroup.


"Henning" <computer_hero(a)coldmail.com> wrote in message
news:i295a9$l2v$1(a)news.eternal-september.org...
> And where is the assignement?
>
> /Henning
>
> "Cor" <Notmyfirstname(a)planet.nl> skrev i meddelandet
> news:e9p1jtXKLHA.4240(a)TK2MSFTNGP06.phx.gbl...
>> Tom,
>>
>> Why C# and Java
>>
>> You can do it in VB too
>>
>> If (((Not X) = 1)) = False) then
>>
>> However, it keeps showing for me the knowledge of the developer who did
>> this.
>>
>> Cor
>>
>> "Tom Shelton" <tom_shelton(a)comcast.invalid> wrote in message
>> news:i28dvd$35b$1(a)news.eternal-september.org...
>>> on 7/21/2010, ralph supposed :
>>>> On Wed, 21 Jul 2010 19:07:31 -0600, Tom Shelton
>>>> <tom_shelton(a)comcast.invalid> wrote:
>>>>
>>>>
>>>>>
>>>>> The only reason boolean returns came into it is because most modern
>>>>> languages force conditionals (if, while, etc) to only accept a
>>>>> statement that evaluates to a boolean - so the old constant ==
>>>>> varialbe convention isn't a requirement.... You get a compiler error
>>>>> in either direction.
>>>>>
>>>>
>>>> But the question had nothing to do with *other languages* it was a
>>>> C/C++ example, and placing a Constant first has always been a nice
>>>> habit to get into when doing comparisons, period.
>>>>
>>>
>>> To prevent an ACCIDENTAL assignment. I understand that. And that is
>>> the basic answer...
>>>
>>>> In the example the other operand was a function, so an error was
>>>> likely in either case, but likely had nothing to do with the
>>>> programmer employing the convention.
>>>>
>>>> And where did you get the idea you CAN NOT do an assignment in a
>>>> conditional statement????
>>>>
>>>
>>> I didn't say you can't... I didn't even say you would want to. It is
>>> just a common old C/C++ bug to ACCIDENTLY do an assignment. The
>>> convention of constant first was simply to avoid that mistake.
>>>
>>> You can even do an assignent in C# and Java - it's jsut the result of
>>> your expresion must be a boolean.
>>>
>>> string line;
>>> while ((line = reader.ReadLine()) != null)
>>> {
>>> }
>>>
>>>
>>>
>>> --
>>> Tom Shelton
>>>
>>>
>>>
>
>
>
From: DanS on

>>>>> It's C++ code.... Older C++ didn't define a bool type
>>>>> or have any concept of a boolean value. That mades
>>>>> these types of comparisons necessary, and the reverse
>>>>> test was to prevent the old bug of accidently doing an
>>>>> assignment in the test.
>>
>> LoopHere:
>>
>>>> Since when is a programmer's own deficiency a bug ?
>>>>
>>> A bug is any incorrect behavior in the program - which in
>>> this old case maybe the result of a typo or as you say,
>>> programmer deficiency. What does this actualy have to do
>>> with my response?
>>
>> Why would you ask that ?
>>
>> Your response to the question was......
>>
>> "Older C++ didn't define a bool type or have any concept
>> of a boolean value. That mades these types of comparisons
>> necessary, and the reverse test was to prevent the old bug
>> of accidently doing an assignment in the test."
>>
>> Goto LoopHere;
>
> I'm w/ Tom in some surprise of even commenting on the use
> of "bug" for the problem of a typo causing incorrect
> behavior in code (in this case one instead of two "="
> signs). Would you not consider a misspelling of a variable
> name or the inadvertent use of the wrong variable or any
> number of other (more or less) mechanical mistakes bugs?
> How would you define a bug vis a vis a "programmer
> deficiency"?

I don't know, I've never thought about it.

I do know, however, that the times I've done an assignment vs.
a compare, the code didn't work.

(Yes, I know you, or I could give a 1000 examples of how it
may work, yet still be incorrect.)





From: Bob Butler on

"Tom Shelton" <tom_shelton(a)comcast.invalid> wrote in message
news:i2852b$u82$1(a)news.eternal-september.org...
> Bob Butler used his keyboard to write :
>> "dpb" <none(a)non.net> wrote in message
>> news:i27te9$ul$1(a)news.eternal-september.org...
>> <cut>
>>> I'm w/ Tom in some surprise of even commenting on the use of "bug" for
>>> the problem of a typo causing incorrect behavior in code (in this case
>>> one instead of two "=" signs). Would you not consider a misspelling of
>>> a variable name or the inadvertent use of the wrong variable or any
>>> number of other (more or less) mechanical mistakes bugs? How would you
>>> define a bug vis a vis a "programmer deficiency"?
>>
>> It causes a bug in the application; it's not a bug in the language per
>> se.
>
> No one said it was a bug in the language...

Then I fail to understand what the question is about calling it a bug. If
somebody codes
if (x=0) {
when they meant to code
if (x==0) {
then they have a bug in the code.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Prev: Displaying property menu at runtime
Next: Delay Methods