-
Notifications
You must be signed in to change notification settings - Fork 89
Nemerlish
Nemerlish a.k.a. nemish.exe is an interactive Nemerle interpreter. It uses the regular compiler to evaluate subsequent input and provides various features to ease its interactive use.
Nemerlish doesn't have any specific software requirements to run, but it will make use of the readline library if it's present in the system, providing support for persistent history and allowing the use of arrow keys, backspace, delete (and tab-completion in the, hopefuly near, future).
Nemish is developed on the Mono platform on Linux, but should work on MS.NET/Windows without problems.
Nemerlish sources are located in nemerle/tools/nemerlish directory in the ncc source distribution and here in the SVN repository. To compile nemish, type:
- make
- make install
- nemish.exe [-f]
When you run nemish, it will first look for $HOME/.nemerlish_profile. If the file does not exist it will be created and appended with this default contents:
/* Open the namespace holding nemerlish-related properties. */
using Nemerle.Evaluation.Interpreter.Internals;
If you used the -f commandline option, all the files enumerated after it, will be evaluated as well.
Next, if readline is supported on your system, nemish will look for $HOME/.nemerlish_history and restore history from previous sessions. In case the file does not exist and readline is supported, it will be created and used from now on.
At this point you will be presented with a prompt.
Each expression you enter, should be appended with ";;". This allows nemish to distinguish, whether you wish to enter another line of code, or to commit what you've written so far.
The first thing for new users to type in is "Help;;". It will give a brief description of available properties such as PS1 (the primary prompt, default "- "), PS2 (the secondary prompt, default "= "), Ref (the assemblies to link, default "") or Help itself. Besides these, you can use "!;;", to run the default system shell, or "!command;;", to run any external command.
After each commited computation newly declared variables' names, types and values (if any) will be printed. The return value of the whole expression will be assigned to a special variable "it" (as in SML of NJ). All the variables and functions will remain available during further computations.
To quit, use ^c (ctrl-c).
Nemish sources are compiled into two assemblies - Nemerle.Evaluation.dll (eval.n) and nemish.exe (main.n, interp.n, readline.n).
Once all the above, described in the "Running" section takes place, nemish starts taking input. When it's commited with ";;\n", it's parsed for certain special cases (there are currently two - "using" statements and "!" statements). After that, the code is passed to the Evaluator, which prepends it with declarations of all the memoized variables/functions from previous iterations, wraps it all up in a class and compiles in memory using ncc. All the variables are once again collected for future use.
The evaluated code is compiled with both Nemerle.Evaluation.dll and nemish.exe linked. The former, so that the memoized variables, stored by the evaluator, can be looked up; the latter so that the properties from interp.n (PS1, PS2, Help, Ref, etc.) can be made use of.
- Classes cannot be declared by entering in the interpreter
- Some internal newline issues (breaks usage of //-style comments among other things)
- Code clean-ups (there's some ugly stuff, that could be made a little prettier)
- Make use of the lexer/preparser to handle using statements and comments (this should also fix the newline problems AFAIR)
- Drop wrapping code in a class, now top-level statements are allowed and that's just perfect for nemish (this will resolve the problem with class declarations)
- Drop compiling things multiple times, a separate assembly should be compiled in each iteration and linked in the next ones. This will prevent unnecessary recomputations.
- Lots of features such as tab-completion, a help for each documented method, a vim plugin for code evaluation using nemish and others.
- Also nemish's code is currently imperative - this will change in the future
Nemerlish is developed by Wojtek Knapik, with the invaluable help of Kamil Skalski, both present on Nemerle mailing lists and irc channel.