Documentation and meta functions
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
@(require
|
||||
scribble/example
|
||||
@(for-label racket roos))
|
||||
@(for-label roos))
|
||||
|
||||
@(define myeval
|
||||
(make-base-eval '(require roos)))
|
||||
@@ -23,22 +23,69 @@ method will be used.
|
||||
...
|
||||
((method-j ...) expr ...)
|
||||
)]
|
||||
Defines a class with name @code{class-name}. @code{this} refers to the instantiated object of class @{class-name}, @code{supers} refers to the possible instantiated super classes of @code{class-name}. @code{attribute-i} defines an attribute. It will create a getter, named @code{attribute-i}, and a setter, named @code{attribute-i!}. @code{method-j} defines a method.
|
||||
Defines a class with name @code{class-name}. @code{this} refers to the instantiated object of class @code{class-name}, @code{supers} refers to the possible instantiated super classes of @code{class-name}. @code{attribute-i} defines an attribute. It will create a getter, named @code{attribute-i}, and a setter, named @code{attribute-i!}. @code{method-j} defines a method.
|
||||
|
||||
@defform[(-> obj name ...)]
|
||||
Calls a method or getter/setter of obj.
|
||||
|
||||
@examples[#:eval eval
|
||||
@defform[(roos-class? var)]
|
||||
Returns @code{#t}, if var is a defined roos class; @code{#f}, otherwise.
|
||||
|
||||
@defform[(roos-object? var)]
|
||||
Returns @code{#t}, if var is a variable instantiated by a roos class; @code{#f}, otherwise.
|
||||
|
||||
@defform[(roos-classname var)]
|
||||
Returns the name (as symbol) of the defined roos class, or of the class of a roos object, if var is an instantiated class; @code{#f}, otherwise.
|
||||
|
||||
@defform[(roos-class var)]
|
||||
Returns the defined roos class of an instantiated roos class if @code{roos-object?} returns @code{#t}; @code{#f}, otherwise
|
||||
|
||||
|
||||
@examples[(require roos)
|
||||
(roos (a x) this (supers)
|
||||
(y ( + x 4))
|
||||
((g a) (* a (-> this y))))
|
||||
(roos (b) this (supers (a))
|
||||
|
||||
(roos (b1) this (supers (a 6))
|
||||
((v . a) (if (null? a)
|
||||
(-> supers y)
|
||||
(begin
|
||||
(-> supers y! (car a))
|
||||
(-> supers y))))
|
||||
(y 55))
|
||||
(define bb (b))
|
||||
(-> bb g 2)]
|
||||
|
||||
(roos (b2) this (supers (a 5))
|
||||
((v2) (-> supers y))
|
||||
((v2*) (-> this y)))
|
||||
|
||||
(roos (c) this (supers (b1) (b2))
|
||||
((zy) (-> supers y))
|
||||
((z1) (-> supers v))
|
||||
((z2) (-> supers v2))
|
||||
(y -1))
|
||||
|
||||
(define-syntax :
|
||||
(syntax-rules ()
|
||||
((_ c d ...)
|
||||
c)))
|
||||
|
||||
(define bb (b1))
|
||||
|
||||
(: (-> bb g 2) "(-> bb g 2) Will return the value of (* 2 y of class b1)")
|
||||
(: (-> bb y! 7) "(-> bb y! 7) Will set y in class b1 to 7")
|
||||
(: (-> bb g 6) "(-> bb g 6) Will return 42")
|
||||
(: (-> bb v) "(-> bb v) Will return the value of y in class a")
|
||||
(: (-> bb v 42) "(-> bb v 42) Will set the value of y in class a to 42")
|
||||
(: (-> bb y) "(-> bb y) Will return the value of y in class b1, i.e. 7")
|
||||
(: (-> bb v) "(-> bb v) Will return the value of y in class a, i.e. 42")
|
||||
|
||||
(define cc (c))
|
||||
(: (-> cc zy) "(-> cc zy) Will return the value of y in super class b1")
|
||||
(: (-> cc y! 88) "(-> cc y! 88) Will set the value of y in class c")
|
||||
(: (-> cc zy) "(-> cc zy) Will return the value of y in super class b1")
|
||||
(: (-> cc z1) "(-> cc z1) Will return the value of y in the super class of b1, which will be (+ 4 6) = 10")
|
||||
(: (-> cc z2) "(-> cc z2) Will return this value of y in the super class of b2, which will be (+ 4 5) = 9")
|
||||
(: (-> cc v2*) "(-> cc v2*) Will return the value of y in class c")
|
||||
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user