本文整理汇总了C#中Environment.Define方法的典型用法代码示例。如果您正苦于以下问题:C# Environment.Define方法的具体用法?C# Environment.Define怎么用?C# Environment.Define使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Environment
的用法示例。
在下文中一共展示了Environment.Define方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Call
/// <summary>
/// Call a define evaluator.
/// Handle the two forms of define.
/// In the first case, just save the lambda and return.
/// This is what would result if we prepend "lambda" and call EvaluateExpression.
/// In the second case, we need create an evaluator to evaluate the expression.
/// </summary>
/// <param name="expr">The expression to evaluate.</param>
/// <param name="env">The environment to make the expression in.</param>
/// <param name="caller">The caller. Return to this when done.</param>
/// <returns>The define evaluator.</returns>
internal static Evaluator Call(SchemeObject expr, Environment env, Evaluator caller)
{
if (First(expr) is Pair)
{
// Defun case -- create a lambda and bind it to the variable.
var symbol = First(First(expr));
if (!(symbol is Symbol))
{
ErrorHandlers.SemanticError(string.Format(@"Attempt to define a non-symbol: ""{0}""", symbol.ToString(true)), null);
}
env.Define((Symbol)symbol, Lambda.New(Rest(First(expr)), Rest(expr), env));
caller.ReturnedExpr = Undefined.Instance;
return caller;
}
return new EvaluateDefine(expr, env, caller);
}