Home All Groups Group Topic Archive Search About
Author
10 May 2007 4:14 AM
Les
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.:

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

Author
10 May 2007 6:11 AM
J French
On Thu, 10 May 2007 00:14:01 -0400, "Les" <v**@prodigy.net> wrote:

>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.:

<snip>

>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?

In the old days jumping out of loops was not a good idea, but that is
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
Author
10 May 2007 2:49 PM
Bob Butler
"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.
Author
11 May 2007 12:52 AM
Les
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.
>
>
Author
11 May 2007 4:09 AM
Steve Gerrard
"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.
Author
11 May 2007 12:47 PM
Bob Butler
Show quote Hide quote
"Steve Gerrard" <mynameh***@comcast.net> wrote in message
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.


That's fine if there are only a few; as you add more the balance tips
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.
Author
12 May 2007 5:43 AM
J French
On Fri, 11 May 2007 05:47:58 -0700, "Bob Butler" <noway@nospam.ever>
wrote:

<snip>

>That's fine if there are only a few; as you add more the balance tips
>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.

True, moving some of the data definition out of the procedure
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
>general).  I'm just saying that there are situations where they can be a
>useful tool and a nice option to have available.

When I first ran into Nested Procedures in Delphi, my reaction was
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
Author
11 May 2007 6:12 AM
J French
On Thu, 10 May 2007 07:49:38 -0700, "Bob Butler" <noway@nospam.ever>
wrote:

>"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>

True - it is a matter of code flow

>> - 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.

GoSub is generally used when there is a fair amount of code in the
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
Author
10 May 2007 12:46 PM
Jeff Johnson
"Les" <v**@prodigy.net> wrote in message
news:Ocs2ZnrkHHA.1624@TK2MSFTNGP06.phx.gbl...

>I have the following code snippet of a Gosub routine

Ewww.

> 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?

No problems. Whatsoever.
Author
10 May 2007 5:41 PM
MikeD
"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


--
Mike
Microsoft MVP Visual Basic
Author
10 May 2007 6:06 PM
Karl E. Peterson
MikeD <nob***@nowhere.edu> wrote:
Show quoteHide quote
> "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.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
10 May 2007 6:15 PM
Robert Morley
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.
Author
10 May 2007 8:00 PM
Karl E. Peterson
Robert Morley <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
> "Karl E. Peterson" <k***@mvps.org> wrote ...
>> 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.

I *rarely* use it, but boy I see opportunity to all the time.  I miss it dearly.
But, as Mike pointed out, they really fouled it up at VB4/32.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
11 May 2007 12:54 AM
Les
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.
>
>
Author
14 May 2007 8:52 PM
Karl E. Peterson
Les <v**@prodigy.net> wrote:
> 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.

I can't recall the last time I found GoSub sped things up.  Unless you count
debugging time saved by not having to remember to update multiple identical code
blocks when errors were found or functionality needs changed.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
10 May 2007 6:27 PM
BeastFish
Show quote Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
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.

IOW, a harbinger of things to come <g>
Author
10 May 2007 6:45 PM
MikeD
Show quote Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
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.

Sometimes Karl, I think you're just a little too anti-Microsoft.  <g>

--
Mike
Microsoft Visual Basic MVP
Author
10 May 2007 7:58 PM
Karl E. Peterson
MikeD <nob***@nowhere.edu> wrote:
>>> 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.
>
> Sometimes Karl, I think you're just a little too anti-Microsoft.  <g>

I was there.  It was a choice.  I wasn't making a judgement in their regard.  Well,
I may have *extrapolated* a bit, I suppose... <g>  But then, subsequent "history"
validated that leap quite nicely.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
10 May 2007 6:12 PM
Jeff Johnson
"MikeD" <nob***@nowhere.edu> wrote in message
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>

Fold.
Author
10 May 2007 6:18 PM
Jeff Johnson
"Jeff Johnson" <i.get@enough.spam> wrote in message
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.

Rats, I was hoping I could catch it before I sent it.... I realized too late
that I should have added "You know, because I hate CALL."
Author
10 May 2007 6:13 PM
Robert Morley
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
Author
10 May 2007 7:19 PM
Bob Butler
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
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

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.
Author
10 May 2007 9:09 PM
Paul Clement
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)
Author
10 May 2007 9:17 PM
Mike Williams
"Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message
news:s21743d9tk2p2kfankfm9m1j8e9dushr87@4ax.com...

> Yes, for years it's been a fine example [Gosub] of how not to
> write code, performance notwithstanding.

When I was a lad Paul it was the *only* way to write Subs ;-)

Mike
Author
11 May 2007 5:43 PM
Paul Clement
On Thu, 10 May 2007 22:17:48 +0100, "Mike Williams" <mi***@whiskyandCoke.com> wrote:

¤ "Paul Clement" <UseAdddressAtEndofMess***@swspectrum.com> wrote in message
¤ news:s21743d9tk2p2kfankfm9m1j8e9dushr87@4ax.com...
¤
¤ > Yes, for years it's been a fine example [Gosub] of how not to
¤ > 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)
Author
10 May 2007 11:09 PM
Karl E. Peterson
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.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
10 May 2007 11:52 PM
Robert Morley
> 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
Author
11 May 2007 12:09 AM
Karl E. Peterson
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
Author
11 May 2007 12:42 AM
Jim Carlock
Robert Morley posted...
>> 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?

They're pretty good for building a string to print out. Just pass in
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.
Author
11 May 2007 2:12 AM
Robert Morley
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
>
Author
11 May 2007 12:02 AM
Bob Butler
Show quote Hide quote
"Karl E. Peterson" <k***@mvps.org> wrote in message
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.
Author
11 May 2007 12:07 AM
Karl E. Peterson
Bob Butler <noway@nospam.ever> wrote:
Show quoteHide quote
> "Karl E. Peterson" <k***@mvps.org> wrote in message
> 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.

Yet.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
11 May 2007 3:45 AM
Rick Rothstein (MVP - VB)
> 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>

Rick
Author
11 May 2007 3:58 AM
Bob Butler
"Rick Rothstein (MVP - VB)" <rickNOSPAMnews@NOSPAMcomcast.net> wrote in
message 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>

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)
Author
11 May 2007 4:05 AM
Rick Rothstein (MVP - VB)
Show quote Hide quote
>>> 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>
>
> 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)

Great... it's a one-liner!  <g>

Rick
Author
12 May 2007 12:22 AM
Jim Carlock
> 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.
Author
11 May 2007 5:56 PM
Paul Clement
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)
Author
14 May 2007 8:57 PM
Karl E. Peterson
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:
>
> ¤ 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.

My bad.  Of course, GoSub survived the duration of ClassicVB's natural life.  Past
tense was inappropriate.

> 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.

It's the closest option available in the language, so go hold your nose elsewhere.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
11 May 2007 4:41 AM
Steve Gerrard
"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?
Author
11 May 2007 1:32 PM
David Kerber
In article <QICdnZgTcIV3bt7bnZ2dnUVZ_vGin***@comcast.com>,
mynameh***@comcast.net says...
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
> >
> >
>
> 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.


--
Remove the ns_ from if replying by e-mail (but keep posts in the
newsgroups if possible).
Author
11 May 2007 2:50 PM
Steve Gerrard
Show quote Hide quote
"David Kerber" <ns_dkerber@ns_WarrenRogersAssociates.com> wrote in message
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.
>
>

It was set to optimize for speed.
Author
14 May 2007 8:58 PM
Karl E. Peterson
Steve Gerrard <mynameh***@comcast.net> wrote:
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
>
> 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?

Because Microsoft *CHOSE* to de-optimize this construct.  (Repeating myself here.)
--
..NET: It's About Trust!
http://vfred.mvps.org