Inheritance classes in Scheme
        Posted  
        
            by DreamWalker
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by DreamWalker
        
        
        
        Published on 2010-03-04T19:23:10Z
        Indexed on 
            2010/03/23
            20:03 UTC
        
        
        Read the original article
        Hit count: 342
        
Now I research OOP-part of Scheme. I can define class in Scheme like this:
(define (create-queue)
  (let ((mpty #t) 
        (the-list '()))
    (define (enque value)
      (set! the-list (append the-list (list value)))
      (set! mpty #f)
      the-list)
    (define (deque)
      (set! the-list (cdr the-list))
      (if (= (length the-list) 0) 
      (set! mpty #t))
      the-list)
    (define (isEmpty)
      mpty)
    (define (ptl)
      the-list)
    (define (dispatch method)
      (cond ((eq? method 'enque) enque)
        ((eq? method 'deque) deque)
        ((eq? method 'isEmpty) isEmpty)
        ((eq? method 'print) ptl)))
    dispatch))
(Example from css.freetonik.com)
Can I implement class inheritance in Scheme?
© Stack Overflow or respective owner