Beispiel #1
0
        private static ILispValue EvaluateSet(IList <ILispValue> args, ILispEnvironment environment)
        {
            if (args.Count < 2)
            {
                throw new SignatureMismatchException("too few arguments supplied");
            }
            if (args.Count > 2)
            {
                throw new SignatureMismatchException("too many arguments supplied");
            }
            // this is a special form since we do not evaluate the first argument, which must be a symbol
            if (args[0].Type != LispValueType.Symbol)
            {
                throw new TypeMismatchException(new Symbol("variable"), LispValueType.Symbol, args[0].Type);
            }
            ILispValue value = Evaluate(args[1], environment);

            environment.Set((Symbol)args[0], value);
            return(value);
        }