Regression
They say that as you get older you regress back towards childhood. So I present you with today's Haskell program (the idea shamelessly stolen from JoshTriplett from #haskell on IRC):import BASIC main = runBASIC $ do 10 LET X =: 1 20 PRINT "Hello BASIC world!" 30 LET X =: X + 1 40 IF X <> 11 THEN 20 50 ENDYes, it runs. (I'm sorry about the =: instead of =, but some things are just too wired into Haskell to change.)
13 Comments:
And where can we find BASIC module?
Ooo, I like this.
Nice. I guess this is based on PrintfType-like type class trickery and doesn't reject invalid basic programs until runtime, right?
It can go wrong in many ways at runtime, just like real BASIC. :)
Does it run if we reorder the statements? Or are the line numbers just for show? In other words, does this work?
50 END
20 PRINT "Hello BASIC world!"
30 LET X =: X + 1
40 IF X <> 11 THEN 20
10 LET X =: 1
You can reorder the statements if you like.
I take it there is a limit on the available variable names? Not that this is ahistorical: Commodore BASIC ignored all but the first two letters, for example; but allowing arbitrary names would be a challenge.
Quiz: Dartmouth BASIC has a limit of 286 variables.
Lennart - this made my day. I can smell the food in my mother's kitchen.
Hey, this was my idea! And Josh also has a working implementation!
It's cool that you went ahead and did an implementation as well, and cool that you gave Josh credit. However, it would also have been nice to give us a little time to get ours out first. We had big 1 April plans for it.
I hereby sentence you to write a few thousand lines of HBASIC. :-)
PO8: I'm sorry, I didn't know it was your idea. Nor that you had plans.
My apologies.
It's all good fun. I mostly just wanted to clarify the situation. Josh and I will keep poking at it also---we're already making our next plans.
It looks like you have the HBASIC language pretty clean at this point with your implementation. Will you post the source code soon?
Nice. I guess this is based on PrintfType-like type class trickery and doesn't reject invalid basic programs until runtime, right?cheap electronics
Post a Comment
<< Home