Skip to content

Commit 05b39a7

Browse files
leifericfclaude
andcommitted
embed: route host-syntax sugar through the tree-walker in BC compile
(.method target ...), (.-field target), and TypeName/staticMethod rewrites live in eval_try_host_syntax, which only runs when the tree-walker dispatches a cons form. Names starting with a dot or formatted like Capital/method now delegate from the BC compiler to the tree-walker so a BC-compiled fn body can use host interop. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 336bf34 commit 05b39a7

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/eval/bc/compile.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,23 @@ static int is_special_form_name(const char *name)
496496
if (strcmp(name, "cond") == 0) return 1;
497497
if (strcmp(name, "new") == 0) return 1;
498498
if (strcmp(name, ".") == 0) return 1;
499+
/* Host-syntax sugar: (.method target ...), (.-field target),
500+
* TypeName/staticMethod. These rewrite to host/... primitive calls
501+
* in eval_try_host_syntax, which only runs on the tree-walker
502+
* path. Send them there so a BC-compiled fn body can use them. */
503+
if (name[0] == '.' && name[1] != '\0') return 1;
504+
{
505+
const char *slash = strchr(name, '/');
506+
if (slash != NULL && slash != name && slash[1] != '\0') {
507+
/* Reject the bare division op `/` (one-char name) and
508+
* already-namespaced symbols like clojure.core/+ where the
509+
* head is a valid env binding; here we only steer host
510+
* static-method calls to the tree-walker. Heuristic:
511+
* Capital-letter type names. */
512+
const unsigned char c0 = (unsigned char)name[0];
513+
if (c0 >= 'A' && c0 <= 'Z') return 1;
514+
}
515+
}
499516
return 0;
500517
}
501518

0 commit comments

Comments
 (0)