As a lot of people pointed out in this question, Lisp is mostly used as a learning experience. Nevertheless, it would be great if I could somehow use my Lisp algorithms and combine them with my C# programs. In college my profs never could tell me how to use my Lisp routines in a program (no, not writing a GUI in Lisp, thank you). So how can I?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
Clojure is a Lisp-1 that is compiled on-the-fly to Java bytecode, leading to very good runtime performance. You can use Clojure, and cross-compile it to a .NET assembly using IKVM's ikvmc. Of course, when used in .NET, Clojure happily generates .NET IL, leading to the same kind of compiled-code performance you can expect when using it on a JVM.
If it's merely the routines you want to use you might try LSharp, which lets you have Lisp expressions in .NET:
http://www.lsharp.org/
The other way around (using .NET from Lisp) would be RDNZL:
http://www.weitz.de/rdnzl/
The .Net 1.1 SDK contains a LISP compiler example. See SDK\v1.1\Tool Developers Guide\Samples\clisp
I know this is a really old question. But I'll try to provide an answer from my own experience and perspective.
To those like us who love the pureness and elegance and simplicity of Scheme/Lisp, I hope this gives you some encouragement and inspiration how they can be very useful in real production :)
I recently open-sourced a Scheme-like interpreter from work called schemy, written in C# (~1500 line of code). And here's the motivation and how it is useful -
Without going into too much detail, I was building a web API server, whose request handling logic is desired to be plug-and-play by other developers/data scientists. There was a clear demand for separation of concern here - the server does not care much about the request handling logic, but it needs to know which requests it can handle and where to find and load the logic for the handlers.
So instead of putting handlers implementation in the server application, the server only provides re-usable "blocks" that can be chained together based on some criteria and logic to form a pipeline, i.e., handlers defined via configuration. We tried JSON/XML to describe such a pipeline and quickly realized that I was essentially building an abstract syntax tree parser.
This was when I realized this was a demand for a lightweight, s-expression based small language. Hence I implemented the embeddable schemy interpreter.
I put an example command handling application here, which captures the essence of the design philosophy for the web server I mentioned above. It works like so:
It extends an embedded Schemy interpreter with some functions implemented in C#.
It finds
.ss
scripts which defines a command processing pipeline by using those implemented functions.The server finds and persists the composes pipeline from a script by looking for the symbol
EXECUTE
which should be of typeFunc<object, object>
.When a command request comes in, it simply invokes the corresponding command processor (the one defined by
EXECUTE
), and responses with the result.Finally, here's a complex example script, that provides an online man-page lookup via this TCP command server:
With this script loaded by the command server, a TCP client can issue commands
man <unix_command>
to the server:Try these .Net implementations of Lisp:
There is also DotLisp.