December 22, 2011 at 10:59 am
no equivalent to Visual Basic's RETURN statement to return control to the statement after the one that issued the GOTO
I think you're actually thinking of the GOSUB statement, which we have in T-SQL as EXEC.
While I haven't personally used GOTO in a very long time either, I can still see a restricted use for it, for the purpose of jumping forward in code (but never backward). Just my 2c but I don't always want every stored proc I write to be one huge TRY..CATCH block.
I find it interesting that Microsoft themselves still use GOTO (2008 R2 at least, haven't tried 2012) when scripting out a SQL Agent job from SSMS.
December 22, 2011 at 11:13 am
GOTO is not as evil as it is painted today. When Dijkstra wrote his paper - which not many today's programmers have read -, real programmers programmed in Assembler and GOTO was one of the flavors of the 'branch' instruction. The recommended error handling construct looked like this:
* coming back from a Supervisor call; return code is in register 1
* return codes were multiples of 4
B *+4(1) *+4 is the address of the following instruction
B success you get here if the return code was 0
B error4 you get here if the return code was 4
B error8 etc.
Imagine debugging a program with several 'branch tables' like this. Some Supervisor calls might return over 20 different errors.
On the other hand, some GOTOs were actually encouraged; e.g., BXLE or Branch on Index Lower or Equal, which was the best way to do a WHILE loop.
December 22, 2011 at 3:48 pm
Blanket prohibitions are generally a bad idea in any field. All processors have Jump instructions, which are low-level GOTOs, and high-level languages compile or interpret down to that, so your actual code is full of GOTOs anyway, now matter how fanatic you are about structure. They're like any tool - they can be misused, and they can be the best tool for the job. People who automatically just repeat the 'GOTO is BAD' mantra are sheep - I prefer to think for myself.
I also wish T-SQL had a GoSub statement - would have been perfect for a job just today. Instead, I wound up with a couple of GOTOs and some awkward tests.
December 22, 2011 at 4:37 pm
A lot of ideas that are painted black are due to mis-interpretations.
Take Hungarian notation. Simonyi suggested its use to signal intent but people mis-interpretted this to signify type. Thats why we get tables beginning with tbl; due to that mis-interpretation.
You could argue that SQL2005/2008 schemas and namespaces are actually closer to expressing Simonyi's original idea.
December 22, 2011 at 5:10 pm
Revenant (12/22/2011)
GOTO is not as evil as it is painted today. When Dijkstra wrote his paper - which not many today's programmers have read -, real programmers programmed in Assembler and GOTO was one of the flavors of the 'branch' instruction. The recommended error handling construct looked like this:
* coming back from a Supervisor call; return code is in register 1
* return codes were multiples of 4
B *+4(1) *+4 is the address of the following instruction
B success you get here if the return code was 0
B error4 you get here if the return code was 4
B error8 etc.
Imagine debugging a program with several 'branch tables' like this. Some Supervisor calls might return over 20 different errors.
On the other hand, some GOTOs were actually encouraged; e.g., BXLE or Branch on Index Lower or Equal, which was the best way to do a WHILE loop.
Don't tell me your one of those that thinks assembler is real programing? I bet you don't from the way you write! Thou it's not entirely uncommon. Those goofs that likes to invent the wheel all over again and again..
No I still stand by that GOTOs in 99% of all cases are written because the programmer did not know better and that was how he did it 20 years ago.
December 22, 2011 at 7:17 pm
IceDread (12/22/2011)
. . . Don't tell me your one of those that thinks assembler is real programing? I bet you don't from the way you write! . . .
No, I do not, not any longer; however, there was time when the only REAL programming was in Assembler. Those were the times when an hour of IBM /360 was $300, in 1970 dollars, and that was about programmer's monthly salary. COBOL compile could take say 15 minutes, assembly of ~3,000 lines of code less than a minute.
Pick your heroes. Retroactively.
Viewing 6 posts - 16 through 20 (of 20 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy