Examples of FnObj


Examples of com.stuffwithstuff.magpie.interpreter.FnObj

 
  @Def("(is Function) call(arg)")
  @Doc("Invokes the given function.")
  public static class Call implements Intrinsic {
    public Obj invoke(Context context, Obj left, Obj right) {
      FnObj function = left.asFn();
      Obj fnArg = right;
     
      // Make sure the argument matches the function's pattern.
      Callable callable = function.getCallable();
      if (!PatternTester.test(context, callable.getPattern(), fnArg,
          callable.getClosure())) {
        throw context.error(Name.NO_METHOD_ERROR, "The argument \"" +
            context.getInterpreter().evaluateToString(fnArg) + "\" does not match the " +
            "function's pattern " + callable.getPattern());
      }

      return function.invoke(context, fnArg);
    }
View Full Code Here

Examples of com.stuffwithstuff.magpie.interpreter.FnObj

  @Def("run(body is Function)")
  @Doc("Creates a new thread and runs the function concurrently on it.")
  public static class Run implements Intrinsic {
    public Obj invoke(Context context, Obj left, Obj right) {
      FnObj function = right.asFn();
     
      Routine routine = new Routine(context, function);
      routine.start();
     
      return context.nothing();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.