symbol-values.red 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. %
  2. % SYMBOL-VALUES.RED - ValueCell, UnboundP, MakeUnbound and Set
  3. %
  4. % Author: Eric Benson
  5. % Computer Science Dept.
  6. % University of Utah
  7. % Date: 20 August 1981
  8. % Copyright (c) 1981 Eric Benson
  9. %
  10. on SysLisp;
  11. syslsp procedure UnboundP U; %. Does U not have a value?
  12. if IDP U then
  13. if Tag SymVal IDInf U eq Unbound then T else NIL
  14. else
  15. NonIDError(U, 'UnboundP);
  16. syslsp procedure MakeUnbound U; %. Make U an unbound ID
  17. if IDP U then
  18. SymVal IDInf U := MkItem(Unbound, IDInf U)
  19. else
  20. NonIDError(U, 'MakeUnbound);
  21. syslsp procedure ValueCell U; %. Safe access to SymVal entry
  22. begin scalar V; % This guy is called from Eval
  23. return if IDP U then
  24. << V := SymVal IDInf U;
  25. if Tag V eq Unbound then
  26. ContinuableError('99, BldMsg('"%r is an unbound ID", U), U)
  27. else V >>
  28. else
  29. NonIDError(U, 'ValueCell);
  30. end;
  31. % This version of SET differs from the Standard Lisp report in that Exp is
  32. % not declared fluid, in order to maintain compatibility between compiled
  33. % and interpreted code.
  34. syslsp procedure Set(Exp, Val); %. Assign Val to ID Exp
  35. if IDP Exp then
  36. if not (null Exp or Exp eq 'T) then
  37. << SymVal IDInf Exp := Val;
  38. Val >>
  39. else StdError '"T and NIL cannot be SET"
  40. else NonIDError(Exp, 'Set);
  41. off SysLisp;
  42. END;