diff --git a/doc/Doc.md b/doc/Doc.md index de64f23..2b0eeb6 100644 --- a/doc/Doc.md +++ b/doc/Doc.md @@ -14,14 +14,14 @@ |`(while cond ...)`|`while` evaluates only its cond argument.|`while` evaluates its condition expression every iteration before running. If it is true, it continues to evaluate every expression in the `while` body. It then returns the last value evaluated.| -## Examples +## Library #### Using the binary -Run wisp in interactive mode: +Run ml in interactive mode: ```bash -$ ./wisp +$ ./ml >>> (print "Hello world!") Hello world! => "Hello world!" @@ -30,13 +30,13 @@ Hello world! Interpret a file: ```bash -$ ./wisp -f "examples/hello_world.lisp" +$ ./ml -f "examples/hello_world.lisp" Hello world! ``` Interpret from command line argument: ```bash -$ ./wisp -c '(print "Hello world!")' +$ ./ml -c '(print "Hello world!")' Hello world! ``` diff --git a/ml.cpp b/ml.cpp index d75c27c..152c5d5 100644 --- a/ml.cpp +++ b/ml.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include @@ -47,7 +46,7 @@ -// Convert an object to a string using a stringstream conveniently +// Convert an object to a string using a string stream conveniently #define to_string(x) static_cast((std::ostringstream() << std::dec << x )).str() // Replace a substring with a replacement string in a source string @@ -1350,8 +1349,8 @@ namespace builtin { eval_args(args, env); if (args.size() != 1) - throw MlError(MlValue(FLOAT_TYPE, cast_to_float), env, - args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS); + throw MlError(MlValue(FLOAT_TYPE, cast_to_float), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS); + return args[0].cast_to_float(); } @@ -1360,7 +1359,8 @@ namespace builtin { eval_args(args, env); if (args.size() != 1) - throw MlError(MlValue(INT_TYPE, cast_to_int), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS); + throw MlError(MlValue(INT_TYPE, cast_to_int), env, args.size() > 1 ? TOO_MANY_ARGS : TOO_FEW_ARGS); + return args[0].cast_to_int(); }