Next: , Previous: , Up: overview   [Index]


1.7 Implementation extensions

Here is a list of implementation extensions which may be non–compliant with R6RS.

  1. According to R6RS: if the parent of a record type has a custom protocol function, the record type itself must have a custom protocol function; that is:
    (import (rnrs))
    
    (define-record-type alpha
      (fields a)
      (protocol (lambda (A) ---)))
    
    ;; this is good
    (define-record-type beta
      (parent alpha)
      (fields b)
      (protocol (lambda (A B) ---)))
    
    ;; this is bad according to R6RS!!!
    (define-record-type gamma
      (parent alpha)
      (fields b))
    

    This restriction is violated by Vicare, which allows the following:

    (import (rnrs))
    
    (define-record-type alpha
      (fields a)
      (protocol (lambda (A) ---)))
    
    ;; this is good in Vicare!!!
    (define-record-type beta
      (parent alpha)
      (fields b))
    

    Vicare just expects the parent protocol function to have the same interface of a default protocol function.

  2. If vicare is run without the option --strict-r6rs: the syntax define-record-type automatically generates unsafe field accessor and mutator syntaxes; in the following example:
    (define-record-type color
      (fields (mutable red)
              (mutable green)
              (mutable blue)))
    

    in addition to the safe accessor and mutator definitions for:

    color-red           color-red-set!
    color-green         color-green-set!
    color-blue          color-blue-set!
    

    unsafe accessors and mutator definitions for:

    $color-red          $color-red-set!
    $color-green        $color-green-set!
    $color-blue         $color-blue-set!
    

    are generated with code like:

    (define-syntax $color-red
      (syntax-rules ()
        ((_ x)
         ($struct-ref x 0))))
    
    (define-syntax $color-red-set!
      (syntax-rules ()
        ((_ x v)
         ($struct-set! x 0 v))))
    

    Notice that the name of the unsafe accessors and mutators is always built from the field name, not from the custom names given in the definition; for example:

    (import (rnrs))
    
    (define-record-type color
      (fields (mutable red   the-red   set-the-red!)
              (mutable green the-green set-the-green!)
              (mutable blue  the-blue  set-the-blue!)))
    
    (define X
      (make-color 1 2 3))
    
    (define Y
      (make-color 1 2 3))
    
    (set-the-red!   X 10)
    (set-the-green! X 20)
    (set-the-blue!  X 30)
    (list (the-red   X)
          (the-green X)
          (the-blue  X)))
    ⇒ (10 20 30)
    
    ($color-red-set!   Y 10)
    ($color-green-set! Y 20)
    ($color-blue-set!  Y 30)
    (list ($color-red   Y)
          ($color-green Y)
          ($color-blue  Y)))
    ⇒ (10 20 30)
    
  3. R6RS records can be automatically finalised whenever the garbage collector reclaims them. It is possible to register a destructor function in the R6RS record–type descriptor; whenever a record is instantiated and its record–type descriptor has a destructor function: the record is registered in an internal guardian. The guardian has an associated post garbage collection hook which applies the destructor to the record. iklib records final for details.

Next: , Previous: , Up: overview   [Index]