- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I believe that emulating try/catch/finally with gotos is possible, but will be really difficult to do that correctly. You must remember to call destructors yourself. You must match the type of exception to corresponding error handling sections yourself. You must rethrow (how? special return value?) any exception you have no error handling section yourself. etc. For me it looks discouraging. What the language does encourage me to do is on error resume next.
Admin
I think TRWTF is using booleans to check for hacking attempts when it is equally easy to write:
I would rather use something like memory signing used by Starcraft... or actually I would not, but I like to bring up that idea from time to time.
Admin
No Goto was not bad, saying it is bad is like saying guns are bad. It was a tool one of many in the language. The language did not encourage the use of it. It was possible to follow best practices and never use it unless you were trying to emulate try-catch.
Admin
Yes not easy, and the level of programmer normally using VB6 would not realize the necessary pieces to really do this right, but that would also be the same for someone working in C++; VB6 was deceptivly easy to read so people though they know what they were doing even when they didn't.
Once again though, the language didn't encourage On Error Resume Next any more then C++ encouraged the lack of proper memory management. It was just harder then most developers though and showed a lack of skill on those developers.
Admin
They go off all by themselves, sometimes when you are cleaning them, but frequently for no reason at all.
If they find themselves within 1000 feet of a school they will erupt into an orgy of violence.
In the presence of an innocent victim they will either shoot the victim, or a cop, or a random bystander.
On a plane they will go off unexpectedly causing the entire plane to explode.
Guns will kill even when they aren't loaded, because they secretly stash one extra bullet in a hidden compartment no one could have expected.
Really the only situation where guns are not bad is in the hands of a donut-scarfing cop. Even a dirty cop is still OK. The gun sees that shiny badge and decides to behave itself and submit to the superior class of human.
Admin
Admin
It always saddens me to see the sheer number of people who have been brainwashed into believing that language feature x is inherently evil.
Admin
you ment eval?
Admin
Admin
Back in the olden days of COM, true could be -1 or +1 depending on the language, so you'll see this enum has true = -1 and "complement true" = +1. There are people still running macros written a decade ago.
Admin
LOL, hilarious
Admin
No, 'On Error Goto' sucked. Well, the way most people used it anyway, which was to jump to the 'error handler' block at the bottom, and then get totally confused.
The VB-bashers usually aren't aware of the fun variant, 'On Error Resume Next'; where if an error occurred, then why, you'd just continue to the next line! You know a WTF is in progress when you see that at the top of a code module. "Damn the errors, full speed ahead!"
'On Error Goto Next' wasn't all bad, and you could sort of emulate 'Try Catch' with it. Well, at least you could have little blocks with their own error handling, eg:
On Error Goto Next X = Y / 0 If Err Then MsgBox "YU div 0?" End If
Wrap that in a Do Loop or similar and you get something that makes a little bit of sense. More than 'On Error Goto WTF' anyway.
Admin
Actually, I should really point out that 'On Error Goto' still sucks.
Classic VB, in the guise of VBA, is bloody everywhere. Not just Excel & Word, but even things like AutoCAD and CorelDRAW.
Oh well, it's better than Lisp, I suppose.
Even worse is Lotus Notes, that has a (poor) clone of VB for scripting.
(MS used to have a list of all the licenced apps, but it vanished from their website. It was long list.)
Admin
He should have used '7423' for true and '944723' for false. Those are the best hex analogs for leet '7RUe' and 'pH4L23'.
Admin
... which doesn't mean what most people seem to think it means. Isn't that ironic?
Admin
You had to explicitly test for errors after each step.
Of course most lazy programmers didn't.
Admin
Admin
Admin
Admin
Admin
Well, I'm beginning to understand why Microsoft engineers can't code their way out of a paper bag. All of the exploits, security holes, lack of support for standards... it all makes sense when you know that, at a very fundamental level, even the people writing the underlying API haven't a clue what they're fucking talking about.
Admin
Admin
Admin
Admin
Amateurs:
http://www.outpost9.com/reference/jargon/jargon_17.html
That is how it's done.
Admin
might I suggest
Admin
Admin
Might work for a while, but I reckon a "for" loop might fuck your average with a continue implemented by goto
Admin
Admin
Remembering the comment is something...remembering Google search is priceless!
Admin
Yeesh! Talk about bondage and discipline!
Admin
The problem with this kind of thinking is that the comparison operator itself returns a boolean value. So, if you write
and you want to be consistent, you must change that to and so on. It's booleans all the way down.Admin
More generally, GOTO is a control structure primitive that can be used to model higher-level concepts. (At the bottom level, a CPU only ever deals with LITERAL GOTO, CONDITIONAL GOTO, and COMPUTED GOTO. Everything else is built on top of that.) Because it is a low-level primitive, it's not easy to use well — and if you have something that models what you are doing better you shouldn't be using GOTO — but that doesn't mean that you should never use it; it would be arrogant to say that we've discovered all possible useful control structures (we have a minimal set with if, while and a bunch of flag variables, but that doesn't mean that the translation to such a set is efficient) so it is useful to be able to still make our own where necessary.
But for kiddies doing “My First Programming Course”, avoiding GOTO is a good idea.
Admin
All VB programmers are professional. I mean, for fucks sake, would you write in VB if you weren't getting paid for it?
Admin
The waftery?
Admin
For i = 1 To 8 continue: // work if condition = bad i = i + 1 if i > 8 Exit For Goto continue End If // more work Loop
(it's been a few years since I've done VB6, so sorry if the syntax isn't all there)
Admin
Sometimes goto is an acceptable solution. Being afraid of it is just as bad as abusing it.
Admin
So never mind that.
Admin
My sarcasm detector may be broke, but these things all seem highly unlikely.
Admin
It's not that guns are bad per se, it's that it's a fallacy to think that having a gun makes you safer.
If a criminal threatens you and you pull a gun, now the criminal is in a position where he must kill you or be killed himself. But if you don't have a gun, then he can just take your money or whatever and leave you unhurt.
Futhermore, if you have a gun in your home, then in an argument someone might rashly grab the gun and kill a family member. Or a person in a moment of depression might kill themselves.
That is, violent criminals, who are in the very act of committing a felony, can be trusted not to hurt anyone unless absolutely necessary for their own self-defense. But the average law-abiding person who gets hold of a gun is likely to go on a rampage of violence at the slightest provocation.
That's how it was explained to me, anyway.
Admin
What you want is:
On Error Goto Next Do 'do work here... If Err = 0 Then Exit Do End If 'condition bad here... Loop
Go around in circles until you don't get error, then exit the loop.
The Do Loop merely replaces the label & Goto, allowing you to claim to be highly evolved by not using the dreaded GoTo statement. Sure, whatever floats your boat.
You can always toss in a counter to exit the loop as well.
Admin
Personally, if a thief breaks into my house, it's not a kill or be killed situation for him, it's simply be killed. I won't hesitate.
Admin
The ITG is the real WTF.
Get your hand off it and grow up.
Admin
Imagine the following hypothetical scenarios:
[*] Lawful citizens and criminals cannot acquire guns. Most would agree that this is relatively safe. Nobody has any guns so obviously guns themselves cannot hurt anybody.
[*] Lawful citizens cannot acquire guns, but criminals can. A somewhat more reasonable picture for the USA in the short term, if guns were ever to be restricted. Those with intent to do harm still possess guns, but the innocent people that don't want to hurt anyone are defenseless against them. Most would agree that this is relatively unsafe.
[*] Lawful citizens and criminals can both acquire guns. On the one hand, it is possible for there to be a lot more guns, but on the other hand the consequences for using them are more immediate for everyone. A criminal cannot just boldly pull a gun on a random group of people without fearing that they will pull guns right back on him. That's a lose-lose situation. He is either killed, caught, or kills and raises the heat on himself.
For the record, even though the majority of the USA is free to own and possess guns there actually aren't very many gun owners proportionate to the population. In other words, most people do not own guns, and fewer still carry them around them with, even though they have the right to.
Imagine that you are a criminal (assuming you're not ;). Let's also say that you have a gun because, frankly, you don't care if it's illegal to own one. You break the law anyway. Which do you prefer: a society where the lawful citizen you plan on ripping off and/or assaulting cannot possess a gun or the society where he has the right to own and carry one? Odds are you will prefer to have the upper hand. Criminals are not bullet proof. Most of them are going to be afraid of getting shot too.
Accidents involving guns are also not very common. Car accidents are a much more serious problem. I would agree that gun ownership should require a certain level of education and/or training. That said, I wish they didn't give driver's licenses out so easily too. There are a lot of people that are very dangerous behind the wheel that should be taking the bus.
Admin
How is this a problem? Am I suppose to ask the thief if he is there to just take my TV or to kill me, my wife and my little girl? He is there, without permission, already threatening, I am not going to stop and ask questions.
You sir, probably take the stance that I am killing him to keep my TV, I take the stance that he risked his life for one when there are safer ways to get one, to bad he lost.
Admin
You sir, should challenge the thief to compare penis sizes. Biggest gets the TV, odds are you'll lose.
I'd beat both of you, of course, but I don't have much use for a TV.
Admin
It's not about comparing, it's not about who has a tougher attitude. I don't want to fool around with an intruder. If he intelligently takes off back out the door before I get a sight on him I won't pursue. It is about one thing and one thing only, defense of me and my family, nothing more, nothing less.
Admin
For me it's about odds. I don't know exactly what the odds would be of a gun accident or suicide if I had a gun in my house, but I do know it would be higher than now with no gun. Is it worth taking that risk? How likely is it I'll need a gun in my house? If it's likely enough to be worth the risk, I am going to start looking for a house in a different neighborhood. The safety of my family is really the most important thing, so I don't know why I would risk compromising it by either living in a dangerous neighborhood or having a gun in the house or both.
Admin
When guns are prohibited from goto, only users of goto will have guns.
Hitler implemented gun control: Exit Thread
Admin
Oops, I got that backwards.
When guns are required to goto, only users of goto will have guns.
Fortunately this thread is already exited.