Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  $ echo 'PRINT 3+4∗5' > test.bas 
  $ go run main.go test.bas
  34

  $ echo 'PRINT (3+4*5)' > test.bas
  $ go run main.go test.bas
  23

  $ echo 'PRINT (3+4)*5' > test.bas
  $ go run main.go test.bas
  35
No idea where it's getting 34 from though.


Grr. Expressions are hard:

    10 LET a = 3+4*5
    20 PRINT a, "\n"
Produces the expected outcome:

    -> 23
Bug filed:

https://github.com/skx/gobasic/issues/41


Yes, but it should not require that LET statement. The expression evaluator looks subtly broken.


Bug filed, as per the edited comment above. I definitely agree this is wrong!


Don't know if it's the same bug, but "PRINT 1/0" returns 1. "PRINT (1/0)" prints nothing. Using "LET a=1/0" raises a div by zero error. Also, "LET a=1%0" panics.


The issue with the "PRINT 1/0" and "PRINT (1/0)" are the same as the previous one.

LET a = 1/0 SHOULD produce a division by error, so I think that's correct. But 1%0 shouldn't panic. I'll fix that.


Thank you! At the airport and no access to my desktop so I could not run the code but I suspected that was going to cause a problem. Deskchecking ftw ;)


In the first case, maybe it's treating the '+' as string concatenation - so 3+4 is giving 34? Then it's just dropping the 5 because it can't multiply a string and a number.

Regardless, I really like this project. :)


Ahh, you're correct.

   go run main.go /dev/tty
   PRINT 1+2*5,"\n"
   ^D
   12




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: