Hou-Rui / pybasic

a python BASIC interpreter
6 stars 1 forks source link

I gave you a star, but I'm really dissapointed :) #2

Open dado-cro opened 1 year ago

dado-cro commented 1 year ago

I always wanted to do something like you did, just for fun. Recreate a piece of my childhood (my idea was to write COMMAND.COM shell for Linux, that would be cool). But you didn't just make a BASIC recreation, you actually made a superset of BASIC, and again you are missing such important statements like: PLAY "" ' plays music in one octave from the built-in speaker, letters A-G are allowed CIRCLE (X,Y), R ' draws a circle at screen coordinates X,Y - R is radius LOCATE X,Y ' places the cursor at coordinates X,Y, so your next print statement will output text there BEEP ' this statement has no arguments, it just plays a beep from the built-in speaker

Omission of GOTO is inexcusable. You now cannot write even the classic BASIC HelloWorld program:

10 PRINT "HELLO WORLD"
20 BEEP
30 GOTO 10

You are also missing important functions (eh, subroutines as they are called in basic):

LEFT$ (S$, X)              ' returns X leftmost characters of string S$
RIGHT$ (S$, X)          ' returns X rightmost characters of string S$
MID$ (S$, X, Y)         ' returns a substring of S$ starting at position X and spanning nest Y characters.

Furthermore, variables don't have to declare a type, it is deducted from there names, for example, this line of yours: A = INPUT() AS INTEGER is completely unnecesary, and probably illegal in real BASIC (you are missing LET statement). This part would do just fine:

LET A = INPUT("ENTER A NUMBER:")
LET A$ = INPUT("ENTER YOUR NAME:")
PRINT "MY AGE IS " + A
PRINT "MY NAME IS " + A$

Variables that end with $ are automatically strings, even subroutines that deal with strings (like MID$() above or CHAR$) have $ in their names so programmers know they are dealing with strings.

And now, complete blasphemy. You didn't implement a simple BEEP, but you did DEFUN, which never existed in BASIC but probably in crazy languages like LISP. Also, not only did you implement functions (BASIC has only subroutines), but you also did structs !!! BASIC is short for "Beginners' All-purpose Symbolic Instruction Code", structs are not for beginners. And your functions+structs function kind of like classes. So you added some object orientation and some functional programming to something that should be the simplest possible imperative programming language to teach kids. There's no BEEP. Ah, I think I will have to fork this, have to check the license first :)

I hope you know I'm just joking, I really like your project I'm sure you had fun with this. I wish you all the best.

aurelVZ commented 8 months ago

dado cro must be from cro-atia