src/vm/oba_compiler.c
static int lambda(Compiler* compiler) {
  Compiler fnCompiler;
  initCompiler(compiler->vm, &fnCompiler, compiler->parser, compiler);

  enterScope(&fnCompiler);
  parameterList(&fnCompiler);
  ignoreNewlines(&fnCompiler);
  consume(&fnCompiler, TOK_ASSIGN, "Missing lambda expression");
  functionExpressionBody(&fnCompiler);

  ObjFunction* fn = endCompiler(&fnCompiler, "", 0);
  if (fn == NULL) return -1;
  obaPushRoot(compiler->vm, (Obj*)fn);

  emitOp(compiler, OP_CLOSURE);
  emitByte(compiler, addConstant(compiler, OBJ_VAL(fn)));

  for (int i = 0; i < fn->upvalueCount; i++) {
    emitByte(compiler, fnCompiler.upvalues[i].isLocal ? 1 : 0);
    emitByte(compiler, fnCompiler.upvalues[i].index);
  }

  obaPopRoot(compiler->vm);

  return fn->arity;
}
// TODO(kendal): Dedup this with function definition.
Dedup this with function definition.
Dedup this with function definition .
static int lambda(Compiler* compiler) {
  Compiler fnCompiler;
  initCompiler(compiler->vm, &fnCompiler, compiler->parser, compiler);
  enterScope(&fnCompiler);
  parameterList(&fnCompiler);
  ignoreNewlines(&fnCompiler);
  consume(&fnCompiler, TOK_ASSIGN, "Missing lambda expression");
  functionExpressionBody(&fnCompiler);
  ObjFunction* fn = endCompiler(&fnCompiler, "", 0);
  if (fn == NULL) return -1;
  obaPushRoot(compiler->vm, (Obj*)fn);
  emitOp(compiler, OP_CLOSURE);
  emitByte(compiler, addConstant(compiler, OBJ_VAL(fn)));
  for (int i = 0; i < fn->upvalueCount; i++) {
    emitByte(compiler, fnCompiler.upvalues[i].isLocal ? 1 : 0);
    emitByte(compiler, fnCompiler.upvalues[i].index);
  }
  obaPopRoot(compiler->vm);
  return fn->arity;
}
static int lambda ( Compiler * compiler ) { Compiler fnCompiler ; initCompiler ( compiler -> vm , & fnCompiler , compiler -> parser , compiler ) ; enterScope ( & fnCompiler ) ; parameterList ( & fnCompiler ) ; ignoreNewlines ( & fnCompiler ) ; consume ( & fnCompiler , TOK_ASSIGN , " " ) ; functionExpressionBody ( & fnCompiler ) ; ObjFunction * fn = endCompiler ( & fnCompiler , " " , 0 ) ; if ( fn == NULL ) return -1 ; obaPushRoot ( compiler -> vm , ( Obj * ) fn ) ; emitOp ( compiler , OP_CLOSURE ) ; emitByte ( compiler , addConstant ( compiler , OBJ_VAL ( fn ) ) ) ; for ( int i = 0 ; i < fn -> upvalueCount ; i ++ ) { emitByte ( compiler , fnCompiler . upvalues [ i ] . isLocal ? 1 : 0 ) ; emitByte ( compiler , fnCompiler . upvalues [ i ] . index ) ; } obaPopRoot ( compiler -> vm ) ; return fn -> arity ; }
TODO(kendal): Dedup this with function definition.
TODO ( kendal ) : Dedup this with function definition .