Skip to content

Commit

Permalink
added test showing more that forms introduced by macros do not inadve…
Browse files Browse the repository at this point in the history
…rtedly capture lexical variables at use site
  • Loading branch information
azizghuloum committed Nov 25, 2024
1 parent d41cbd8 commit f602061
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions examples/macro-generating-macro-2.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## `macro-generating-macro-2.ts`

### Status: `DONE`

### Input Program

```typescript
using_syntax_rules(
[capture,
capture(expr, id, body),
using_syntax_rules([id, id, expr]).rewrite(body)],
).rewrite((x) => {
const using_syntax_rules = 10;
// capture introduces a using_syntax_rules form but that is
// referentially transparent .. i.e., it doesn't care about
// what's defined in its use site. Capture always works, no
// matter where you put it.
capture(x, t, (x) => x + t);
})
```

### Output Program

```typescript
(x_5) => {
const using_syntax_rules_8 = 10;
(x_13) => x_13 + x_5;
};
```

12 changes: 12 additions & 0 deletions tests/macro-generating-macro-2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using_syntax_rules(
[capture,
capture(expr, id, body),
using_syntax_rules([id, id, expr]).rewrite(body)],
).rewrite((x) => {
const using_syntax_rules = 10;
// capture introduces a using_syntax_rules form but that is
// referentially transparent .. i.e., it doesn't care about
// what's defined in its use site. Capture always works, no
// matter where you put it.
capture(x, t, (x) => x + t);
})

0 comments on commit f602061

Please sign in to comment.