skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
328 stars 27 forks source link

Fantasy Basic: GOSUB by name? #24

Closed skx closed 5 years ago

skx commented 6 years ago

I could imagine this, to allow you to GOTO/GOSUB via ident:

10 LET a = 3000
20 GOSUB a

However neither helps if you want to renumber your programs. (Well I guess they add clarity.) However this would:

10 GOSUB steve
...
100 LABEL steve
110  RETURN

Do we want to add such things? Maybe. Filed as a fantasy for the moment.

stuaxo commented 6 years ago

QBasics named subs and functions are nice, you end up not needing line numbers

skx commented 6 years ago

Yeah if you had names you'd not need numbers - right now they're basically ignored except for GOTO/GOSUB.

I'm still in two minds about this, to be honest I expect the natural compromise would be to implement DEF FN. That would allow calling things by name, and also be a challenge to implement.

(Edit: User-defined functions now exist :)

stuaxo commented 5 years ago

Soo... does this future examples won't have line numbers :rofl:

More QBasic compatibility in the future ? (though we do already have QB64 for that)

skx commented 5 years ago

I decided that I'd leave as-is. The addition of user-defined functions goes most of the way towards offering useful/reusable functions.

Adding too many extra things takes it away from the Sinclair BASIC I used to use.

:)