3 ms·
It doesn't have functions they are normally thought of - but most BASIC languages of the era (generally Microsoft derived) did have simple "DEF FN" style: http
by cr0sh 8y ago
It doesn't have functions they are normally thought of - but most BASIC languages of the era (generally Microsoft derived) did have simple "DEF FN" style:
http://www.antonis.de/qbebooks/gwbasman/deffn.html http://www.antonis.de/qbebooks/gwbasman/deffn.html
Otherwise, you had to fake it, which you kinda note: Since all variables were global in nature, this made it challenging - but possible. You could set aside a few named variables for your "functions", then just use GOSUB:
10 X0=1:X1=3:GOSUB 1000:PRINT Y0
.
.
.
999 END
1000 REM THE FUNCTION HERE
1010 Y0=X0+X1
1020 RETURN
That isn't "spaghetti code"; done properly, it's a form of structured BASIC. No, it isn't as readable, but you honestly get used to it. "GOSUB 2050" just means "do this task" and you know what to pass it (and if you don't, then you need to consult your docs or REM statements).
It's only when you start mixing in GOTOs jumping out of routines, all over the place, no structure, etc - that's where you get the infamous spaghetti code...
- teddyh 8y ago> It doesn't have functions they are normally thought of - but most BASIC languages of the era (generally Microsoft derived) did have simple "DEF FN" style: Um, yes? That’s exactly what I meant by “an even more limited form of Python's style of lambdas”. Which is what they are. I never used them myself; I never, ever, found a use for them. The rest of your argument seems to be “If you’re careful, it’s techically possible to write structured code.”, but the same can be said of most any language. Even assembly language for $FOO’s sake, usually has labels!