Changeset 30565 in project


Ignore:
Timestamp:
03/15/14 12:26:52 (7 years ago)
Author:
juergen
Message:

cells cell-ref and cell-set! added

Location:
release/4/cells
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/cells/tags/1.1/cells.scm

    r30560 r30565  
    3232; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333;
    34 ; Last update: Mar 14, 2014
     34; Last update: Mar 15, 2014
    3535;
    3636
    3737(module cells
    38 (export cell cell? cell-of?)
     38(export cells cell cell? cell-of? cell-ref cell-set!)
    3939(import scheme
    4040        (only chicken case-lambda condition-case define-values
    41               define-reader-ctor gensym))
     41              define-reader-ctor gensym assert print))
     42
     43(define cells
     44  (case-lambda
     45    (()
     46     '(cell cell? cell-of? cell-ref cell-set!))
     47    ((sym)
     48     (case sym
     49       ((cell) (print "constructor: " '(cell arg)))
     50       ((cell?) (print "type predicate: " '(cell? xpr)))
     51       ((cell-of?) (print "predicate: " '((cell-of? type?) xpr)))
     52       ((cell-ref) (print "accessor: " '(cell-ref cell%)))
     53       ((cell-set!) (print "mutator: " '(cell-set! cell% val)))
     54       (else
     55         (print "choose one of " (cells)))))))
    4256
    4357(define-values (cell cell?)
     
    6276
    6377(define-reader-ctor '% cell)
     78
     79(define (cell-ref c%)
     80  (assert (cell? c%) "not a cell" c%)
     81  (c%))
     82
     83(define (cell-set! c% val)
     84  (assert (cell? c%) "not a cell" c%)
     85  (c% val))
     86
    6487) ; module cells
  • release/4/cells/tags/1.1/cells.setup

    r30560 r30565  
    77 'cells
    88 '("cells.so" "cells.import.so")
    9  '((version "1.0")))
     9 '((version "1.1")))
    1010
    1111
  • release/4/cells/tags/1.1/tests/run.scm

    r30560 r30565  
    1818    (not ((cell-of? list?) cell%))
    1919    (= (cell%) 5)
     20    (= (cell-ref cell%) 5)
    2021    (cell% 50)
    21     (= (cell%) 50)))
     22    (= (cell%) 50)
     23    (cell-set! cell% 500)
     24    (= (cell-ref cell%) 500)
     25    (condition-case (cell-ref 500)
     26      ((exn) #t))
     27    ))
    2228
    2329(define-test (STACKS)
  • release/4/cells/trunk/cells.scm

    r30560 r30565  
    3232; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3333;
    34 ; Last update: Mar 14, 2014
     34; Last update: Mar 15, 2014
    3535;
    3636
    3737(module cells
    38 (export cell cell? cell-of?)
     38(export cells cell cell? cell-of? cell-ref cell-set!)
    3939(import scheme
    4040        (only chicken case-lambda condition-case define-values
    41               define-reader-ctor gensym))
     41              define-reader-ctor gensym assert print))
     42
     43(define cells
     44  (case-lambda
     45    (()
     46     '(cell cell? cell-of? cell-ref cell-set!))
     47    ((sym)
     48     (case sym
     49       ((cell) (print "constructor: " '(cell arg)))
     50       ((cell?) (print "type predicate: " '(cell? xpr)))
     51       ((cell-of?) (print "predicate: " '((cell-of? type?) xpr)))
     52       ((cell-ref) (print "accessor: " '(cell-ref cell%)))
     53       ((cell-set!) (print "mutator: " '(cell-set! cell% val)))
     54       (else
     55         (print "choose one of " (cells)))))))
    4256
    4357(define-values (cell cell?)
     
    6276
    6377(define-reader-ctor '% cell)
     78
     79(define (cell-ref c%)
     80  (assert (cell? c%) "not a cell" c%)
     81  (c%))
     82
     83(define (cell-set! c% val)
     84  (assert (cell? c%) "not a cell" c%)
     85  (c% val))
     86
    6487) ; module cells
  • release/4/cells/trunk/cells.setup

    r30560 r30565  
    77 'cells
    88 '("cells.so" "cells.import.so")
    9  '((version "1.0")))
     9 '((version "1.1")))
    1010
    1111
  • release/4/cells/trunk/tests/run.scm

    r30560 r30565  
    1818    (not ((cell-of? list?) cell%))
    1919    (= (cell%) 5)
     20    (= (cell-ref cell%) 5)
    2021    (cell% 50)
    21     (= (cell%) 50)))
     22    (= (cell%) 50)
     23    (cell-set! cell% 500)
     24    (= (cell-ref cell%) 500)
     25    (condition-case (cell-ref 500)
     26      ((exn) #t))
     27    ))
    2228
    2329(define-test (STACKS)
Note: See TracChangeset for help on using the changeset viewer.