rlisp88.red 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. module rlisp88; % Support for the RLISP '88 superset.
  2. % Author: Anthony C. Hearn.
  3. fluid '(!*minusliter !*mode !*oldminusliter !*rlisp88 forbinops!*
  4. oldmode!*);
  5. switch rlisp88;
  6. create!-package('(rlisp88 for88 loops88 bquote comment rvector mstruct
  7. records inspect),
  8. '(rlisp));
  9. symbolic procedure rlisp88_on;
  10. begin
  11. if !*rlisp88 then return nil;
  12. !*rlisp88 := t;
  13. !*oldminusliter := !*minusliter;
  14. !*minusliter := t;
  15. deflist('((module formmodule) (global formglobalfluid)
  16. (fluid formglobalfluid) (procedure nformproc)),
  17. 'formfn);
  18. remprop('join,'newnam);
  19. put('conc,'newnam,'join);
  20. put('oldwhen,'infix,get('when,'infix));
  21. remprop('when,'infix);
  22. flag('(for),'nochange); % Check on this.
  23. deflist(forbinops!*,'bin);
  24. deflist('((for forstat88) (repeat repeatstat88)
  25. (while whilstat88)),'stat);
  26. deflist('((for formfor88) (repeat formrepeat88)
  27. (while formwhile88)),'formfn);
  28. copyd('for,'for88);
  29. copyd('oldrepeat!*,'repeat);
  30. remd 'repeat;
  31. copyd('repeat,'repeat88);
  32. copyd('oldwhile!*,'while);
  33. remd 'while; % To avoid messages.
  34. copyd('while,'while88);
  35. if not(!*mode eq 'symbolic)
  36. then <<oldmode!* := !*mode; !*mode := 'symbolic>>;
  37. % The following statements, and their colloraries in rlisp88_off,
  38. % reveal problems with the current REDUCE model; it cannot specify
  39. % attributes in algebraic mode that do not apply in symbolic mode.
  40. % The following are representative, and by no means exhaustive.
  41. remprop('array,'stat);
  42. remprop('index,'stat);
  43. remprop('def,'stat);
  44. remprop('array,'formfn);
  45. remprop('add,'number!-of!-args);
  46. remprop('add,'smacro)
  47. end;
  48. symbolic procedure rlisp88_off;
  49. begin
  50. if null !*rlisp88 then return nil
  51. else if null getd 'oldrepeat!*
  52. then rederr "Rlisp88 mode not set";
  53. !*minusliter := !*oldminusliter;
  54. remprop('module,'formfn);
  55. remprop('global,'formfn);
  56. remprop('fluid,'formfn);
  57. put('procedure,'formfn,'formproc);
  58. remprop('conc,'newnam);
  59. put('join,'newnam,'conc);
  60. put('when,'infix,get('oldwhen,'infix));
  61. remflag('(for),'nochange);
  62. for each x in '(append collect count join maximize minimize)
  63. do remprop(x,'bin);
  64. deflist('((product times2) (sum plus2)),'bin);
  65. deflist('((for forstat) (repeat repeatstat) (while whilstat)),
  66. 'stat);
  67. deflist('((for formfor) (repeat formrepeat) (while formwhile)),
  68. 'formfn);
  69. remd 'for;
  70. remd 'repeat;
  71. remd 'while;
  72. copyd('repeat,'oldrepeat!*);
  73. copyd('while,'oldwhile!*);
  74. remd 'oldrepeat!*;
  75. remd 'oldwhile!*;
  76. if oldmode!* then <<!*mode := oldmode!*; oldmode!* := nil>>;
  77. deflist('((array rlis) (def rlis) (index rlis)),'stat);
  78. put('array,'formfn,'formarray);
  79. put('add,'number!-of!-args,2);
  80. put('add,'smacro,'(lambda (u v) (cons u v)))
  81. end;
  82. put('rlisp88,'simpfg,'((t (rlisp88_on)) (nil (rlisp88_off))));
  83. endmodule;
  84. end;