And*_*hin 2 lisp inheritance scheme
现在我研究一下Scheme的OOP部分.我可以在Scheme中定义类,如下所示:
(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))
Run Code Online (Sandbox Code Playgroud)
我可以在Scheme中实现类继承吗?