Page 1 of 2
allow GOTO to also jmp to integer variables (dynamic)
Posted: Tue Nov 29, 2016 12:12 pm
by Keya
Currently when the PB compiler encounters "GOTO MyProc" im guessing it does something like the following pseudocode:
Code: Select all
If IsValidLabel(MyProc)
Output '! jmp MyProc'
Else
CompilerError
EndIf
ie. it can only be used to goto fixed labels, as per docs.
I'd love it if it asked a second question - "is it a valid Integer variable? if yes jmp to that address"
Code: Select all
If IsValidLabel(MyProc)
Output '! jmp MyProc'
Else
If IsValidIntegerVariable(MyProc)
Output '! jmp [MyProc]'
Else
CompilerError
EndIf
EndIf
No need to use inline "!jmp"'s then (my current workaround) as PB native syntax could be used, and it allows greater flexibility due to dynamic addresses that can be ascertained at runtime

(and yes i know PB already has ways to CALL dyn addresses, but seemingly no JMP?

)
Thankyou for considering
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Thu Mar 16, 2017 9:30 pm
by Josh
+1
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Thu Mar 16, 2017 11:10 pm
by Demivec
+1
This request also reminds me of the ones for 'Restore *pointer'.
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Thu Mar 16, 2017 11:21 pm
by davido
+1
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sat Mar 18, 2017 2:16 pm
by DoubleDutch
+1
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sat Mar 18, 2017 5:41 pm
by DontTalkToMe
Don't hold your breath.
People using PureBasic should consider themselves lucky goto it's still here.
http://www.purebasic.fr/english/viewtop ... 97#p428497
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sat Mar 18, 2017 10:20 pm
by Keya
yes i know the GOTO argument has been done to death, but if GOTO is removed you might as well also remove JMP from the assembler. (Please don't!)
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 3:26 pm
by langinagel
-10
There were reasons why BASIC as language is not popular any more, one of it is the provision and (wild) use of GOTO, which lead to non-maintainable code.
Old, but still bold:
http://homepages.cwi.nl/~storm/teaching ... stra68.pdf
I agree that there are discussions to polish up the use of GOTO also in C++.
If GOTO is used once in a while (!!!, not wildly) with a good rationale - ok.
But this request would lead to the opposite direction (wild use) and push Purebasic further in the "not for professional programming" corner.
I would rather see to keep the procedural approach (like PASCAL) as necessary.
Well,...Fred has to decide.
Greatings
LN
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 6:56 pm
by Lord
[Deleting "-10" by adding "+10"]
A "professional programmer" knows how to use GOTO in the right way!
So eliminating GOTO pushes
langinagel wrote:Purebasic further in the "not for professional programming" corner.

Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 9:41 pm
by nco2k
personally i think Goto and Gosub should be removed. you either know what you are doing and can directly use asm for stuff like that, or you dont. and those people shouldnt be using Goto in the first place. just my two cents.
c ya,
nco2k
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 10:03 pm
by DoubleDutch
If you don't use it then why does it matter if it's improved?
I vote for it and gosub to change to allow an expression
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 10:28 pm
by nco2k
same reason why ascii was removed.

wether people like it or not, chances are high that this will happen in the future. im amazed that the waponez example still uses Gosub, which sets a terrible example for young people who are trying to learn purebasic and programing in general. sure, i shouldnt care about it since i dont use it, but i really dont see the point in supporting such relics in the year 2017. i mean, we could also add Then and enforce line numbering again.
c ya,
nco2k
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 11:24 pm
by djes
You know what piss me off? It's that a lot of coders don't know what is a jmp, what is a register, what is the carry. They only knows objects and how to instantiate, overload and override. Most of their programs are stack of stacks and they don't care about optimisation or how to get much of the CPU. That's OK for some stuff, there's miscellaneous problems and solutions, that's all. But don't say to me that this is the way to go.
We're using pb, pb is BASIC, and BASIC knows goto. We're using it as a low level language, and so we have to know what is a jmp. And we love that, we love to have the control. There's nothing really hidden, except API, and it's already a pain. Pb is not Java or Smalltalk, it will never be. It's a fun language, made for little/medium projects, and rapid application development. Let enjoy new and existing instructions for a better cpu control, and let everybody judge about how a program should be written.
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Sun Mar 19, 2017 11:56 pm
by nco2k
basic knows Then, basic knows line numbering. purebasic isnt really basic and we all know that. we have pointers and countless of other things that are nowhere near basic. we also dont have relics like Let for example. you can use asm to jump wherever you want. you can use asm to access registers however you want. you are perfectly entitled to do so. you are also perfectly entitled to use Goto and Gosub. the point of my post was not to piss people off. chances are that one day Goto and Gosub will be removed. asm wont. so why not simply use asm instead and dont worry about stuff like this anymore.
c ya,
nco2k
Re: allow GOTO to also jmp to integer variables (dynamic)
Posted: Mon Mar 20, 2017 12:34 am
by DoubleDutch
djes: +1