示例#1
0
        public static SExp Setq(SExp[] vals, Environment env)
        {
            Utilities.CheckArguments(vals, args=>args.Length==2, "set!: ");
              if (!(vals[0] is Identifier))
              {
            string msg = "The first argument must be identifier.";
            throw new TypeNotMatchException(msg);
              }

              Identifier name = vals[0] as Identifier;
              SExp val = Utilities.Eval(vals[1], env);
              if (!env.Reassign(name.Value as string, val))
              {
            string msg =
              string.Format("Identifier '{0}' is undefined.", name);
            throw new IdentifierNotDefinedException(msg);
              }
              return name;
        }