Hex Artifact Content
Not logged in

Artifact d554c8a49ddb82b9cc23bcfc0d9c7f804ef4dab4:


0000: 3b 3b 20 43 6f 70 79 72 69 67 68 74 20 28 43 29  ;; Copyright (C)
0010: 20 57 69 6c 6c 69 61 6d 20 44 20 43 6c 69 6e 67   William D Cling
0020: 65 72 20 32 30 30 38 2e 20 41 6c 6c 20 52 69 67  er 2008. All Rig
0030: 68 74 73 20 52 65 73 65 72 76 65 64 2e 0a 3b 3b  hts Reserved..;;
0040: 0a 3b 3b 20 50 65 72 6d 69 73 73 69 6f 6e 20 69  .;; Permission i
0050: 73 20 68 65 72 65 62 79 20 67 72 61 6e 74 65 64  s hereby granted
0060: 2c 20 66 72 65 65 20 6f 66 20 63 68 61 72 67 65  , free of charge
0070: 2c 20 74 6f 20 61 6e 79 20 70 65 72 73 6f 6e 20  , to any person 
0080: 6f 62 74 61 69 6e 69 6e 67 20 61 20 63 6f 70 79  obtaining a copy
0090: 0a 3b 3b 20 6f 66 20 74 68 69 73 20 73 6f 66 74  .;; of this soft
00a0: 77 61 72 65 20 61 6e 64 20 61 73 73 6f 63 69 61  ware and associa
00b0: 74 65 64 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f  ted documentatio
00c0: 6e 20 66 69 6c 65 73 20 28 74 68 65 20 22 53 6f  n files (the "So
00d0: 66 74 77 61 72 65 22 29 2c 20 74 6f 20 64 65 61  ftware"), to dea
00e0: 6c 0a 3b 3b 20 69 6e 20 74 68 65 20 53 6f 66 74  l.;; in the Soft
00f0: 77 61 72 65 20 77 69 74 68 6f 75 74 20 72 65 73  ware without res
0100: 74 72 69 63 74 69 6f 6e 2c 20 69 6e 63 6c 75 64  triction, includ
0110: 69 6e 67 20 77 69 74 68 6f 75 74 20 6c 69 6d 69  ing without limi
0120: 74 61 74 69 6f 6e 20 74 68 65 20 72 69 67 68 74  tation the right
0130: 73 0a 3b 3b 20 74 6f 20 75 73 65 2c 20 63 6f 70  s.;; to use, cop
0140: 79 2c 20 6d 6f 64 69 66 79 2c 20 6d 65 72 67 65  y, modify, merge
0150: 2c 20 70 75 62 6c 69 73 68 2c 20 64 69 73 74 72  , publish, distr
0160: 69 62 75 74 65 2c 20 73 75 62 6c 69 63 65 6e 73  ibute, sublicens
0170: 65 2c 20 61 6e 64 2f 6f 72 20 73 65 6c 6c 0a 3b  e, and/or sell.;
0180: 3b 20 63 6f 70 69 65 73 20 6f 66 20 74 68 65 20  ; copies of the 
0190: 53 6f 66 74 77 61 72 65 2c 20 61 6e 64 20 74 6f  Software, and to
01a0: 20 70 65 72 6d 69 74 20 70 65 72 73 6f 6e 73 20   permit persons 
01b0: 74 6f 20 77 68 6f 6d 20 74 68 65 20 53 6f 66 74  to whom the Soft
01c0: 77 61 72 65 20 69 73 0a 3b 3b 20 66 75 72 6e 69  ware is.;; furni
01d0: 73 68 65 64 20 74 6f 20 64 6f 20 73 6f 2c 20 73  shed to do so, s
01e0: 75 62 6a 65 63 74 20 74 6f 20 74 68 65 20 66 6f  ubject to the fo
01f0: 6c 6c 6f 77 69 6e 67 20 63 6f 6e 64 69 74 69 6f  llowing conditio
0200: 6e 73 3a 0a 3b 3b 0a 3b 3b 20 54 68 65 20 61 62  ns:.;;.;; The ab
0210: 6f 76 65 20 63 6f 70 79 72 69 67 68 74 20 6e 6f  ove copyright no
0220: 74 69 63 65 20 61 6e 64 20 74 68 69 73 20 70 65  tice and this pe
0230: 72 6d 69 73 73 69 6f 6e 20 6e 6f 74 69 63 65 20  rmission notice 
0240: 73 68 61 6c 6c 20 62 65 20 69 6e 63 6c 75 64 65  shall be include
0250: 64 20 69 6e 0a 3b 3b 20 61 6c 6c 20 63 6f 70 69  d in.;; all copi
0260: 65 73 20 6f 72 20 73 75 62 73 74 61 6e 74 69 61  es or substantia
0270: 6c 20 70 6f 72 74 69 6f 6e 73 20 6f 66 20 74 68  l portions of th
0280: 65 20 53 6f 66 74 77 61 72 65 2e 0a 3b 3b 0a 3b  e Software..;;.;
0290: 3b 20 54 48 45 20 53 4f 46 54 57 41 52 45 20 49  ; THE SOFTWARE I
02a0: 53 20 50 52 4f 56 49 44 45 44 20 22 41 53 20 49  S PROVIDED "AS I
02b0: 53 22 2c 20 57 49 54 48 4f 55 54 20 57 41 52 52  S", WITHOUT WARR
02c0: 41 4e 54 59 20 4f 46 20 41 4e 59 20 4b 49 4e 44  ANTY OF ANY KIND
02d0: 2c 20 45 58 50 52 45 53 53 20 4f 52 0a 3b 3b 20  , EXPRESS OR.;; 
02e0: 49 4d 50 4c 49 45 44 2c 20 49 4e 43 4c 55 44 49  IMPLIED, INCLUDI
02f0: 4e 47 20 42 55 54 20 4e 4f 54 20 4c 49 4d 49 54  NG BUT NOT LIMIT
0300: 45 44 20 54 4f 20 54 48 45 20 57 41 52 52 41 4e  ED TO THE WARRAN
0310: 54 49 45 53 20 4f 46 20 4d 45 52 43 48 41 4e 54  TIES OF MERCHANT
0320: 41 42 49 4c 49 54 59 2c 0a 3b 3b 20 46 49 54 4e  ABILITY,.;; FITN
0330: 45 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43  ESS FOR A PARTIC
0340: 55 4c 41 52 20 50 55 52 50 4f 53 45 20 41 4e 44  ULAR PURPOSE AND
0350: 20 4e 4f 4e 49 4e 46 52 49 4e 47 45 4d 45 4e 54   NONINFRINGEMENT
0360: 2e 20 52 45 4d 45 4d 42 45 52 2c 20 54 48 45 52  . REMEMBER, THER
0370: 45 20 49 53 20 4e 4f 0a 3b 3b 20 53 43 48 45 4d  E IS NO.;; SCHEM
0380: 45 20 55 4e 44 45 52 47 52 4f 55 4e 44 2e 20 49  E UNDERGROUND. I
0390: 4e 20 4e 4f 20 45 56 45 4e 54 20 53 48 41 4c 4c  N NO EVENT SHALL
03a0: 20 54 48 45 20 41 55 54 48 4f 52 53 20 4f 52 20   THE AUTHORS OR 
03b0: 43 4f 50 59 52 49 47 48 54 20 48 4f 4c 44 45 52  COPYRIGHT HOLDER
03c0: 53 20 42 45 0a 3b 3b 20 4c 49 41 42 4c 45 20 46  S BE.;; LIABLE F
03d0: 4f 52 20 41 4e 59 20 43 4c 41 49 4d 2c 20 44 41  OR ANY CLAIM, DA
03e0: 4d 41 47 45 53 20 4f 52 20 4f 54 48 45 52 20 4c  MAGES OR OTHER L
03f0: 49 41 42 49 4c 49 54 59 2c 20 57 48 45 54 48 45  IABILITY, WHETHE
0400: 52 20 49 4e 20 41 4e 20 41 43 54 49 4f 4e 20 4f  R IN AN ACTION O
0410: 46 0a 3b 3b 20 43 4f 4e 54 52 41 43 54 2c 20 54  F.;; CONTRACT, T
0420: 4f 52 54 20 4f 52 20 4f 54 48 45 52 57 49 53 45  ORT OR OTHERWISE
0430: 2c 20 41 52 49 53 49 4e 47 20 46 52 4f 4d 2c 20  , ARISING FROM, 
0440: 4f 55 54 20 4f 46 20 4f 52 20 49 4e 20 43 4f 4e  OUT OF OR IN CON
0450: 4e 45 43 54 49 4f 4e 20 57 49 54 48 20 54 48 45  NECTION WITH THE
0460: 0a 3b 3b 20 53 4f 46 54 57 41 52 45 20 4f 52 20  .;; SOFTWARE OR 
0470: 54 48 45 20 55 53 45 20 4f 52 20 4f 54 48 45 52  THE USE OR OTHER
0480: 20 44 45 41 4c 49 4e 47 53 20 49 4e 20 54 48 45   DEALINGS IN THE
0490: 20 53 4f 46 54 57 41 52 45 2e 0a 0a 23 21 72 36   SOFTWARE...#!r6
04a0: 72 73 0a 28 6c 69 62 72 61 72 79 20 28 73 72 66  rs.(library (srf
04b0: 69 20 73 39 39 20 72 65 63 6f 72 64 73 20 69 6e  i s99 records in
04c0: 73 70 65 63 74 69 6f 6e 29 0a 0a 20 20 28 65 78  spection)..  (ex
04d0: 70 6f 72 74 20 72 65 63 6f 72 64 3f 20 72 65 63  port record? rec
04e0: 6f 72 64 2d 72 74 64 0a 20 20 20 20 20 20 20 20  ord-rtd.        
04f0: 20 20 72 74 64 2d 6e 61 6d 65 20 72 74 64 2d 70    rtd-name rtd-p
0500: 61 72 65 6e 74 0a 20 20 20 20 20 20 20 20 20 20  arent.          
0510: 72 74 64 2d 66 69 65 6c 64 2d 6e 61 6d 65 73 20  rtd-field-names 
0520: 72 74 64 2d 61 6c 6c 2d 66 69 65 6c 64 2d 6e 61  rtd-all-field-na
0530: 6d 65 73 20 72 74 64 2d 66 69 65 6c 64 2d 6d 75  mes rtd-field-mu
0540: 74 61 62 6c 65 3f 29 0a 0a 20 20 28 69 6d 70 6f  table?)..  (impo
0550: 72 74 20 28 72 6e 72 73 20 62 61 73 65 29 0a 20  rt (rnrs base). 
0560: 20 20 20 20 20 20 20 20 20 28 72 6e 72 73 20 6c           (rnrs l
0570: 69 73 74 73 29 0a 20 20 20 20 20 20 20 20 20 20  ists).          
0580: 28 72 6e 72 73 20 72 65 63 6f 72 64 73 20 69 6e  (rnrs records in
0590: 73 70 65 63 74 69 6f 6e 29 0a 20 20 20 20 20 20  spection).      
05a0: 20 20 20 20 28 73 72 66 69 20 73 39 39 20 72 65      (srfi s99 re
05b0: 63 6f 72 64 73 20 68 65 6c 70 65 72 29 29 0a 0a  cords helper))..
05c0: 20 20 3b 20 54 68 65 20 72 65 63 6f 72 64 3f 20    ; The record? 
05d0: 70 72 65 64 69 63 61 74 65 20 69 73 20 61 6c 72  predicate is alr
05e0: 65 61 64 79 20 64 65 66 69 6e 65 64 20 62 79 20  eady defined by 
05f0: 28 72 6e 72 73 20 72 65 63 6f 72 64 73 20 69 6e  (rnrs records in
0600: 73 70 65 63 74 69 6f 6e 29 2e 0a 0a 20 20 3b 20  spection)...  ; 
0610: 54 68 65 20 72 65 63 6f 72 64 2d 72 74 64 20 70  The record-rtd p
0620: 72 6f 63 65 64 75 72 65 20 69 73 20 61 6c 72 65  rocedure is alre
0630: 61 64 79 20 64 65 66 69 6e 65 64 20 62 79 20 28  ady defined by (
0640: 72 6e 72 73 20 72 65 63 6f 72 64 73 20 69 6e 73  rnrs records ins
0650: 70 65 63 74 69 6f 6e 29 2e 0a 0a 20 20 28 64 65  pection)...  (de
0660: 66 69 6e 65 20 72 74 64 2d 6e 61 6d 65 20 72 65  fine rtd-name re
0670: 63 6f 72 64 2d 74 79 70 65 2d 6e 61 6d 65 29 0a  cord-type-name).
0680: 0a 20 20 28 64 65 66 69 6e 65 20 72 74 64 2d 70  .  (define rtd-p
0690: 61 72 65 6e 74 20 72 65 63 6f 72 64 2d 74 79 70  arent record-typ
06a0: 65 2d 70 61 72 65 6e 74 29 0a 0a 20 20 28 64 65  e-parent)..  (de
06b0: 66 69 6e 65 20 72 74 64 2d 66 69 65 6c 64 2d 6e  fine rtd-field-n
06c0: 61 6d 65 73 20 72 65 63 6f 72 64 2d 74 79 70 65  ames record-type
06d0: 2d 66 69 65 6c 64 2d 6e 61 6d 65 73 29 0a 0a 20  -field-names).. 
06e0: 20 28 64 65 66 69 6e 65 20 28 72 74 64 2d 61 6c   (define (rtd-al
06f0: 6c 2d 66 69 65 6c 64 2d 6e 61 6d 65 73 20 72 74  l-field-names rt
0700: 64 29 0a 20 20 20 20 28 64 65 66 69 6e 65 20 28  d).    (define (
0710: 6c 6f 6f 70 20 72 74 64 20 6f 74 68 65 72 6e 61  loop rtd otherna
0720: 6d 65 73 29 0a 20 20 20 20 20 20 28 6c 65 74 20  mes).      (let 
0730: 28 28 70 61 72 65 6e 74 20 28 72 74 64 2d 70 61  ((parent (rtd-pa
0740: 72 65 6e 74 20 72 74 64 29 29 0a 20 20 20 20 20  rent rtd)).     
0750: 20 20 20 20 20 20 20 28 6e 61 6d 65 73 20 28 61         (names (a
0760: 70 70 65 6e 64 20 28 76 65 63 74 6f 72 2d 3e 6c  ppend (vector->l
0770: 69 73 74 0a 20 20 20 20 20 20 20 20 20 20 20 20  ist.            
0780: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0790: 28 72 74 64 2d 66 69 65 6c 64 2d 6e 61 6d 65 73  (rtd-field-names
07a0: 20 72 74 64 29 29 0a 20 20 20 20 20 20 20 20 20   rtd)).         
07b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
07c0: 20 20 6f 74 68 65 72 6e 61 6d 65 73 29 29 29 0a    othernames))).
07d0: 20 20 20 20 20 20 20 20 28 69 66 20 70 61 72 65          (if pare
07e0: 6e 74 0a 20 20 20 20 20 20 20 20 20 20 20 20 28  nt.            (
07f0: 6c 6f 6f 70 20 70 61 72 65 6e 74 20 6e 61 6d 65  loop parent name
0800: 73 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 28  s).            (
0810: 6c 69 73 74 2d 3e 76 65 63 74 6f 72 20 6e 61 6d  list->vector nam
0820: 65 73 29 29 29 29 0a 20 20 20 20 28 6c 6f 6f 70  es)))).    (loop
0830: 20 72 74 64 20 27 28 29 29 29 0a 0a 20 20 28 64   rtd '()))..  (d
0840: 65 66 69 6e 65 20 28 72 74 64 2d 66 69 65 6c 64  efine (rtd-field
0850: 2d 6d 75 74 61 62 6c 65 3f 20 72 74 64 30 20 66  -mutable? rtd0 f
0860: 69 65 6c 64 6e 61 6d 65 29 0a 20 20 20 20 28 64  ieldname).    (d
0870: 65 66 69 6e 65 20 28 6c 6f 6f 70 20 72 74 64 29  efine (loop rtd)
0880: 0a 20 20 20 20 20 20 28 69 66 20 28 72 74 64 3f  .      (if (rtd?
0890: 20 72 74 64 29 0a 20 20 20 20 20 20 20 20 20 20   rtd).          
08a0: 28 6c 65 74 2a 20 28 28 6e 61 6d 65 73 20 28 76  (let* ((names (v
08b0: 65 63 74 6f 72 2d 3e 6c 69 73 74 20 28 72 74 64  ector->list (rtd
08c0: 2d 66 69 65 6c 64 2d 6e 61 6d 65 73 20 72 74 64  -field-names rtd
08d0: 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20  ))).            
08e0: 20 20 20 20 20 28 70 72 6f 62 65 20 28 6d 65 6d       (probe (mem
08f0: 71 20 66 69 65 6c 64 6e 61 6d 65 20 6e 61 6d 65  q fieldname name
0900: 73 29 29 29 0a 20 20 20 20 20 20 20 20 20 20 20  s))).           
0910: 20 28 69 66 20 70 72 6f 62 65 0a 20 20 20 20 20   (if probe.     
0920: 20 20 20 20 20 20 20 20 20 20 20 28 72 65 63 6f             (reco
0930: 72 64 2d 66 69 65 6c 64 2d 6d 75 74 61 62 6c 65  rd-field-mutable
0940: 3f 20 72 74 64 20 28 2d 20 28 6c 65 6e 67 74 68  ? rtd (- (length
0950: 20 6e 61 6d 65 73 29 20 28 6c 65 6e 67 74 68 20   names) (length 
0960: 70 72 6f 62 65 29 29 29 0a 20 20 20 20 20 20 20  probe))).       
0970: 20 20 20 20 20 20 20 20 20 28 6c 6f 6f 70 20 28           (loop (
0980: 72 74 64 2d 70 61 72 65 6e 74 20 72 74 64 29 29  rtd-parent rtd))
0990: 29 29 0a 20 20 20 20 20 20 20 20 20 20 28 61 73  )).          (as
09a0: 73 65 72 74 69 6f 6e 2d 76 69 6f 6c 61 74 69 6f  sertion-violatio
09b0: 6e 20 27 72 74 64 2d 66 69 65 6c 64 2d 6d 75 74  n 'rtd-field-mut
09c0: 61 62 6c 65 3f 0a 20 20 20 20 20 20 20 20 20 20  able?.          
09d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
09e0: 20 20 20 20 20 22 69 6c 6c 65 67 61 6c 20 61 72       "illegal ar
09f0: 67 75 6d 65 6e 74 22 20 72 74 64 30 20 66 69 65  gument" rtd0 fie
0a00: 6c 64 6e 61 6d 65 29 29 29 0a 20 20 20 20 28 6c  ldname))).    (l
0a10: 6f 6f 70 20 72 74 64 30 29 29 0a 0a 29 0a        oop rtd0))..).