Register append! and dict-set! as proper primitives
Previously these mutating operations were internal helpers in the JS bootstrapper but not declared in primitives.sx or registered in the Python evaluator. Now properly specced and available in both hosts. Removes mock injections from cache tests — they use real primitives. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -386,6 +386,11 @@ def prim_cons(x: Any, coll: Any) -> list:
|
||||
def prim_append(coll: Any, x: Any) -> list:
|
||||
return list(coll) + [x] if coll else [x]
|
||||
|
||||
@register_primitive("append!")
|
||||
def prim_append_mut(coll: Any, x: Any) -> list:
|
||||
coll.append(x)
|
||||
return coll
|
||||
|
||||
@register_primitive("chunk-every")
|
||||
def prim_chunk_every(coll: Any, n: Any) -> list:
|
||||
n = int(n)
|
||||
@@ -439,6 +444,13 @@ def prim_dissoc(d: Any, *keys_to_remove: Any) -> dict:
|
||||
result.pop(key, None)
|
||||
return result
|
||||
|
||||
@register_primitive("dict-set!")
|
||||
def prim_dict_set_mut(d: Any, key: Any, val: Any) -> Any:
|
||||
if isinstance(key, Keyword):
|
||||
key = key.name
|
||||
d[key] = val
|
||||
return val
|
||||
|
||||
@register_primitive("into")
|
||||
def prim_into(target: Any, coll: Any) -> Any:
|
||||
if isinstance(target, list):
|
||||
|
||||
Reference in New Issue
Block a user