OSDN Git Service

[UPDATE] example
[happyabc/happyabc.git] / example / class.scm
1 ;; Example for class definition
2 ;;; 42
3 ;;; 12
4 ;;; [object Foo]
5 ;;; 10
6 ;;; [object Foo]
7
8
9 (define-class Foo (Object) ())
10 (define-method init ([self Foo] x)
11   (print x)
12   (let ((t 10)) 
13     (let ((t 12))
14       (print t))))
15
16 (define-method f ((self Foo) x)
17   (print x))
18
19 (define-method g ((self Foo))
20   (print self))
21
22 (define foo (new Foo 42))
23 (print foo)
24 (. foo (f 10))
25 (. foo (g))