Inheritance classes in Scheme
- by DreamWalker
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?