Skip to content

Conversation

@nedanwr
Copy link
Owner

@nedanwr nedanwr commented Jan 28, 2026

Summary

Add support for anonymous function expressions (lambdas) that can be assigned to variables and called dynamically.

Changes

  • Add lambda expression parsing in frontend (parser.c/h) with new AST node types
  • Implement lambda compilation with new opcodes OP_CREATE_FUNCTION and OP_INVOKE_FUNCTION (compiler.c/h)
  • Extend VM to handle lambda function creation and invocation (vm.c/h)
  • Add owned_bytecode field for proper lambda memory management
  • Extend value_new_function to support parameter names (runtime.c/h)
  • Update LSP diagnostics to check lambda bodies for undefined variables
  • Update LSP completion descriptions to include lambda syntax

Testing

  • All existing tests pass
  • New tests added (if applicable)
    • tests/integration/pass/lambda_basic.kr - basic lambda assignment and calls
    • tests/integration/pass/lambda_multiline.kr - multi-line lambdas with block bodies
  • Examples updated (if applicable)
  • Memory leak checks pass (if applicable)

Documentation

  • Examples updated (if applicable)
  • README/docs updated (if applicable)
    • website/content/docs/language/functions.mdx - lambda syntax and use cases
    • website/content/docs/quick-reference.mdx - quick reference entry
    • website/content/docs/roadmap.mdx - marked as completed

Breaking Changes

None

@nedanwr nedanwr self-assigned this Jan 28, 2026
@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
kronos Ready Ready Preview, Comment Jan 28, 2026 8:10am

@coderabbitai
Copy link

coderabbitai bot commented Jan 28, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nedanwr nedanwr merged commit c22c0eb into develop Jan 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants