Last active
January 4, 2017 15:49
-
-
Save LeifAndersen/67128089c3f195b03f6f39fd0f9090eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (module foo racket | |
| (provide A%) | |
| (define A% | |
| (class object% | |
| (super-new) | |
| (field [state 0]) | |
| (define/public (foo) | |
| "world")))) | |
| (module bar typed/racket | |
| (require/typed (submod ".." foo) | |
| [A% (Class (field [state (Vectorof String)]) | |
| [foo (-> (Vectorof String))])]) | |
| (define B% | |
| (class A% | |
| (super-new) | |
| (inherit-field state) | |
| (define/override (foo) | |
| state))) | |
| (define b (new B%)) | |
| (vector-ref (send b foo) 0)) | |
| (require 'bar) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (module foo racket | |
| (provide A%) | |
| (define A% | |
| (class object% | |
| (super-new) | |
| (field [state 0])))) | |
| (module bar typed/racket | |
| (require/typed (submod ".." foo) | |
| [A% (Class (field [state (Vectorof String)]))]) | |
| (define B% | |
| (class A% | |
| (super-new) | |
| (inherit-field state) | |
| (: foo (-> (Vectorof String))) | |
| (define/public (foo) | |
| state))) | |
| (define b (new B%)) | |
| (vector-ref (send b foo) 0)) | |
| (require 'bar) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lang racket | |
| (module foo racket | |
| (provide A%) | |
| (define A% | |
| (class object% | |
| (super-new) | |
| (define/public (foo) | |
| "hello") | |
| (define/public (bar) | |
| ;; TRY REPLACING WITH `(send this foo)`!!! | |
| (foo))))) | |
| (module bar typed/racket | |
| (require/typed (submod ".." foo) | |
| [A% (Class [foo (-> Integer)] | |
| [bar (-> String)])]) | |
| (define B% | |
| (class A% | |
| (super-new) | |
| ;; TRY COMMENTING OUT THIS METHOD!!! | |
| (define/override (foo) | |
| 42))) | |
| (define b (new B%)) | |
| (send b bar)) | |
| (require 'bar) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment