allow GOTO to also jmp to integer variables (dynamic)

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

allow GOTO to also jmp to integer variables (dynamic)

Post 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
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by Josh »

+1
sorry for my bad english
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by Demivec »

+1

This request also reminds me of the ones for 'Restore *pointer'.
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by davido »

+1
DE AA EB
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by DoubleDutch »

+1
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
DontTalkToMe
Enthusiast
Enthusiast
Posts: 334
Joined: Mon Feb 04, 2013 5:28 pm

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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!)
User avatar
langinagel
Enthusiast
Enthusiast
Posts: 131
Joined: Fri Jan 28, 2005 11:53 pm
Location: Germany
Contact:

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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
https://www.doerpsoft.org

Boost. Work. Efficiency.
User avatar
Lord
Addict
Addict
Posts: 900
Joined: Tue May 26, 2009 2:11 pm

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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.
:wink:
Image
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by nco2k »

same reason why ascii was removed. :wink: 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. :P

Code: Select all

42 PRINT "Hello world!"
c ya,
nco2k
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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.
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: allow GOTO to also jmp to integer variables (dynamic)

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Re: allow GOTO to also jmp to integer variables (dynamic)

Post by DoubleDutch »

djes: +1
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
Post Reply