monkey-dart icon indicating copy to clipboard operation
monkey-dart copied to clipboard

Problem entering multiline function

Open jkleiser opened this issue 8 years ago • 4 comments

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 avatar Jan 26 '17 10:01 jkleiser

@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! :)

mreichelt avatar Jan 26 '17 10:01 mreichelt

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.

mrnugget avatar Jan 26 '17 10:01 mrnugget

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 avatar Jan 26 '17 11:01 jkleiser

@jkleiser no, but I want to support them - see issue #5 :)

mreichelt avatar Jan 26 '17 11:01 mreichelt