If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

The reason has to do with invalid use of the returned data subtype. Using it can lead a programmer to make other such mistakes that would lead to errors, etc. Instead, to maintain accurate use of data subtypes, you can achieve the same desired results -- and make the code more intuitive -- by coding it this way:

Anyone with a working knowledge of a modern programming language should be able to understand what this statement is doing and why it works. Otherwise, the functionality would not exist.

Most programming language do not allow such ambiguity. What ambiguity? Numeric results where Boolean results would normally be expected. It takes more than just a "working knowledge" of VBScript to truly understand how such a mis-match in data subtypes is actually being handled. Examples?

Programmer sees a statement like this:

Code:

If Len(str1) Then ...

Programmer thinks, "The Len() function returns a numeric result which is treated as a Boolean condition." Programmer may then get the idea that positive numbers, including decimals, greater than zero are treated as True and zero or negative numbers are treated as False.

This is not a good way to think. That is why I said it was a bad programming practice -- it is ambiguous to code that way.

Originally posted by buntine What!? Which programming languages do you use? Every MS technology I am familiar with allows it.

Well, sorry, if that is true then I guess I have an advantage over you. I don't just program in the languages of the Internet or for PCs. I program in many languages for midrange and mainframe computers, too. NONE of those languages allow ambiguous use of data types. Period.

Originally posted by buntine You should not try to make yourself sound better than others. The least you could have said was "Here is the way I like to do it: ... This is advantageous because...".

You misjudge me. I think you chose to take personal insult where none was given. My statements are not only based on 25+ years of programming experience. If they were, then perhaps I would have said things in a way that would have eased your bruised ego. Instead, my statements are based upon what educators have drilled into my head over those same many years. Tell me, since I don't know you, are you actually trained in Information Science and Programming? ...or is programming something you have just "picked up" here and there? Do you also have a degree in the field?

If so, I think your education has actually been lacking. Just because a programming environment allows a thing, does not mean it is something that should actually be exploited as correct usage. Also, don't hold Microsoft technology up as some kind of Holy Grail. After all, look at all the criticism and downright condemnation Microsoft has received for its efforts to make client-side technology as powerful as server-side technology. Case in point... In spite of everything that JavaScript, and particularly IE's JScript, can do; practically all you hear at this website is that it shouldn't be used. Those who try to use it are actually vilified and ostracized for it.

No, thank you very much, but I'll stick to my guns. Purposely writing program code to be ambiguous is just plain wrong. This is especially true when absolutely no less functionality is given if such code is written with clear and obvious intent. Preferring the ambiguous over the obvious smacks of just plain laziness. Period.

Originally posted by buntine

Originally posted by phpnovice Programmer thinks, "The Len() function returns a numeric result which is treated as a Boolean condition." Programmer may then get the idea that positive numbers, including decimals, greater than zero are treated as True and zero or negative numbers are treated as False.

In the conxext of an If Statment, this is true. Everyone should know that.

See?!? Even you, who think so highly of yourself, don't know VBScript well enough to know what is true about the If statement where numeric results are involved. My quote said that a programmer might think negative numbers are treated as a false conditional. You agreed with that and you are wrong. Instead, negative numbers are treated as true conditionals. Only the zero is treated as a false conditional. You just proved my point. Thank you.

I actually did say one thing incorrectly earlier, though.

Originally posted by phpnovice The reason has to do with invalid use of the returned data subtype.

I did not mean to say it that way -- though this is not the statement that was picked on. Instead, this is what I meant:

"The reason has to do with ambiguous use of the returned data subtype."

Buntine is right in that, in many programming languages, false is represented as a 0 integer value, and all other integer values are equivalent to true. It is therefore not ambiguous (from the compiler's point of view) to treat an integer value as a boolean in such languages.

However, phpnovice is right in that it is more cryptic and less readable, especially for for inexperienced programmers, and may lead to the misunderstanding that all languages work this way when they in fact do not.

That's my two cents. Feel free to disagree...

Last edited by HaganeNoKokoro; 03-24-2005 at 11:11 PM.

Kids, kids... you tried your best, and you failed miserably; the lesson is: never try.

Originally posted by HaganeNoKokoro Buntine is right in that, in many programming languages, false is represented as a 0 integer value, and all other integer values are equivalent to true.

The fact that this is supported by some programming languages (though never stated exactly as you have stated it), was never at issue. Plus, you also make my point because you limit this to "integer" when, in fact, single and double decimal values are also supported as being equivalent to "true".

In the future, do it in a more suitable way or I will take action. You have seen my example.

That sounds like a threat. What "action"? There is no possible action you could take that would not be a violation and an abuse of your status on this site. Just making such a threat is a violation and an abuse of your status. I have violated no rules of this site. You had better retract that immediately -- or I'll take this thread to the site administration and let them deal with you. And, what "example"? The example of a dictator who will brook no opposition to his own point of view?

I said nothing against you, personally, in my original comments. The fact that you have taken exception to them is inexcusable in light of your status on this site. Yes, you are entitled to your opinion, but so am I. What I said is not even just my opinion. It is a fact that is expressly taught in every programming class that I have ever attended -- and there have been many. You don't have to agree with such facts. But don't take it out on me because I point out these facts.

Now... I have copied all of these posts to my PC as proof of what was said. I am ready to submit these to the site administration in justification of myself and in condemnation of your overbearing attitude. In your position, you are not allowed to demonstrate such an attitude unless a member is actually and willfully violating the rules of this site.

I have spoken to the administrators and fellow moderators about this issue. I will retract my statement (as you can see my threating statement is now gone). And I apologise to you for attempting to lay down the law upon you in an irresponsible way.