Skip to content

Implement define-macro special form#8

Open
mark-friedman wants to merge 1 commit intomainfrom
feature/define-macro-433352381041054241
Open

Implement define-macro special form#8
mark-friedman wants to merge 1 commit intomainfrom
feature/define-macro-433352381041054241

Conversation

@mark-friedman
Copy link
Owner

Implemented the define-macro special form, providing Common Lisp-style unhygienic macros.

Changes:

  1. Core Implementation:

    • Added analyzeDefineMacro to src/core/interpreter/analyzers/core_forms.js.
    • This function evaluates the transformer body in a fresh, isolated interpreter instance during analysis.
    • It registers a wrapper function in the macro registry that invokes the transformer closure with the macro arguments.
    • Added define-macro to SYNTAX_KEYWORDS and SPECIAL_FORMS in src/core/interpreter/library_registry.js.
  2. Library Support:

    • Created src/core/scheme/define-macro.sld, exporting define-macro.
    • Updated repl.js and web/main.js to automatically import (scheme define-macro) into the initial environment.
    • Updated tests/run_scheme_tests_lib.js to load and import (scheme define-macro) for test files.
  3. Testing:

    • Added tests/functional/test_defmacro.scm covering basic usage, return values, and explicit transformer syntax.
    • Added this test to tests/test_manifest.js.

Test Results:

  • Node.js Test Suite: 2021 passed, 0 failed, 7 skipped.
  • Verified manual REPL usage.

PR created automatically by Jules for task 433352381041054241 started by @mark-friedman

Implemented the `define-macro` special form, providing Common Lisp-style unhygienic macros.
- Added `analyzeDefineMacro` to `src/core/interpreter/analyzers/core_forms.js`.
- Created `src/core/scheme/define-macro.sld`.
- Updated `repl.js` and `web/main.js` to import `(scheme define-macro)` by default.
- Added support for both `(define-macro (name . args) body)` and `(define-macro name transformer)` syntax.
- Updated `CHANGES.md`.

Co-authored-by: mark-friedman <1743690+mark-friedman@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant