monkey-dart
monkey-dart copied to clipboard
Problem entering multiline function
I tried to enter the fibonacci function from https://interpreterbook.com, but your REPL didn't give me a prompt after I entered the final };
.
When I instead entered this one-liner, I could use the fib function without problem:
let fib = fn(x) { if (x==0) {0} else { if (x==1) {1} else { fib(x-1) + fib(x-2); }}};
Where is the magic "monkey" executable installed? Doing which monkey
revealed nothing on my Mac.
Thanks for this great fun!
@jkleiser Thanks! I had the same problem. I wrote @mrnugget about this, and he said it's coming in version 1.3. So stay tuned! :)
Small correction: the only thing that's coming in v1.3 is a fix for an endless loop that arises in the Go version, when a non-terminated block statement is entered on the REPL.
Multi-line is much harder to build than one might think and is probably out of the scope of the book. It would be interesting though to see if one could build a Monkey REPL using something like GNU Readline and get better support for the most common editing tasks.
If entering multi-line functions is a problem, how is @mrnugget able to load a function like the fibonacci? I tried monkey fibonacci.monk
, but file arguments don't seem to be an option (in the Dart implementation) at the moment.
@jkleiser no, but I want to support them - see issue #5 :)