Allow gosub in procedures

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

Demivec wrote:On a side note, I'm interrested in a "On <indexvalue> ExecProc" kind of command as well. It would be used instead of the Select/Case. I think it has merits for speed and ease of reading. But that's another story.
Agreed!

I currently use an array of addresses and CallFunctionFast for a similar result. Nice to have this as native! But, as you say, another story.
Dare2 cut down to size
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

The commands Goto, Gosub & Return are still present in PB? Never noticed that... :shock:
Tranquil
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Looks like this is a safe gosub for a procedure...

http://www.purebasic.fr/english/viewtop ... 433#229433
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
mesozorn
Enthusiast
Enthusiast
Posts: 171
Joined: Fri Feb 20, 2009 2:23 am

Post by mesozorn »

In VB, you can easily do:

Code: Select all

Public Sub Test()
a = 20
GoSub Whatever
Exit Sub

Whatever:
MsgBox "Value is " + Str(a)
Return
End Sub
...without messing up the stack or causing any problems whatsoever. It should be just as simple to do this in PB.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Gravedigger?

[edit]
OMG, he even raped a second thread with the same response ...

http://www.purebasic.fr/english/viewtopic.php?t=30736
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
mesozorn
Enthusiast
Enthusiast
Posts: 171
Joined: Fri Feb 20, 2009 2:23 am

Post by mesozorn »

Fluid Byte wrote:OMG, he even raped a second thread with the same response ...
Sorry, I got confused thinking they were different pages of the same thread, and that my response hadn't been posted on the first try, so I tried again. Didn't realize it was a repeat post.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

point is
freak wrote:Gosub adjusts the stack, Goto doesn't. Thats why you can use the one inside procedures and not the other.
so, absolutely meaningless what VisualBasic does or doesn't or fry some dingo's kidneys on a hot tin roof....

it would not be "simple" to allow Gosub in a Procedure, but would need a whole bloody lot of altering the handling away from how it is now.

... and that for some ... useless (?) ... feature?
c'mon....
oh... and have a nice day.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

netmaestro wrote:I don't believe either one belongs in a modern variant of the Basic language. There's far more power in PB today than was ever in early Basic's, so much in fact that using primitive commands like these is not only pointless but it leads to seriously bad programming styles.
+11
Edsger W.Dijkstra wrote:The unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress.
Edsger W.Dijkstra wrote:The go to statement as it stands is just too primitive, it is too much an invitation to make a mess of one's program.
Image

Don't use goto until you have learnt enough to know why using goto is bad, then hopefully you would have learn't never to use it!!!
--Kale

Image
Post Reply