f-dstruct.red 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. % Fast Defstruct Improvements;
  2. % M.L. Griss
  3. % Load after Defstruct to redefine basic Selectors
  4. FLUID '(DefGetFn!* DefPutFn!* !*DefFnAsExpr);
  5. LoadTime <<
  6. DefGetFn!*:='IGetv;
  7. DefPutFn!*:='IPutv;
  8. !*DefFnAsExpr:=NIL;>>;
  9. % RHS selector (get fn) constructor.
  10. lisp procedure MkSelector( Name, Slotnum );
  11. If !*DefFnAsExpr then
  12. putd( Name, 'expr,
  13. list( 'lambda, '(Struct), List( DefGetFn!*, 'Struct, SlotNum ) ) )
  14. else Putd(name,'macro,
  15. list('lambda,'(struct),
  16. List('LIST,MkQuote DefGetFn!*,'(Cadr Struct),MkQuote SlotNum)));
  17. % LHS depositor (put fn) constructor.
  18. lisp procedure MkDepositor( Name, Slotnum );
  19. begin scalar PutName;
  20. PutName := intern concat( "PUT", id2string Name );
  21. If !*DefFnAsExpr then
  22. putd( PutName, 'expr,
  23. list( 'lambda, '(Struct Val),
  24. List( DefPutFn!*, 'Struct, SlotNum, 'Val ) ) )
  25. else Putd(PutName,'macro,
  26. list('lambda,'(struct),
  27. List('List,MkQuote DefPutFn!*,
  28. '(Cadr Struct),
  29. MkQuote SlotNum,
  30. '(Caddr Struct)
  31. ))
  32. );
  33. put( Name, 'Assign!-Op, PutName );
  34. return PutName
  35. end;
  36. END;