[CM] s7_define_constant_with_environment useless?
chohag at jtan.com
chohag at jtan.com
Sat Apr 18 10:27:52 PDT 2026
Specifically the "with_environment" part.
Using s7_define_constant_with_environment() creates a binding only
in the given let but makes the binding immutable everywhere, even
in the root let or an unrelated let. Should it work more like the
define-constant operator and only block changing the binding in the
let it's defined in (and lets hanging off that one)?
Protecting the first 'set_immutable' in _with_environment() with
'if (let == sc->rootlet)' appears to make it work that way although
I'm really only guessing here based on looking at define_constant_op()
and I don't know what the wider impact is. In particular I'm not
sure what 'set_immutable(global_slot(sym))' is doing.
.
Matthew
--- ../s7/s7.c Wed Apr 15 11:51:00 2026
+++ s7.c Sat Apr 18 18:07:21 2026
@@ -12242,7 +12242,8 @@
{
const s7_pointer sym = make_symbol_with_strlen(sc, name);
s7_define(sc, T_Let(let), sym, value);
- set_immutable(sym);
+ if (let == sc->rootlet)
+ set_immutable(sym);
set_possibly_constant(sym);
set_immutable(global_slot(sym)); /* might also be #<undefined> */
set_immutable_slot(local_slot(sym));
More information about the Cmdist
mailing list