6.9 RecList Interface

ORIGIN 'list';
BODY 'private/recListBody';
(*
 * COPYRIGHT
 * 
 *       Copyright (C) Mjolner Informatics, 1992-94
 * 
 *       All rights reserved.
 *)
--- lib: attributes ---
recList: list
  (* This recList pattern extends the list pattern to allow for
   * sublists.  Most operations either enters or exits a list
   * position.  List positions in a recList may contain either an
   * element or a sublist.  Defines the following new operations: 
   * 
   *     insertSublistBefore, insertSublistAfter,
   *)
  (# <<SLOT recListLib: attributes>>;
     theCellType::< 
       (* theCellType is the pattern from which the individual
        * recList positions are created.  It also defines the when
        * attribute which is used for accessing either the element or
        * the sublist at this position.  By further binding element,
        * respectively sublist, in when, the actions to be executed in
        * either case, may be specified.
        *)
       (# sublist: ^list; 
          when: 
            (* to differenciate between this(theCellType) holding an
             * element or a sublist
             *)
            (# elm:< (# elm: ^element
                       ...
                     exit elm[]
                     #);
               sublist:< (# lst: ^list
                           ...
                         exit lst[] 
                         #);
               recListCellWhenPrivate: @... 
            do INNER; recListCellWhenPrivate
            #);
          copy::< (# 
                  do (if sublist[] <> NONE then
                         sublist.copy->theCellCopy.sublist[]
                     if)
                  #)
       do INNER
       #);
     insertSublistBefore: 
       (* if position=NONE, insert lst as last element *)
       (# lst: ^list; position, newPosition: ^theCellType;
          illegalSublist:< illegalSublistException
       enter (lst[], position[])
       ...
       exit newPosition[]
       #);
     insertSublistAfter: 
       (* if position=NONE, insert lst as first element *)
       (# lst: ^list; position, newPosition: ^theCellType;
          illegalSublist:< illegalSublistException
       enter (lst[], position[])
       ...
       exit newPosition[]
       #);
     illegalSublistException: Exception
       (# 
       do 'The element of this sublist does not share '->msg.putText;
          'qualifications with the element type of the list'->msg.putLine;
          INNER
       #);
     theScanner::<
       (# ...
       #);
     theReverseScanner::<
       (# ...
       #);
     theFromScanner::<
       (# ...
       #);
     doEnter::<
       (# containerType::<recList;
       ...
       #);
  do INNER
  #)


6.9 RecList Interface
© 1992-2002 Mjølner Informatics
[Modified: Thursday September 9th 1999 at 16:18]