Artifact fdcfbef5c1c85b5f6be80e92deec85d1540b2bef9d962e8d11a5a3a7e5e52f7f:
- File
psl-1983/3-1/util/defstruct.examples-red
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1880) [annotate] [blame] [check-ins using] [more...]
- File
psl-1983/util/defstruct.examples-red
— part of check-in
[eb17ceb7f6]
at
2020-04-21 19:40:01
on branch master
— Add Reduce 3.0 to the historical section of the archive, and some more
files relating to version sof PSL from the early 1980s. Thanks are due to
Paul McJones and Nelson Beebe for these, as well as to all the original
authors.git-svn-id: https://svn.code.sf.net/p/reduce-algebra/code/historical@5328 2bfe0521-f11c-4a00-b80e-6202646ff360 (user: arthurcnorman@users.sourceforge.net, size: 1880) [annotate] [blame] [check-ins using]
% (Do definitions twice to see what functions were defined.) macro procedure TWICE u; list( 'PROGN, second u, second u ); % A definition of Complex, structure with Real and Imaginary parts. % Give 0 Init values. TWICE Defstruct( Complex( !:Creator(Complex) ), R(0), I(0) ); C0 := MakeComplex(); % Constructor with default inits. ComplexP C0; % Predicate. C1:=MakeComplex( R 1, I 2 ); % Constructor with named values. R(C1); I(C1); % Named selectors. C2:=Complex(3,4); % Creator with positional values. AlterComplex( C1, R(2), I(3) ); % Alterant with named values. C1; R(C1):=5; I(C1):=6; % Named depositors. C1; % Show use of Include Option. (Again, redef to show fns defined.) TWICE Defstruct( MoreComplex( !:Include(Complex) ), Z(99) ); M0 := MakeMoreComplex(); M1 := MakeMoreComplex( R 1, I 2, Z 3 ); R C1; R M1; % A more complicated example: The structures which are used in the % Defstruct facility to represent defstructs. (The EX prefix has % been added to the names to protect the innocent...) TWICE % Redef to show fns generated. Defstruct( EXDefstructDescriptor( !:Prefix(EXDsDesc), !:Creator ), DsSize( !:Type int ), % (Upper Bound of vector.) Prefix( !:Type string ), SlotAlist( !:Type alist ), % (Cdrs are SlotDescriptors.) ConsName( !:Type fnId ), AltrName( !:Type fnId ), PredName( !:Type fnId ), CreateName( !:Type fnId ), Include( !:Type typeid ), InclInit( !:Type alist ) ); TWICE % Redef to show fns generated. Defstruct( EXSlotDescriptor( !:Prefix(EXSlotDesc), !:Creator ), SlotNum( !:Type int ), InitForm( !:Type form ), SlotFn( !:Type fnId ), % Selector/Depositor id. SlotType( !:Type type ), % Hm... UserGet( !:Type boolean ), UserPut( !:Type boolean ) ); END;