Merge scheme-forms into macros: named let, letrec, dynamic-wind, eq?/eqv?/equal?
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -134,6 +134,27 @@ def prim_eq(a: Any, b: Any) -> bool:
|
||||
def prim_neq(a: Any, b: Any) -> bool:
|
||||
return a != b
|
||||
|
||||
@register_primitive("eq?")
|
||||
def prim_eq_identity(a: Any, b: Any) -> bool:
|
||||
"""Identity equality — true only if a and b are the same object."""
|
||||
return a is b
|
||||
|
||||
@register_primitive("eqv?")
|
||||
def prim_eqv(a: Any, b: Any) -> bool:
|
||||
"""Equivalent: identity for compound types, value for atoms."""
|
||||
if a is b:
|
||||
return True
|
||||
if isinstance(a, (int, float, str, bool)) and isinstance(b, type(a)):
|
||||
return a == b
|
||||
if (a is None or a is NIL) and (b is None or b is NIL):
|
||||
return True
|
||||
return False
|
||||
|
||||
@register_primitive("equal?")
|
||||
def prim_equal(a: Any, b: Any) -> bool:
|
||||
"""Deep structural equality (same as =)."""
|
||||
return a == b
|
||||
|
||||
@register_primitive("<")
|
||||
def prim_lt(a: Any, b: Any) -> bool:
|
||||
return a < b
|
||||
|
||||
Reference in New Issue
Block a user