Changeset 8682 in project


Ignore:
Timestamp:
02/23/08 16:54:30 (12 years ago)
Author:
svnwiki
Message:

Changes applied for Anonymous (71.38.23.88) through svnwiki:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/yasos

    r8680 r8682  
    3636
    3737=== Examples
     38
    3839  ;;;===============
    3940  ;;;file yasos-examples.scm
    4041  ;;;===============
    41  
     42  
    4243  (declare (unit yasos-examples))
    4344  (require-extension syntax-case yasos format)
    44  
     45  
    4546  ;;----------------------------
    4647  ;; general operations
    4748  ;;----------------------------
    48  
     49  
    4950  (define-operation (print-obj obj port)
    5051    (format port
    5152      ;; if an instance does not have a print-obj operation..
    5253      (if (instance? obj) "#<INSTANCE>~%" "#<NOT-AN-INSTANCE: ~s>~%") obj))
    53  
     54  
    5455  (define-operation (size-obj obj)
    5556    ;; default behavior
     
    6263      (else
    6364        (error "Operation not supported: size-obj" obj))))
    64  
     65  
    6566  ;;----------------------
    6667  ;; point interface
    6768  ;;----------------------
    68  
     69  
    6970  (define-predicate point?) ;; answers #f  by default
    7071  (define-operation (x obj))
     
    7273  (define-operation (set-x! obj new-x))
    7374  (define-operation (set-y! obj new-y))
    74  
     75  
    7576  ;;--------------------------------
    7677  ;; point implementation
    7778  ;;--------------------------------
    78  
     79  
    7980  (define (make-point the-x the-y)
    8081    (object
     
    9192      ((print-obj self port)
    9293        (format port "#<point: ~a ~a>~%" (x self) (y self)))))
    93  
     94  
    9495  ;;-----------------------------------------
    9596  ;; 3D point interface additions
    9697  ;;-----------------------------------------
    97  
     98  
    9899  (define-predicate point-3d?) ;; #f by defualt
    99100  (define-operation (z obj))
    100101  (define-operation (set-z! obj new-z))
    101  
     102  
    102103  ;;------------------------------------
    103104  ;; 3D point implementation
    104105  ;;------------------------------------
    105  
     106  
    106107  (define (make-point-3d the-x the-y the-z)
    107108    (object-with-ancestors ( (a-point (make-point the-x the-y)) )
     
    113114      ((print-obj self port)
    114115        (format port "#<3d-point: ~a ~a ~a>~%" (x self) (y self) (z self)))))
    115  
     116  
    116117  ;;;-----------------------
    117118  ;; person interface
    118119  ;;------------------------
    119  
     120  
    120121  (define-predicate person?)
    121122  (define-operation (name obj))
     
    129130            bogus-passwd
    130131            (print-obj obj #f))))
    131  
     132  
    132133  ;;----------------------------------
    133134  ;; person implementation
    134135  ;;----------------------------------
    135  
     136  
    136137  (define (make-person a-name an-age a-ssn the-password)
    137138    (object
     
    152153      ((print-obj self port)
    153154        (format port "#<Person: ~a age: ~a>~%" (name self) (age self)))))
    154 
     155 
    155156  ;;;---------------------------------------------------------------
    156157  ;; account-history and bank-account interfaces
    157158  ;;----------------------------------------------------------------
    158  
     159   
    159160  (define-predicate bank-account?)
    160161  (define-operation (current-balance obj pin))
Note: See TracChangeset for help on using the changeset viewer.