Changeset 12010 in project


Ignore:
Timestamp:
09/26/08 20:49:44 (12 years ago)
Author:
Kon Lovett
Message:

Added "unsafe" record-type.

Location:
release/3/misc-extn
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/3/misc-extn/tags/3.2.0/misc-extn-eggdoc.scm

    r11839 r12010  
    7070        (usage "(require-extension misc-extn-record)")
    7171
    72         (macro "(define-unchecked-record-type T CTOR PRED [SLOT ...])"
     72        (macro "(define-record-type/unsafe-inline-unchecked T CTOR PRED [SLOT ...])"
    7373          (p "SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', "
    7474          "except no checks are made for correct record type before slot "
    75           "access, and the record type symbol is not defined.")
     75          "access, the record type symbol is not defined, "
     76          "procedures are inline, and unsafe system procedures are used.")
    7677
    7778          (p "For use when slot access is attempted " (i "only") " after "
    78           "determining the correct record type explicitly. Do " (i "not") " "
    79           "make constructed slot access procedures part of a public "
    80           "API."))
     79          "determining the correct record type explicitly."))
    8180
    8281        (macro "(define-inline-unchecked-record-type T CTOR PRED [SLOT ...])"
     
    723722
    724723    (history
     724      (version "3.2.0" "Removed 'define-unchecked-record-type'. Added 'define-record-type/unsafe-inline-unchecked'.")
    725725      (version "3.1.3" "Needed Unit files.")
    726726      (version "3.1" "Added misc-extn-directory; moved file-exists/directory, find-file-pathnames, find-program-pathnames, whch-command-pathname, remove-dotfiles from misc-extn-posix.")
  • release/3/misc-extn/tags/3.2.0/misc-extn-record.scm

    r9512 r12010  
    33
    44;;; Records
    5 
    6 ;; SRFI-9 workalike w/o record type checking.
    7 
    8 (define-macro (define-unchecked-record-type t conser pred . slots)
    9   (let ([vars (cdr conser)]
    10         [slotnames (map car slots)] )
    11     `(begin
    12        (define ,conser
    13          (##sys#make-structure ',t
    14                                ,@(map (lambda (sname)
    15                                         (if (memq sname vars)
    16                                             sname
    17                                             '(##sys#void) ) )
    18                                       slotnames) ) )
    19        (define (,pred x) (##sys#structure? x ',t))
    20        ,@(let loop ([slots slots] [i 1])
    21            (if (null? slots)
    22                '()
    23                (let ([slot (car slots)])
    24                  (let ([setters (memq #:record-setters ##sys#features)]
    25                        [setr? (pair? (cddr slot))]
    26                        [getr `(lambda (x) (##sys#block-ref x ,i) ) ] )
    27                    `(,@(if setr?
    28                            `((define (,(caddr slot) x y) (##sys#block-set! x ,i y)) )
    29                            '() )
    30                      (define ,(cadr slot)
    31                        ,(if (and setr? setters)
    32                             `(getter-with-setter ,getr ,(caddr slot))
    33                              getr) )
    34                      ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) ) )
    355
    366;; SRFI-9 workalike w/o record type checking and inline procedures.
     
    5727                   (define-inline (,(cadr slot) x) (##sys#block-ref x ,i) )
    5828                   ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) )
     29
     30;; SRFI-9 workalike w/o record type checking, immediate reference, and inline procedures.
     31
     32(define-macro (define-record-type/unsafe-inline-unchecked t conser pred . slots)
     33  (let ([vars (cdr conser)]
     34        [slotnames (map car slots)] )
     35    `(begin
     36       (define-inline ,conser
     37         (##sys#make-structure ',t
     38                               ,@(map (lambda (sname)
     39                                        (if (memq sname vars)
     40                                            sname
     41                                            '(##sys#void) ) )
     42                                      slotnames) ) )
     43       (define-inline (,pred x) (##sys#structure? x ',t))
     44       ,@(let loop ([slots slots] [i 1])
     45           (if (null? slots)
     46               '()
     47               (let ([slot (car slots)])
     48                 `(,@(if (pair? (cddr slot))
     49                         `((define-inline (,(caddr slot) x y) (##sys#setslot x ,i y)) )
     50                          '() )
     51                   (define-inline (,(cadr slot) x) (##sys#slot x ,i) )
     52                   ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) )
  • release/3/misc-extn/tags/3.2.0/misc-extn.html

    r9512 r12010  
    163163<div class="section">
    164164<h3>Usage</h3>(require-extension misc-extn-record)</div>
    165 <dt class="definition"><strong>macro:</strong> (define-unchecked-record-type T CTOR PRED [SLOT ...])</dt>
    166 <dd>
    167 <p>SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, and the record type symbol is not defined.</p>
    168 <p>For use when slot access is attempted <i>only</i> after determining the correct record type explicitly. Do <i>not</i> make constructed slot access procedures part of a public API.</p></dd>
     165<dt class="definition"><strong>macro:</strong> (define-record-type/unsafe-inline-unchecked T CTOR PRED [SLOT ...])</dt>
     166<dd>
     167<p>SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, the record type symbol is not defined, procedures are inline, and unsafe system procedures are used.</p>
     168<p>For use when slot access is attempted <i>only</i> after determining the correct record type explicitly.</p></dd>
    169169<dt class="definition"><strong>macro:</strong> (define-inline-unchecked-record-type T CTOR PRED [SLOT ...])</dt>
    170170<dd>
     
    685685<h3>Version</h3>
    686686<ul>
     687<li>3.2.0 Removed 'define-unchecked-record-type'. Added 'define-record-type/unsafe-inline-unchecked'.</li>
     688<li>3.1.3 Needed Unit files.</li>
    687689<li>3.1 Added misc-extn-directory; moved file-exists/directory, find-file-pathnames, find-program-pathnames, whch-command-pathname, remove-dotfiles from misc-extn-posix.</li>
    688690<li>3.003 Added list macros. Deprecated alist-delete*, filter-rest-argument!. Added misc-extn-dsssl.</li>
  • release/3/misc-extn/trunk/misc-extn-eggdoc.scm

    r11839 r12010  
    7070        (usage "(require-extension misc-extn-record)")
    7171
    72         (macro "(define-unchecked-record-type T CTOR PRED [SLOT ...])"
     72        (macro "(define-record-type/unsafe-inline-unchecked T CTOR PRED [SLOT ...])"
    7373          (p "SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', "
    7474          "except no checks are made for correct record type before slot "
    75           "access, and the record type symbol is not defined.")
     75          "access, the record type symbol is not defined, "
     76          "procedures are inline, and unsafe system procedures are used.")
    7677
    7778          (p "For use when slot access is attempted " (i "only") " after "
    78           "determining the correct record type explicitly. Do " (i "not") " "
    79           "make constructed slot access procedures part of a public "
    80           "API."))
     79          "determining the correct record type explicitly."))
    8180
    8281        (macro "(define-inline-unchecked-record-type T CTOR PRED [SLOT ...])"
     
    723722
    724723    (history
     724      (version "3.2.0" "Removed 'define-unchecked-record-type'. Added 'define-record-type/unsafe-inline-unchecked'.")
    725725      (version "3.1.3" "Needed Unit files.")
    726726      (version "3.1" "Added misc-extn-directory; moved file-exists/directory, find-file-pathnames, find-program-pathnames, whch-command-pathname, remove-dotfiles from misc-extn-posix.")
  • release/3/misc-extn/trunk/misc-extn-record.scm

    r9512 r12010  
    33
    44;;; Records
    5 
    6 ;; SRFI-9 workalike w/o record type checking.
    7 
    8 (define-macro (define-unchecked-record-type t conser pred . slots)
    9   (let ([vars (cdr conser)]
    10         [slotnames (map car slots)] )
    11     `(begin
    12        (define ,conser
    13          (##sys#make-structure ',t
    14                                ,@(map (lambda (sname)
    15                                         (if (memq sname vars)
    16                                             sname
    17                                             '(##sys#void) ) )
    18                                       slotnames) ) )
    19        (define (,pred x) (##sys#structure? x ',t))
    20        ,@(let loop ([slots slots] [i 1])
    21            (if (null? slots)
    22                '()
    23                (let ([slot (car slots)])
    24                  (let ([setters (memq #:record-setters ##sys#features)]
    25                        [setr? (pair? (cddr slot))]
    26                        [getr `(lambda (x) (##sys#block-ref x ,i) ) ] )
    27                    `(,@(if setr?
    28                            `((define (,(caddr slot) x y) (##sys#block-set! x ,i y)) )
    29                            '() )
    30                      (define ,(cadr slot)
    31                        ,(if (and setr? setters)
    32                             `(getter-with-setter ,getr ,(caddr slot))
    33                              getr) )
    34                      ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) ) )
    355
    366;; SRFI-9 workalike w/o record type checking and inline procedures.
     
    5727                   (define-inline (,(cadr slot) x) (##sys#block-ref x ,i) )
    5828                   ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) )
     29
     30;; SRFI-9 workalike w/o record type checking, immediate reference, and inline procedures.
     31
     32(define-macro (define-record-type/unsafe-inline-unchecked t conser pred . slots)
     33  (let ([vars (cdr conser)]
     34        [slotnames (map car slots)] )
     35    `(begin
     36       (define-inline ,conser
     37         (##sys#make-structure ',t
     38                               ,@(map (lambda (sname)
     39                                        (if (memq sname vars)
     40                                            sname
     41                                            '(##sys#void) ) )
     42                                      slotnames) ) )
     43       (define-inline (,pred x) (##sys#structure? x ',t))
     44       ,@(let loop ([slots slots] [i 1])
     45           (if (null? slots)
     46               '()
     47               (let ([slot (car slots)])
     48                 `(,@(if (pair? (cddr slot))
     49                         `((define-inline (,(caddr slot) x y) (##sys#setslot x ,i y)) )
     50                          '() )
     51                   (define-inline (,(cadr slot) x) (##sys#slot x ,i) )
     52                   ,@(loop (cdr slots) (add1 i)) ) ) ) ) ) ) )
  • release/3/misc-extn/trunk/misc-extn.html

    r9512 r12010  
    163163<div class="section">
    164164<h3>Usage</h3>(require-extension misc-extn-record)</div>
    165 <dt class="definition"><strong>macro:</strong> (define-unchecked-record-type T CTOR PRED [SLOT ...])</dt>
    166 <dd>
    167 <p>SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, and the record type symbol is not defined.</p>
    168 <p>For use when slot access is attempted <i>only</i> after determining the correct record type explicitly. Do <i>not</i> make constructed slot access procedures part of a public API.</p></dd>
     165<dt class="definition"><strong>macro:</strong> (define-record-type/unsafe-inline-unchecked T CTOR PRED [SLOT ...])</dt>
     166<dd>
     167<p>SRFI-9 '(define-record-type T CTOR PRED [SLOT ...])', except no checks are made for correct record type before slot access, the record type symbol is not defined, procedures are inline, and unsafe system procedures are used.</p>
     168<p>For use when slot access is attempted <i>only</i> after determining the correct record type explicitly.</p></dd>
    169169<dt class="definition"><strong>macro:</strong> (define-inline-unchecked-record-type T CTOR PRED [SLOT ...])</dt>
    170170<dd>
     
    685685<h3>Version</h3>
    686686<ul>
     687<li>3.2.0 Removed 'define-unchecked-record-type'. Added 'define-record-type/unsafe-inline-unchecked'.</li>
     688<li>3.1.3 Needed Unit files.</li>
    687689<li>3.1 Added misc-extn-directory; moved file-exists/directory, find-file-pathnames, find-program-pathnames, whch-command-pathname, remove-dotfiles from misc-extn-posix.</li>
    688690<li>3.003 Added list macros. Deprecated alist-delete*, filter-rest-argument!. Added misc-extn-dsssl.</li>
Note: See TracChangeset for help on using the changeset viewer.