Line numbers... in 2002



  • So, while hunting down an issue in the even more legacy (read: VB6) section of our code. Most of this is circa 2002, when they re-implemented HTTP Forms to post XML, re-implemented ASP to use COM objects for all pages, that are all dispatched from one page, and HTML generated by XSLTs. Finally closing in on the code that likely contains the issue, I find this:

    Horrible repressed memories... On the upside, I can't find any GoTo's in the code that jump to a line number, just a few that jump to labels.



  • i maintain a lot of vb6 projects. Thank god no one used this 'feature'



  • How idiotic. Everybody knows your line numbers should increment by 10, not 1. What if you need to add a few lines in-between existing ones?



  • @morbiuswilters said:

    How idiotic. Everybody knows your line numbers should increment by 10, not 1. What if you need to add a few lines in-between existing ones?

    I know this is a joke, but hrrrnnggghhh


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    How idiotic. Everybody knows your line numbers should increment by 10, not 1. What if you need to add a few lines in-between existing ones?
    That's what RENUMBER was for.



  • @dkf said:

    @morbiuswilters said:
    How idiotic. Everybody knows your line numbers should increment by 10, not 1. What if you need to add a few lines in-between existing ones?
    That's what RENUMBER was for.

    Don't give me that fancy IDE bullplop. Besides, what happens if the line you're goto'ing to is in a variable?


  • Considered Harmful

    @morbiuswilters said:

    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    Don't give me that fancy IDE bullplop. Besides, what happens if the line you're goto'ing to is in a variable?
    IDE? I've never coded BASIC in an IDE, nor on a machine with a processor newer than an 8086. Old skool BASICs could renumber their lines, and this would fail horribly/amusingly if you used computed GOTOs. Or rather the RENUMBER would work but the computed GOTO wouldn't change. If you were very lucky, you got a warning.



  • @joe.edwards said:

    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    I dunno.. crappy FSM?



  • @dkf said:

    IDE? I've never coded BASIC in an IDE, nor on a machine with a processor newer than an 8086.

    It was a joke. Like, how so many people on here things like GUI debuggers are wizard's tools that you don't really need, I was implying RENUMBER was also such.

    @dkf said:

    Old skool BASICs could renumber their lines, and this would fail horribly/amusingly if you used computed GOTOs. Or rather the RENUMBER would work but the computed GOTO wouldn't change.

    Which is why I brought it up.


  • Discourse touched me in a no-no place

    @joe.edwards said:

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?
    Saner code these days uses switch. (Or dispatches via function pointers or to an implementation class or …)


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    Which is why I brought it up.
    As in vomiting up from memory? Yep, that fits old style BASIC pretty well.



  • @dkf said:

    @joe.edwards said:
    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?
    Saner code these days uses switch. (Or dispatches via function pointers or to an implementation class or …)

    All of those could be done with literal gotos, though, right? Admittedly, it might make some code simpler to use computed gotos.



  • @dkf said:

    @morbiuswilters said:
    Which is why I brought it up.
    As in vomiting up from memory? Yep, that fits old style BASIC pretty well.

    Basic was the first language I learned, back when I was 8 or so. I didn't learn it very well, since I just had a 3-inch-think manual in a D-ring binder which explained GW-Basic but it assumed you already knew a bunch of shit about programming. I did manage to make a very, very crude 3-D.. um, not a game, but a thing where you could kind of move a couple of steps.



  • @morbiuswilters said:

    I did manage to make a very, very crude 3-D.. um, not a game, but a thing where you could kind of move a couple of steps.

    And it was still better than HL2 on Linux.



  • @morbiuswilters said:

    How idiotic. Everybody knows your line numbers should increment by 10, not 1. What if you need to add a few lines in-between existing ones?

    That's exactly why Oracle is changing the Java version numbering scheme. TRWTF

    [url]http://www.oracle.com/technetwork/java/javase/overview/jdk-version-number-scheme-1918258.html[/url]



  • @twilsonxpert said:

    That's exactly why Oracle is changing the Java version numbering scheme. TRWTF

    It's hard to even be surprised by the fuck-ups coming out of Oracle anymore.



  • One of the especially awful things about VB6 was the fact that you didn't get really good information about where an error occurred in an error handler unless lines were numbered. The more advanced ways to handle it was to generate line numbers as a pre-compile step rather than litter your source code with line numbers.



  •  Of course, Despite all Visual Basic 6's problems, I think it would be hard to rate it below Go.



  • @joe.edwards said:

    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Switch statement?


  • @mikeTheLiar said:

    @morbiuswilters said:
    I did manage to make a very, very crude 3-D.. um, not a game, but a thing where you could kind of move a couple of steps.

    And it was still better than HL2 on Linux.

    Whaaaaaat? The HL2 WTF was Windows HL2, not the Linux beta released the following month.



  • @Ben L. said:

    @joe.edwards said:
    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Switch statement?

    Or callbacks



  • @Ronald said:

    @Ben L. said:
    @joe.edwards said:
    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Switch statement?

    Or callbacks

    You generate your function addresses at runtime?



  • Of course they don't, they let the os pick the address where the function will be and then generate the function code on the fly in memory.



  • I actually just ran into this monstrosity yesterday (vb6):

    <HTML>
    On iHubId GoTo _
                   ADDLINTEREST_HUB, QUOTECONDITION_HUB, CORPORATEOFFICERSINPUT_HUB, CHANGEENDTINFO_HUB, POLEMINPUT_HUB, MESSAGE_HUB, _
                   SURPLUSAGENT_HUB, NOTEPAD_HUB, CERTHOLDERINPUT_HUB, CERTMORTGAGEINFO_HUB, CERTPOLICYINPUT_HUB, SETCOPY_HUB, _
                   INSTALLSCHEDULE_HUB, CHANGENARRATIVE_HUB, TGINDUSTRYINPUT_HUB, TGINDUSTRYCOVGINPUT_HUB, FACREINSINPUT_HUB, CONTACTINPUT_HUB, _
                   DISCMODINPUT_HUB, SOLICITATIONINFO_HUB, DMVPOLDRIVERINFO_HUB, DMVVEHINPUT_HUB, DMVPLATEINPUT_HUB, DMVPLATESDTINPUT_HUB, _
                   DMVTRACKING_HUB, UNDWRDATAINPUT_HUB, UNDWRSCORECONDAPPROVAL_HUB, UNDWRSCORINGAPPROVAL_HUB, UNDWRSCORAPPROVALVAL_HUB, UNDWRSCORINGRESULT_HUB, _
                   UNDWRTIERINPUT_HUB, TERMHISTORYINPUT_HUB, TRMHISTLRGLOSSINPUT_HUB, ERPINPUT_HUB, AECRITICALUNITINPUT_HUB, AELOCINFO_HUB, _
                   AEUDDCURRPRIORINFO_HUB, AEUDDLAYERINFO_HUB, AEBILLINGHEADER_HUB, AEBILLINGCUSTOMER_HUB, AEBILLINGDETAIL_HUB, POLICYRELATIONINFO_HUB, _
                   QUOTEINFO_HUB, LOCATION_HUB, PMLMFLINPUT_HUB, PMLMFLCOVGINPUT_HUB, NAME_HUB, NAMEPTVEHLINK_HUB, _
                   NAMEITEMLINK_HUB, STCOMMOVRDINPUT_HUB, NAMELOCBLDGLINK_HUB, NAMEVEHLINK_HUB, NAMEUNSCHEDVEHLINK_HUB, NAMEENTITYLINK_HUB, _
                   POLEXNEWINPUT_HUB, POLEXNEWADDLOVRMSLCLMSINPT_HUB, POLEXNEWLTDINDCLMSINPUT_HUB, POLEXINPUT_HUB, POLEXLOSSINPUT_HUB, STAMPSSTICKERSINPUT_HUB, _
                   STATESCHEDINPUT_HUB, CATEGORYSCHEDINPUT_HUB, COUNTERSIGNINPUT_HUB, COUNTERSIGNLOBINPUT_HUB, RISKEVALUATIONINPUT_HUB, RISKEVALINPUT_HUB, _
                   RISKFINANCEINPUT_HUB, CBCOUNTERSIGNATUREINFO_HUB, HWQUOTEDATAINPUT_HUB, ZALOBSTATEINFO_HUB, KFSLOBREGINFO_HUB, LOSSINFO_HUB, _
                   PMLRISKINFO_HUB, LOCCOVGINFO_HUB, REPORTTRANSINFO_HUB, VEHDELONRENLINPUT_HUB, LOSSINFOPAYMENTINPUT_HUB, FEESINPUT_HUB, _
                   FEESLOBRATING_HUB, OPTCOVINPUT_HUB, SHAREDAGGREGATE_HUB, SELLOBDETAILPRINT_HUB, PWPOLINPUT_HUB, PWPOLSUBINPUT_HUB, _
                   SIGNATUREINFO_HUB, INSTALLDEPOSIT_HUB, INSTALLCOMMISSION_HUB, INSTALLOPT_HUB, INSTALLSCHEDOPT_HUB, PRODUCERIMAGEINFO_HUB, _
                   MSBILLINGACCTINFO_HUB, PREMDISCINFO_HUB, POLCOVGINPUT_HUB, POLCOVGRATING_HUB, FORMPREDEFINEDWORD_HUB, TMPWODENMISCINFO_HUB, _
                   FORMCONDITION_HUB, LOCFORMCONDITION_HUB, AVAILABLEFORM_HUB, SELECTFORM_HUB, FORMFILLIN_HUB, NAMEFORMFILLIN_HUB, _
                   LOCSELECTEDFORM_HUB, LOCBLDGCROSSREF_HUB, LOSSINFOTOTAL_HUB, PREVPOLINFO_HUB, REINSURANCEINFO_HUB, LOB_HUB, _
                   RATINGGROUP_HUB, WESIGNAPPFORMS_HUB, ADDLLOCINPUT_HUB, TMPWAEBILLINGHEADER_HUB, TMPWAEBILLINGDETAIL_HUB, EMPLOYEEINPUT_HUB, _
                   TAXSURCOVERRIDE_HUB, MEDALLIONINFO_HUB, DBAAKAINFO_HUB, VENDORINSUREDINFO_HUB, POLICYACCOUNTINFO_HUB, PROPERTYCONDITIONS_HUB, _
                   LOBOCCURCOVGRATING_HUB, LOBSTCOVGRATING_HUB, PROPOSALINPUTINFO_HUB, WKOTHERSTATESINPUT_HUB, WKPROPOSALPLANINFO_HUB, WKPROPOSALPREMINPUT_HUB, _
                   POLRATEVERSION_HUB, NAMECLEARANCESTATUS_HUB, PMLLOCINFO_HUB, ADDRESSINFO_HUB, RISKSCOREINFO_HUB, RISKSCOREREASONS_HUB, _
                   MISCINFO_HUB, ATTACHMENT_HUB, POLCALCULATIONINFO_HUB, STCALCULATIONINFO_HUB, OTHERPRODUCER_HUB, LOCINFORESEQXREF_HUB, _
                   LOSSRESPINFO_HUB, LOSSRESPCOVGINFO_HUB, TMPWCORTNMSG_HUB, TMPWCOSERVICESTATUS_HUB, PRERENEWAL_HUB, CORRESPONDENCE_HUB, POLICYVERSIONCONTEXT_HUB'_HUB_HUB_HUB_HUB_HUB
    


  • :twitch:



  •  I think this thread gave me brain damage



  • @dkf said:

    IDE? I've never coded BASIC in an IDE, nor on a machine with a processor newer than an 8086. Old skool BASICs could renumber their lines, and this would fail horribly/amusingly if you used computed GOTOs. Or rather the RENUMBER would work but the computed GOTO wouldn't change. If you were very lucky, you got a warning.

    Then I guess you didn't mess around with QBASIC during the days of MS-DOS.


  • Discourse touched me in a no-no place

    @joe.edwards said:

    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Jump tables: http://en.wikipedia.org/wiki/Branch_table#Jump_table_example_in_C



  • @FrostCat said:

    @joe.edwards said:
    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Jump tables: http://en.wikipedia.org/wiki/Branch_table#Jump_table_example_in_C

    What does this have to do with Basic?


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    @FrostCat said:
    @joe.edwards said:
    @morbiuswilters said:
    Besides, what happens if the line you're goto'ing to is in a variable?

    Apparently computed GOTOs are a real thing, so I have to ask, what kind of situation calls for jumping to a dynamically computed line number?

    Jump tables: http://en.wikipedia.org/wiki/Branch_table#Jump_table_example_in_C

    What does this have to do with Basic?

    Are you channeling Blakeyrat, morbs? Computed gotos are jump tables. C++ vtables are too. W'pedia doesn't have an example in Basic but conveniently another poster provided one.



  • @FrostCat said:

    Computed gotos are jump tables.

    I think a better way of saying that would be "computed gotos could be used to create jump tables in Basic, if you were an idiot." And while a jump table makes sense in C, why you would create one in Basic using computed gotos instead of just creating a switch statement with literal gotos (which could be renumbered)..

    @FrostCat said:

    W'pedia doesn't have an example in Basic but conveniently another poster provided one.

    I thought those were at least labeled gotos, but I'll confess I don't know VB6 syntax.


  • Discourse touched me in a no-no place

    @morbiuswilters said:

    why you would create one in Basic using computed gotos instead of just creating a switch statement with literal gotos
    Because someone is crazy? Old BASICs had to use it because they didn't have proper structured programming constructs — BASIC comes from a period and culture that saw it as a stepping stone to the very traditional end of FORTRAN — and echoes of that madness may well still infest the language's newer incarnations. Yes, there was some cross-fertilization with every other programming language eventually (both with BASIC and FORTRAN) but there's a lot of legacy still squirreled away.



  • @dkf said:

    @morbiuswilters said:
    why you would create one in Basic using computed gotos instead of just creating a switch statement with literal gotos
    Because someone is crazy? Old BASICs had to use it because they didn't have proper structured programming constructs — BASIC comes from a period and culture that saw it as a stepping stone to the very traditional end of FORTRAN — and echoes of that madness may well still infest the language's newer incarnations. Yes, there was some cross-fertilization with every other programming language eventually (both with BASIC and FORTRAN) but there's a lot of legacy still squirreled away.

    Admittedly Basic is pretty dated and not an example of best practices, but I don't understand why you'd make things worse by trying to create a jump table using computed gotos instead of just using literal gotos. shrug



  • @morbiuswilters said:

    I think a better way of saying that would be "computed gotos could be used to create jump tables in Basic, if you were an idiot." And while a jump table makes sense in C, why you would create one in Basic using computed gotos instead of just creating a switch statement with literal gotos (which could be renumbered)..

     

     A jump table is really primarily an assembly language structure, but to get the same functionality in VB, you actually do need to use computed gotos to get the same behavior.  I don't believe VB6 will generate jump tables from a switch statement; at least I've not seen that behavior in other languages that permit non-constant case expressions.  Sure, in theory the compiler could be smart enough to identify when all case expressions were known at runtime and dense, and choose a jump table, but you're giving a lot of credit to the people who came up with a language like VB6 in the first place.



  • @Cat said:

    A jump table is really primarily an assembly language structure, but to get the same functionality in VB, you actually do need to use computed gotos to get the same behavior.  I don't believe VB6 will generate jump tables from a switch statement; at least I've not seen that behavior in other languages that permit non-constant case expressions.  Sure, in theory the compiler could be smart enough to identify when all case expressions were known at runtime and dense, and choose a jump table, but you're giving a lot of credit to the people who came up with a language like VB6 in the first place.

    So basically this is a stupid way to force a pointless low-level optimization in Basic. Gotcha.



  • @morbiuswilters said:

    @Cat said:
    A jump table is really primarily an assembly language structure, but to get the same functionality in VB, you actually do need to use computed gotos to get the same behavior.  I don't believe VB6 will generate jump tables from a switch statement; at least I've not seen that behavior in other languages that permit non-constant case expressions.  Sure, in theory the compiler could be smart enough to identify when all case expressions were known at runtime and dense, and choose a jump table, but you're giving a lot of credit to the people who came up with a language like VB6 in the first place.

    So basically this is a stupid way to force a pointless low-level optimization in Basic. Gotcha.

    Well. It's not pointless, if you're on a truly-ancient dialect of BASIC, it's more like "the only tool you have to do something vaguely-like-unto a function pointer". And if you're on such an ancient system with an ancient dialect, don't discount the occasional optimization technique; you don't know how long that array of if-else statements is going to take to run, even if you have a state-of-the-art 8 Mhz processor (in turbo mode).

    Now, if you tried anything resembling that in anything resembling a modern programming language on modern hardware, that's another story.



  • @morbiuswilters said:

    So basically this is a stupid way to force a pointless low-level optimization in Basic. Gotcha.
    No, basically you're an idiot. When you're coding in BASIC on a ~1MHz CPU with maybe 16K of RAM, every little speed/space optimization helps. Something like GOTO 500 + THINGTODO * 10 for an event handler or whatever was a hell of a lot more efficient than a stack of IF/THEN statements simulating a then-nonexistent SWITCH structure. If you were really lucky, you were working in a BASIC that supported ON...GOTO, which was a simple predecessor to SWITCH statements.

    But of course in modern BASICs that do have structured programming concepts built in, there is little if any point to computed GOTOs.



  • It varied with the BASIC

    Sinclair BASIC ZX-80, ZX-81, TS-1x00 used computed Goto/Gosub for switch statements (renumber fails)
    Commodore BASIC (a subset of Microsoft BASIC) used On Goto & On Gosub with a list of line numbers for switch statements (renumber works)

    Commodore BASIC even had an IDE (an editor ROM cartridge that added basic document editing commands) that extended the built in program modification system that allows programs to be loaded from magazine listings using the keyboard :P

    Other BASICs had nothing to use as a switch and the user was forced to write list of 'If <exp> then goto <line>' statements to implement the switch (common enough even in dialects that had a switch, but that was the programmer's fault)

    On a ZX-8x or TS-1000 computer computed Goto was also used to reduce the memory usage (variables and short expressions use less memory than literals) This is an important consideration when you have 1K RAM shared by BASIC source, variable storage and display (The TS-1000 gave the user a generous 2048 bytes of RAM :P )

    The TS-1000 was my first computer. Later I upgraded to a machine that had a massive 5K of RAM (VIC 20) with 3.5K for source and variables & separate memory for the display ... oh how wonderful it was to not worry about out of memory errors caused by saying too much :D

    Edit: Okay maybe someone can explain how to insert a CR into a comment. I notice that for everyone else it seems to work.


  • Considered Harmful

    I guess I'm fairly lucky that my first PC was a 486 with 8 whole megabytes of RAM. Well, I had a Commodore Amiga 500, but I only played games on that (and used the text-to-speech to utter obscenities).



  • @Zylon said:

    When you're coding in BASIC on a ~1MHz CPU with maybe 16K of RAM, every little speed/space optimization helps. Something like GOTO 500 + THINGTODO * 10 for an event handler or whatever was a hell of a lot more efficient than a stack of IF/THEN statements simulating a then-nonexistent SWITCH structure. If you were really lucky, you were working in a BASIC that supported ON...GOTO, which was a simple predecessor to SWITCH statements.

    Tell us about how you used to wear an onion on your belt.



  • @morbiuswilters said:

    Tell us about how you used to wear an onion on your belt.
    It's more fun to mock you for being wrong.



  • @Zylon said:

    @morbiuswilters said:

    Tell us about how you used to wear an onion on your belt.
    It's more fun to mock you for being wrong.

    I don't think you've been reading the same thread I have. Regardless, I'm sure all that exciting Basic knowledge will help you in your career of giving handjobs to Mexicans who have just crossed the border in exchange for some meth.

    OTOH, you're probably almost 70 and near-death, so I should probably stop making fun of you and let you get back to your hobby of trying to trick cashiers into taking expired coupons.



  • @morbiuswilters said:

    I don't think you've been reading the same thread I have
     

    It's a multithreading bug.

    Your discussion hasn't been updated yet from the one the rest of us see. You're not still on an 8MHz machine, right? I have a tip for BASIC coding that I found in a thread somewhere.



  • @dhromed said:

    @morbiuswilters said:

    I don't think you've been reading the same thread I have
     

    It's a multithreading bug.

    Your discussion hasn't been updated yet from the one the rest of us see. You're not still on an 8MHz machine, right? I have a tip for BASIC coding that I found in a thread somewhere.

    +1



  • I don't know about the hardware levels on this forum, Ben L. just recently upgraded to a Pentium 4. Now his PC doubles as a space heater!



  • @MiffTheFox said:

    I don't know about the hardware levels on this forum, Ben L. just recently upgraded to a Pentium 4. Now his PC doubles as a space heater!

    For values of "recently" equal to 2004.

    Here's a live graph of my load average. A load average of 1 means the same as 100% CPU usage.



  • @morbiuswilters said:

    So basically this is a stupid way to force a pointless low-level optimization in Basic. Gotcha.
     

    It could (in certain applications) be a very substantial speed improvement, if you had a substantial amount of branching.

    And not everyone gets a choice of language.  If you're being forced to marry the pig, you may as well put lipstick on it.



  • @Cat said:

    @morbiuswilters said:

    So basically this is a stupid way to force a pointless low-level optimization in Basic. Gotcha.
     

    It could (in certain applications) be a very substantial speed improvement, if you had a substantial amount of branching.

    And not everyone gets a choice of language.  If you're being forced to marry the pig, you may as well put lipstick on it.

    Lipstick on a Pig ("best" looking)
    $100 Amazon Gift Card, 1 can of Tactical Bacon, 1 stick of lipstick



  • @Ben L. said:

    A load average of 1 means the same as 100% CPU usage.

    No, it doesn't.


Log in to reply