anchor.diff: +require mod.fs
   module handler
  +
  +0
  +1+ dup constant matchop
  +1+ dup constant openop
  +1+ dup constant closeop
  +1+ dup constant readop
  +1+ dup constant writeop
  +1+ dup constant seekop
  +constant maxops
   
   variable handlers  handlers off
   
   : handler
  -   create handlers linked 0 , 0 , 0 , 0 , 0 , 0 , ;
  +   create handlers linked 
  +   here maxops cells dup allot erase ;
   
   export handler
  -
  -
  -variable handles  handles off
  -
  -:noname 
  -   16 0 do 
  -     ['] docreate xt, postpone 2@ postpone exit handles linked , 
  -   loop ; execute
  -: newhandle handles begin @ dup cell- @execute or 0= until cell- @ ;
  -
  -
  -1 constant matchop
  -2 constant openop
  -3 constant closeop
  -4 constant readop
  -5 constant writeop
  -6 constant seekop
  -
   
   : op: pad ! : pad @ cells postpone literal postpone + ;
   
  
positive.code: writeop op: writes  ! ;
  seekop  op: seeks   ! ;
  
  export matches opens closes reads writes seeks
  
  matchop op: matcher @ ;
  openop  op: opener  @ ;
  
negative.code: writeop op: writer  @ ;
  seekop  op: seeker  @ ;
  
  export opener closer reader writer seeker matcher
  
  : dispatch @ dup if  execute false else true then ;
  matchop op: match dispatch abort" no matcher" ;
  openop  op: rawopen dispatch if drop 2drop 0 -21 then ;
  closeop op: close dispatch if drop -21 then ;
  readop  op: read  dispatch if drop 2drop 0 -21 then ;
  writeop op: write dispatch if drop 2drop -21 then ;
  seekop  op: seek  dispatch if drop 2drop -21 then ;
  
  : open ( c-addr u fam -- handle handler ior)
     >r handlers begin @ >r r@ match r> swap until
     r> swap >r r@ rawopen  r> swap ;
  
  export rawopen open close read write seek
  
  end-module
  