Fichier objets.ex / 2 mars 2000 Welcome to DrScheme, version 101. Language: Graphical Full Scheme (MrEd). > (define toto% (class object% () (public (x 3)) (sequence (super-init)))) > (define toto1 (make-object toto%)) > toto% # > toto1 # > (ivar toto1 x) 3 Heritage: ----------- > (define titi% (class toto% () (public (y sqrt)) (sequence (super-init)))) > (define titi1 (make-object titi%)) > (ivar titi1 x) 3 > (ivar titi1 y) # > (send titi1 y 9) 3 > (send titi1 y 25) 5 > ((ivar titi1 y) 25) 5 > (ivar titi1 x) 3 > (send titi1 y 2 3) sqrt: expects 1 argument, given 2: 2 3 Modification de variable: ----------------------------- on ne peut pas le faire sur les variables heritees > (define tutu% (class object% () (public (x 0) (z (lambda (u) (set! x u)))) (sequence (super-init)))) > (define tutu1 (make-object tutu%)) > (send tutu1 z 4) > (ivar tutu1 x) 4 > (send tutu1 z 734693896359) > (ivar tutu1 x) 734693896359 > x reference to undefined identifier: x > (ivar toto1 x) 3