SamiKalliomaki / eppabasic

A new web based basic language inspired by CoolBasic.
Other
11 stars 3 forks source link

For loops accept non-integer values #54

Open expositionrabbit opened 9 years ago

expositionrabbit commented 9 years ago

For example, this works...

For i = "a" To "z"
  Print i
Next i

... but only prints "a", indicating that if this feature was intended, it at least doesn't work. It could be a nice feature, though.

fergusq commented 9 years ago

Funny, this does not work:

For i = False To True
  Print i
Next i

Because, Toistorakenteen askeleen ja iteraattorin tyyppien on oltava samat. Why are False and True called a step and an iterator? They whould be called an initial value and a final value.

As True and False are both booleans, the error message appears to be completely misleading.

Also, Print(Boolean) isn't declared.

henkkuli commented 9 years ago

This is not intended feature and is a bug. Thank you for reporting.

fergusq: The error message is all right though not the most iformative one. The message comes from the fact that step defaults to 1 which is not castable to boolean. In the original code number is castable to string so no error is raised.

As soon as we can get our new compiler working this bug should also be fixed.

Henrik

Ps. Boolean to String casting is implemented in dev version and is waiting to be pulled to master.