|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Exiting from a Do Loopindividual loops but I am only showing 2 of them for the example.: TEST: Do ...... ...... ...... if answer=true then return endif ....... ....... Loop until count=5 Do ...... ...... ...... if answer=true then return endif ....... ....... Loop until count=5 Return My question is can I leave the loop using the return command without worrying about any problems since I have not exited the loop using the EXIT DO command. Somewhere in the past I thought I remebered that leaving a loop like this can casue a buffer problem since I have not told it to exit the loop. Using the return command will that exit the loop properly and act as if I did exit the do loop? Thanks, Les On Thu, 10 May 2007 00:14:01 -0400, "Les" <v**@prodigy.net> wrote: <snip>>I have the following code snippet of a Gosub routine which has several >individual loops but I am only showing 2 of them for the example.: >My question is can I leave the loop using the return command without In the old days jumping out of loops was not a good idea, but that is>worrying about any problems since I have not exited the loop using the EXIT >DO command. Somewhere in the past I thought I remebered that leaving a loop >like this can casue a buffer problem since I have not told it to exit the >loop. Using the return command will that exit the loop properly and act as >if I did exit the do loop? a very long time ago. In terms of code clarity and program flow I really would not do what you are proposing - not because it will not work, but because it is messy. I loathe GoSubs - while I'm not keen on GoTo I'll use it if it simplifies code - but I'll go to any length to avoid using a GoSub - GoSub is evil because it allows an invisible bit of code to tamper with all the variables "J French" <erew***@nowhere.uk> wrote in message <cut>news:4642b604.5296676@news.btopenworld.com... > - but I'll go to any length to avoid using a GoSub yes,but you also avoid 'Else'... <g>> - GoSub is evil because it allows an invisible bit of code to tamper In what way is it invisible? It's no more hidden than calling a "standard" > with all the variables sub or function and avoids having to pass a long parameter list. Except for 'End', no tool is "evil" when used reasonably. Hi Bob,
You hit it right on the money. I would normally use a sub procedure for this but it would require passing many variables and arrays. For this particular utility which I am designing for my self I also beleived this was the better way since continuously passing arrays and variables over many routines seemed to me a waste of cpu. I thank you all for your comments and assistance. Les Show quoteHide quote "Bob Butler" <noway@nospam.ever> wrote in message news:#FO4tJxkHHA.2552@TK2MSFTNGP06.phx.gbl... > "J French" <erew***@nowhere.uk> wrote in message > news:4642b604.5296676@news.btopenworld.com... > <cut> > > - but I'll go to any length to avoid using a GoSub > > yes,but you also avoid 'Else'... <g> > > > - GoSub is evil because it allows an invisible bit of code to tamper > > with all the variables > > In what way is it invisible? It's no more hidden than calling a "standard" > sub or function and avoids having to pass a long parameter list. Except for > 'End', no tool is "evil" when used reasonably. > > "Les" <v**@prodigy.net> wrote in message Never having used GoSub, I have no opinion on it.news:ukt4db2kHHA.208@TK2MSFTNGP05.phx.gbl... > Hi Bob, > > You hit it right on the money. I would normally use a sub procedure for > this but it would require passing many variables and arrays. For this > particular utility which I am designing for my self I also beleived this > was the better way since continuously passing arrays and variables over many > routines seemed to me a waste of cpu. I thank you all for your comments and > assistance. > Why not just setup some private module level variables? Then all procedures in that module can have at them, and very little needs to be passed around.
Show quote
Hide quote
"Steve Gerrard" <mynameh***@comcast.net> wrote in message That's fine if there are only a few; as you add more the balance tips news:GeadnfyELPYUcd7bnZ2dnUVZ_vOlnZ2d@comcast.com... > > "Les" <v**@prodigy.net> wrote in message > news:ukt4db2kHHA.208@TK2MSFTNGP05.phx.gbl... >> Hi Bob, >> >> You hit it right on the money. I would normally use a sub procedure for >> this but it would require passing many variables and arrays. For this >> particular utility which I am designing for my self I also beleived this >> was the better way since continuously passing arrays and variables over >> many >> routines seemed to me a waste of cpu. I thank you all for your comments >> and >> assistance. >> > > Never having used GoSub, I have no opinion on it. > > Why not just setup some private module level variables? Then all > procedures in that module can have at them, and very little needs to be > passed around. towards keeping the encapsulation by using Gosub. The solution of using a UDT also suffers the problem of moving part of the definition out of the procedure to the module level so instead of having a single block of code you now have at least 2 to deal with. I'm not advocating widespread use of Gosub (or even nested procedures in general). I'm just saying that there are situations where they can be a useful tool and a nice option to have available. On Fri, 11 May 2007 05:47:58 -0700, "Bob Butler" <noway@nospam.ever> <snip>wrote: >That's fine if there are only a few; as you add more the balance tips True, moving some of the data definition out of the procedure>towards keeping the encapsulation by using Gosub. The solution of using a >UDT also suffers the problem of moving part of the definition out of the >procedure to the module level so instead of having a single block of code >you now have at least 2 to deal with. fragments things a bit, but some of the side effects are quite beneficial - one gets a sort of mini Object to play with. >I'm not advocating widespread use of Gosub (or even nested procedures in When I first ran into Nested Procedures in Delphi, my reaction was>general). I'm just saying that there are situations where they can be a >useful tool and a nice option to have available. that they were dangerous - gradually I came to realize that used carefully they are a good idea Like most things, GoSub needs to be used with care On Thu, 10 May 2007 07:49:38 -0700, "Bob Butler" <noway@nospam.ever> True - it is a matter of code flowwrote: >"J French" <erew***@nowhere.uk> wrote in message >news:4642b604.5296676@news.btopenworld.com... ><cut> >> - but I'll go to any length to avoid using a GoSub >yes,but you also avoid 'Else'... <g> >> - GoSub is evil because it allows an invisible bit of code to tamper GoSub is generally used when there is a fair amount of code in the>> with all the variables >In what way is it invisible? It's no more hidden than calling a "standard" >sub or function and avoids having to pass a long parameter list. Except for >'End', no tool is "evil" when used reasonably. routine, so execution jumps off to another place in the same routine - yet has full access to all the variables. If I find I have a situation where I need to pass a lot of variables, and can't see a way of avoiding that, then I tend to make the variables members of a UDT and pass that - the overhead is trivial "Les" <v**@prodigy.net> wrote in message Ewww.news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... >I have the following code snippet of a Gosub routine > My question is can I leave the loop using the return command without No problems. Whatsoever.> worrying about any problems since I have not exited the loop using the > EXIT > DO command. Somewhere in the past I thought I remebered that leaving a > loop > like this can casue a buffer problem since I have not told it to exit the > loop. Using the return command will that exit the loop properly and act > as > if I did exit the do loop? "Jeff Johnson" <i.get@enough.spam> wrote in message I second that Ewww and raise it a Yuck and an Ick! <g>news:eA2qTEwkHHA.1220@TK2MSFTNGP03.phx.gbl... > "Les" <v**@prodigy.net> wrote in message > news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... > >>I have the following code snippet of a Gosub routine > > Ewww. For just ONE reason why GoSub is bad, see the following: PRB: Poor Performance with the GoSub Statement http://support.microsoft.com/kb/174808/en-us -- Mike Microsoft MVP Visual Basic MikeD <nob***@nowhere.edu> wrote:
Show quoteHide quote > "Jeff Johnson" <i.get@enough.spam> wrote in message That is just *so* political. GoSub fulfilled a unique purpose, for which no other > news:eA2qTEwkHHA.1220@TK2MSFTNGP03.phx.gbl... >> "Les" <v**@prodigy.net> wrote in message >> news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... >> >>> I have the following code snippet of a Gosub routine >> >> Ewww. > > I second that Ewww and raise it a Yuck and an Ick! <g> > > For just ONE reason why GoSub is bad, see the following: > > PRB: Poor Performance with the GoSub Statement > http://support.microsoft.com/kb/174808/en-us construct is completely substitutable without forcing other compromises. That Microsoft *chose* to de-optimize it just emphasizes the magnitude of their disconnect with the language. I suppose that depends if you use it or not. Personally, I haven't used a
GoSub since QBASIC, and was shocked when I learned that some people still did. Rob Show quoteHide quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:eCfdj3ykHHA.4112@TK2MSFTNGP04.phx.gbl... > That is just *so* political. GoSub fulfilled a unique purpose, for which > no other construct is completely substitutable without forcing other > compromises. That Microsoft *chose* to de-optimize it just emphasizes the > magnitude of their disconnect with the language. Robert Morley <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ... I *rarely* use it, but boy I see opportunity to all the time. I miss it dearly. >> That is just *so* political. GoSub fulfilled a unique purpose, for which >> no other construct is completely substitutable without forcing other >> compromises. That Microsoft *chose* to de-optimize it just emphasizes the >> magnitude of their disconnect with the language. > > I suppose that depends if you use it or not. Personally, I haven't used a > GoSub since QBASIC, and was shocked when I learned that some people still > did. But, as Mike pointed out, they really fouled it up at VB4/32. Hi Rob,
As Bob stated above it all depends what you are trying to accomplish. I agree that most of the time I stay clear of them. However if I find that using it at times makes the application run faster then I dont care what it takes as long as it accomplishes what I set out to do. Thanks, Les Show quoteHide quote "Robert Morley" <rmor***@magma.ca.N0.Freak1n.sparn> wrote in message news:OHUXuBzkHHA.4112@TK2MSFTNGP04.phx.gbl... > I suppose that depends if you use it or not. Personally, I haven't used a > GoSub since QBASIC, and was shocked when I learned that some people still > did. > > > > Rob > > "Karl E. Peterson" <k***@mvps.org> wrote in message > news:eCfdj3ykHHA.4112@TK2MSFTNGP04.phx.gbl... > > That is just *so* political. GoSub fulfilled a unique purpose, for which > > no other construct is completely substitutable without forcing other > > compromises. That Microsoft *chose* to de-optimize it just emphasizes the > > magnitude of their disconnect with the language. > > Les <v**@prodigy.net> wrote:
> As Bob stated above it all depends what you are trying to accomplish. I I can't recall the last time I found GoSub sped things up. Unless you count > agree that most of the time I stay clear of them. However if I find that > using it at times makes the application run faster then I dont care what it > takes as long as it accomplishes what I set out to do. debugging time saved by not having to remember to update multiple identical code blocks when errors were found or functionality needs changed.
Show quote
Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message IOW, a harbinger of things to come <g>news:eCfdj3ykHHA.4112@TK2MSFTNGP04.phx.gbl... > MikeD <nob***@nowhere.edu> wrote: > > "Jeff Johnson" <i.get@enough.spam> wrote in message > > news:eA2qTEwkHHA.1220@TK2MSFTNGP03.phx.gbl... > >> "Les" <v**@prodigy.net> wrote in message > >> news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... > >> > >>> I have the following code snippet of a Gosub routine > >> > >> Ewww. > > > > I second that Ewww and raise it a Yuck and an Ick! <g> > > > > For just ONE reason why GoSub is bad, see the following: > > > > PRB: Poor Performance with the GoSub Statement > > http://support.microsoft.com/kb/174808/en-us > > That is just *so* political. GoSub fulfilled a unique purpose, for which no other > construct is completely substitutable without forcing other compromises. That > Microsoft *chose* to de-optimize it just emphasizes the magnitude of their > disconnect with the language.
Show quote
Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message Sometimes Karl, I think you're just a little too anti-Microsoft. <g>news:eCfdj3ykHHA.4112@TK2MSFTNGP04.phx.gbl... > MikeD <nob***@nowhere.edu> wrote: >> "Jeff Johnson" <i.get@enough.spam> wrote in message >> news:eA2qTEwkHHA.1220@TK2MSFTNGP03.phx.gbl... >>> "Les" <v**@prodigy.net> wrote in message >>> news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... >>> >>>> I have the following code snippet of a Gosub routine >>> >>> Ewww. >> >> I second that Ewww and raise it a Yuck and an Ick! <g> >> >> For just ONE reason why GoSub is bad, see the following: >> >> PRB: Poor Performance with the GoSub Statement >> http://support.microsoft.com/kb/174808/en-us > > That is just *so* political. GoSub fulfilled a unique purpose, for which > no other construct is completely substitutable without forcing other > compromises. That Microsoft *chose* to de-optimize it just emphasizes the > magnitude of their disconnect with the language. -- Mike Microsoft Visual Basic MVP MikeD <nob***@nowhere.edu> wrote:
>>> PRB: Poor Performance with the GoSub Statement I was there. It was a choice. I wasn't making a judgement in their regard. Well, >>> http://support.microsoft.com/kb/174808/en-us >> >> That is just *so* political. GoSub fulfilled a unique purpose, for which >> no other construct is completely substitutable without forcing other >> compromises. That Microsoft *chose* to de-optimize it just emphasizes the >> magnitude of their disconnect with the language. > > Sometimes Karl, I think you're just a little too anti-Microsoft. <g> I may have *extrapolated* a bit, I suppose... <g> But then, subsequent "history" validated that leap quite nicely. "MikeD" <nob***@nowhere.edu> wrote in message Fold.news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... >>>I have the following code snippet of a Gosub routine >> >> Ewww. > > > I second that Ewww and raise it a Yuck and an Ick! <g> "Jeff Johnson" <i.get@enough.spam> wrote in message Rats, I was hoping I could catch it before I sent it.... I realized too late news:%23ru1V6ykHHA.1776@TK2MSFTNGP05.phx.gbl... >>>>I have the following code snippet of a Gosub routine >>> >>> Ewww. >> >> >> I second that Ewww and raise it a Yuck and an Ick! <g> > > Fold. that I should have added "You know, because I hate CALL." Did you notice in their examples, they're also using the "evil" End
statement? Rob Show quoteHide quote "MikeD" <nob***@nowhere.edu> wrote in message news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... > For just ONE reason why GoSub is bad, see the following: > > PRB: Poor Performance with the GoSub Statement > http://support.microsoft.com/kb/174808/en-us
Show quote
Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message Don't confuse the syntax with the mess MS made of the implementation. I got news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... > > "Jeff Johnson" <i.get@enough.spam> wrote in message > news:eA2qTEwkHHA.1220@TK2MSFTNGP03.phx.gbl... >> "Les" <v**@prodigy.net> wrote in message >> news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl... >> >>>I have the following code snippet of a Gosub routine >> >> Ewww. > > > I second that Ewww and raise it a Yuck and an Ick! <g> > > For just ONE reason why GoSub is bad, see the following: > > PRB: Poor Performance with the GoSub Statement > http://support.microsoft.com/kb/174808/en-us out of the habit of using Gosub myself a long time ago but it does have advantages in some situations. On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> wrote: ¤ >¤ > I second that Ewww and raise it a Yuck and an Ick! <g> ¤ > ¤ > For just ONE reason why GoSub is bad, see the following: ¤ > ¤ > PRB: Poor Performance with the GoSub Statement ¤ > http://support.microsoft.com/kb/174808/en-us ¤ ¤ Don't confuse the syntax with the mess MS made of the implementation. I got ¤ out of the habit of using Gosub myself a long time ago but it does have ¤ advantages in some situations. Yes, for years it's been a fine example of how not to write code, performance notwithstanding. Paul ~~~~ Microsoft MVP (Visual Basic) "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message When I was a lad Paul it was the *only* way to write Subs ;-)news:s21743d9tk2p2kfankfm9m1j8e9dushr87@4ax.com... > Yes, for years it's been a fine example [Gosub] of how not to > write code, performance notwithstanding. Mike On Thu, 10 May 2007 22:17:48 +0100, "Mike Williams" <mi***@whiskyandCoke.com> wrote: ¤ > Yes, for years it's been a fine example [Gosub] of how not to¤ "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message ¤ news:s21743d9tk2p2kfankfm9m1j8e9dushr87@4ax.com... ¤ ¤ > write code, performance notwithstanding. ¤ ¤ When I was a lad Paul it was the *only* way to write Subs ;-) Operative word being *was*. It's also the primary reason why my first programming language was Pascal. ;-) Paul ~~~~ Microsoft MVP (Visual Basic) Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
> On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> wrote: You just never did *get it* about GoSub, did you? There was no other code > ¤ > PRB: Poor Performance with the GoSub Statement > ¤ > http://support.microsoft.com/kb/174808/en-us > ¤ > ¤ Don't confuse the syntax with the mess MS made of the implementation. I got > ¤ out of the habit of using Gosub myself a long time ago but it does have > ¤ advantages in some situations. > > Yes, for years it's been a fine example of how not to write code, performance > notwithstanding. container, independent of data, in the language. As I understand it, VFred has (or is about to get) nested procedures. Nearly the same thing. Drop the hypocrisy. > There was no other code container, independent of data, in the language. Can you re-word that or something? As stated, I don't understand what it is you're trying to say. I know GoSub can be used to simulate nested procedures...is there something else it does? Rob Robert Morley <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
>> There was no other code container, independent of data, in the language. Standard subroutines contain code *and* data. But gosubs only contain code. They > > Can you re-word that or something? As stated, I don't understand what it is > you're trying to say. I know GoSub can be used to simulate nested > procedures...is there something else it does? use the data of their container. It's similar to declaring variables private at the top of a module, and then using them throughout the module. Well, that's as close as it gets, anyway. It's sort of like another layer of scope, but not really. Hmmm, maybe I can't really reword it any better. The real beauty of gosubs are just like nested procedures. They allow you to containerize common code blocks that need to be executed at varying locations within a routine -- maintaining full access to all the routine-scoped data, of course. The only alternative now is to repeat those code blocks, introducing the potential for nasty bugs when they're not all updated identically over time. Robert Morley posted...
>> There was no other code container, independent of data, in the language. They're pretty good for building a string to print out. Just pass in> > Can you re-word that or something? As stated, I don't understand what it is > you're trying to say. I know GoSub can be used to simulate nested > procedures...is there something else it does? the full string and GoSub to the PrintThis and update PageCount and LineCount to start configuring the string for another page. It allows you to add the PageCount and TotalPages to the bottom of each page at the appropriate spot. If there are alot of variables to print, an array of variables, you might need to keep track of which index was just printed and advance the variable indexes. It provides a real convenient way to update all the variables and check for a termination event (like you've just printed the last page and there's nothing more to print) in one spot before continuing on inside an endless loop. -- Jim Carlock Post replies to the group. You re-worded it just fine. Now I understand what it was you were trying to
say. :-) Show quoteHide quote "Karl E. Peterson" <k***@mvps.org> wrote in message news:O2OfUC2kHHA.1624@TK2MSFTNGP06.phx.gbl... > Robert Morley <rmor***@magma.ca.N0.Freak1n.sparn> wrote: >>> There was no other code container, independent of data, in the language. >> >> Can you re-word that or something? As stated, I don't understand what it >> is >> you're trying to say. I know GoSub can be used to simulate nested >> procedures...is there something else it does? > > Standard subroutines contain code *and* data. But gosubs only contain > code. They use the data of their container. It's similar to declaring > variables private at the top of a module, and then using them throughout > the module. Well, that's as close as it gets, anyway. It's sort of like > another layer of scope, but not really. Hmmm, maybe I can't really reword > it any better. > > The real beauty of gosubs are just like nested procedures. They allow you > to containerize common code blocks that need to be executed at varying > locations within a routine -- maintaining full access to all the > routine-scoped data, of course. The only alternative now is to repeat > those code blocks, introducing the potential for nasty bugs when they're > not all updated identically over time. > -- > .NET: It's About Trust! > http://vfred.mvps.org >
Show quote
Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message I'm sure nested procedures will be promoted as a big advantage of VB.Net news:u%23oO7g1kHHA.4188@TK2MSFTNGP02.phx.gbl... > Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote: >> On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> >> wrote: >> ¤ > PRB: Poor Performance with the GoSub Statement >> ¤ > http://support.microsoft.com/kb/174808/en-us >> ¤ >> ¤ Don't confuse the syntax with the mess MS made of the implementation. >> I got >> ¤ out of the habit of using Gosub myself a long time ago but it does have >> ¤ advantages in some situations. >> >> Yes, for years it's been a fine example of how not to write code, >> performance >> notwithstanding. > > You just never did *get it* about GoSub, did you? There was no other code > container, independent of data, in the language. As I understand it, > VFred has (or is about to get) nested procedures. Nearly the same thing. > Drop the hypocrisy. despite the fact that they're not all that different than Gosub. The only difference is that MS won't be disparaging them. Bob Butler <noway@nospam.ever> wrote:
Show quoteHide quote > "Karl E. Peterson" <k***@mvps.org> wrote in message Yet.> news:u%23oO7g1kHHA.4188@TK2MSFTNGP02.phx.gbl... >> Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote: >>> On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> >>> wrote: >>> ¤ > PRB: Poor Performance with the GoSub Statement >>> ¤ > http://support.microsoft.com/kb/174808/en-us >>> ¤ >>> ¤ Don't confuse the syntax with the mess MS made of the implementation. >>> I got >>> ¤ out of the habit of using Gosub myself a long time ago but it does have >>> ¤ advantages in some situations. >>> >>> Yes, for years it's been a fine example of how not to write code, >>> performance >>> notwithstanding. >> >> You just never did *get it* about GoSub, did you? There was no other code >> container, independent of data, in the language. As I understand it, >> VFred has (or is about to get) nested procedures. Nearly the same thing. >> Drop the hypocrisy. > > I'm sure nested procedures will be promoted as a big advantage of VB.Net > despite the fact that they're not all that different than Gosub. The only > difference is that MS won't be disparaging them. > I'm sure nested procedures will be promoted as a big advantage of VB.Net I bet the next big thing they add to VB.NET is a LineVector statement. The > despite the fact that they're not all that different than Gosub. The only > difference is that MS won't be disparaging them. beauty of this construct is that you can place a label name (followed by a colon) anywhere in your code and then execute a LineVector statement specifying the label name... doing this will instantly make your code continue executing from the line immediately after the label statement.<g> Rick "Rick Rothstein (MVP - VB)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in ah yes, that would be vastly superior to GoTo but it will have to bemessage news:uCWFS73kHHA.4960@TK2MSFTNGP02.phx.gbl... >> I'm sure nested procedures will be promoted as a big advantage of VB.Net >> despite the fact that they're not all that different than Gosub. The >> only difference is that MS won't be disparaging them. > > I bet the next big thing they add to VB.NET is a LineVector statement. The > beauty of this construct is that you can place a label name (followed by a > colon) anywhere in your code and then execute a LineVector statement > specifying the label name... doing this will instantly make your code > continue executing from the line immediately after the label statement.<g> my.application.codemodules.thismodule.procedures.thisprocedure.execution.alter.linevector(my.application.codemodules.thismodule.procedures.thisprocedure.execution.alter.linelabels.whatever)
Show quote
Hide quote
>>> I'm sure nested procedures will be promoted as a big advantage of VB.Net Great... it's a one-liner! <g>>>> despite the fact that they're not all that different than Gosub. The >>> only difference is that MS won't be disparaging them. >> >> I bet the next big thing they add to VB.NET is a LineVector statement. >> The beauty of this construct is that you can place a label name (followed >> by a colon) anywhere in your code and then execute a LineVector statement >> specifying the label name... doing this will instantly make your code >> continue executing from the line immediately after the label >> statement.<g> > > ah yes, that would be vastly superior to GoTo but it will have to be > > my.application.codemodules.thismodule.procedures.thisprocedure.execution.alter.linevector(my.application.codemodules.thismodule.procedures.thisprocedure.execution.alter.linelabels.whatever) Rick > ah yes, that would be vastly superior to GoTo but it will have to be my.application.codemodules.thismodule.procedures.thisprocedure.execution.alter.linevector(my.application.codemodules.thismodule.proc> > edures.thisprocedure.execution.alter.linelabels.whatever) "Rick Rothstein (MVP - VB)" ... : Great... it's a one-liner! <g> Then with an addition operator, OR operators and AND operators,those labels become a longer fancier. -- Jim Carlock Post replies to the group. On Thu, 10 May 2007 16:09:14 -0700, "Karl E. Peterson" <k***@mvps.org> wrote: ¤ Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:¤ > On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> wrote: ¤ > ¤ > PRB: Poor Performance with the GoSub Statement¤ > ¤ > http://support.microsoft.com/kb/174808/en-us ¤ > ¤ ¤ > ¤ Don't confuse the syntax with the mess MS made of the implementation. I got ¤ > ¤ out of the habit of using Gosub myself a long time ago but it does have ¤ > ¤ advantages in some situations. ¤ > ¤ > Yes, for years it's been a fine example of how not to write code, performance ¤ > notwithstanding. ¤ ¤ You just never did *get it* about GoSub, did you? There was no other code ¤ container, independent of data, in the language. As I understand it, VFred has (or ¤ is about to get) nested procedures. Nearly the same thing. Drop the hypocrisy. Operative word being *was* again. GoSub does not have true nested procedure capability. It is also not a code container. That's like saying the If statement or Do...Loop are code containers. There is no control over variable or code scope as in a true nested procedure. As a nested procedure, it's at best a fudged imitation. Paul ~~~~ Microsoft MVP (Visual Basic) Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
Show quoteHide quote > On Thu, 10 May 2007 16:09:14 -0700, "Karl E. Peterson" <k***@mvps.org> wrote: My bad. Of course, GoSub survived the duration of ClassicVB's natural life. Past > > ¤ Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote: > ¤ > On Thu, 10 May 2007 12:19:04 -0700, "Bob Butler" <noway@nospam.ever> wrote: > ¤ > ¤ > PRB: Poor Performance with the GoSub Statement > ¤ > ¤ > http://support.microsoft.com/kb/174808/en-us > ¤ > ¤ > ¤ > ¤ Don't confuse the syntax with the mess MS made of the implementation. I got > ¤ > ¤ out of the habit of using Gosub myself a long time ago but it does have > ¤ > ¤ advantages in some situations. > ¤ > > ¤ > Yes, for years it's been a fine example of how not to write code, performance > ¤ > notwithstanding. > ¤ > ¤ You just never did *get it* about GoSub, did you? There was no other code > ¤ container, independent of data, in the language. As I understand it, VFred has > ¤ (or is about to get) nested procedures. Nearly the same thing. Drop the > hypocrisy. > > Operative word being *was* again. tense was inappropriate. > GoSub does not have true nested procedure It's the closest option available in the language, so go hold your nose elsewhere.> capability. It is also not a code container. That's like saying the If statement > or Do...Loop are code containers. There is no control over variable or code scope > as in a true nested procedure. > > As a nested procedure, it's at best a fudged imitation. "MikeD" <nob***@nowhere.edu> wrote in message Did anyone notice that the code at that link does not do test what it claims to news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... > > > For just ONE reason why GoSub is bad, see the following: > > PRB: Poor Performance with the GoSub Statement > http://support.microsoft.com/kb/174808/en-us > > test? In particular, the function call version does not put the loop body in a function, it just puts the whole loop in one, and should be identical to the inline version. I did a real test, and found that GoSub is faster than a Sub call if compiled to PCode, and slower by quite a bit if compiled to native. In fact, compiled to native it is slower than itself in pcode. Why wouldn't an "optimizing" compiler simply inline all the GoSub code where ever it was called? In article <QICdnZgTcIV3bt7bnZ2dnUVZ_vGin***@comcast.com>,
mynameh***@comcast.net says... Show quoteHide quote > Are you optimizing for speed or program size? That would change things > "MikeD" <nob***@nowhere.edu> wrote in message > news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... > > > > > > For just ONE reason why GoSub is bad, see the following: > > > > PRB: Poor Performance with the GoSub Statement > > http://support.microsoft.com/kb/174808/en-us > > > > > > Did anyone notice that the code at that link does not do test what it claims to > test? In particular, the function call version does not put the loop body in a > function, it just puts the whole loop in one, and should be identical to the > inline version. > > I did a real test, and found that GoSub is faster than a Sub call if compiled to > PCode, and slower by quite a bit if compiled to native. In fact, compiled to > native it is slower than itself in pcode. > > Why wouldn't an "optimizing" compiler simply inline all the GoSub code where > ever it was called? quite a bit in this case. -- Remove the ns_ from if replying by e-mail (but keep posts in the newsgroups if possible).
Show quote
Hide quote
"David Kerber" <ns_dkerber@ns_WarrenRogersAssociates.com> wrote in message It was set to optimize for speed.news:MPG.20ae3a8e13c6a96b989b0f@news.conversent.net... > In article <QICdnZgTcIV3bt7bnZ2dnUVZ_vGin***@comcast.com>, > mynameh***@comcast.net says... >> >> "MikeD" <nob***@nowhere.edu> wrote in message >> news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... >> > >> > >> > For just ONE reason why GoSub is bad, see the following: >> > >> > PRB: Poor Performance with the GoSub Statement >> > http://support.microsoft.com/kb/174808/en-us >> > >> > >> >> Did anyone notice that the code at that link does not do test what it claims >> to >> test? In particular, the function call version does not put the loop body in >> a >> function, it just puts the whole loop in one, and should be identical to the >> inline version. >> >> I did a real test, and found that GoSub is faster than a Sub call if compiled >> to >> PCode, and slower by quite a bit if compiled to native. In fact, compiled to >> native it is slower than itself in pcode. >> >> Why wouldn't an "optimizing" compiler simply inline all the GoSub code where >> ever it was called? > > Are you optimizing for speed or program size? That would change things > quite a bit in this case. > > Steve Gerrard <mynameh***@comcast.net> wrote:
Show quoteHide quote > "MikeD" <nob***@nowhere.edu> wrote in message Because Microsoft *CHOSE* to de-optimize this construct. (Repeating myself here.)> news:efBBvpykHHA.4112@TK2MSFTNGP04.phx.gbl... >> >> >> For just ONE reason why GoSub is bad, see the following: >> >> PRB: Poor Performance with the GoSub Statement >> http://support.microsoft.com/kb/174808/en-us > > Did anyone notice that the code at that link does not do test what it claims to > test? In particular, the function call version does not put the loop body in a > function, it just puts the whole loop in one, and should be identical to the > inline version. > > I did a real test, and found that GoSub is faster than a Sub call if compiled to > PCode, and slower by quite a bit if compiled to native. In fact, compiled to > native it is slower than itself in pcode. > > Why wouldn't an "optimizing" compiler simply inline all the GoSub code where > ever it was called?
Advice on storage and retrieval
A bit of Maths help with arrays Right syntax for EXPRESSION Collection Capabilities How to control button in the form if i have more than 1 user profi Closing recordset Excuting a command line program from within VB Sending email from app in vb6 to hotmail Variants Type mismatch error |
|||||||||||||||||||||||