Stable extension point for definition-form? — no monkey-patching

Replace the fragile pattern of capturing and wrapping definition-form?
with a mutable *definition-form-extensions* list in render.sx. Web
modules append names to this list instead of redefining the function.
Survives spec reloads without losing registrations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 10:06:05 +00:00
parent 8a08de26cd
commit 2a9a4b41bd
3 changed files with 20 additions and 16 deletions

View File

@@ -14,7 +14,7 @@
// =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
var SX_VERSION = "2026-03-24T09:53:22Z";
var SX_VERSION = "2026-03-24T10:04:16Z";
function isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); }
@@ -2236,8 +2236,12 @@ PRIMITIVES["VOID_ELEMENTS"] = VOID_ELEMENTS;
var BOOLEAN_ATTRS = ["async", "autofocus", "autoplay", "checked", "controls", "default", "defer", "disabled", "formnovalidate", "hidden", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "selected"];
PRIMITIVES["BOOLEAN_ATTRS"] = BOOLEAN_ATTRS;
// *definition-form-extensions*
var _definitionFormExtensions_ = [];
PRIMITIVES["*definition-form-extensions*"] = _definitionFormExtensions_;
// definition-form?
var isDefinitionForm = function(name) { return sxOr((name == "define"), (name == "defcomp"), (name == "defisland"), (name == "defmacro"), (name == "defstyle"), (name == "deftype"), (name == "defeffect")); };
var isDefinitionForm = function(name) { return sxOr((name == "define"), (name == "defcomp"), (name == "defisland"), (name == "defmacro"), (name == "defstyle"), (name == "deftype"), (name == "defeffect"), contains(_definitionFormExtensions_, name)); };
PRIMITIVES["definition-form?"] = isDefinitionForm;
// parse-element-args