Re:Show HN: A Lisp interpreter in C# 7
by hestefisk on Sunday July 01, 2018 @04:36PM
(#17437412)
Neat work! Also good demonstration of new C# 7.0 features.
[ Parent
| on HN ]
Thank you.
I appreciated especially the pattern matching feature of C# 7 while programming the interpreter.
For example:
/// <summary>Evaluate a Lisp expression in an environment.</summary>
public object Eval(object x, Cell env) {
try {
for (;;) {
switch (x) {
case Arg xarg:
return xarg.GetValue(env);
case Sym xsym:
try {
return Globals[xsym];
} catch (KeyNotFoundException) {
throw new EvalException("void variable", x);
}
case Cell xcell: