Skip to content

Instantly share code, notes, and snippets.

@LeifAndersen
Last active January 4, 2017 15:49
Show Gist options
  • Select an option

  • Save LeifAndersen/67128089c3f195b03f6f39fd0f9090eb to your computer and use it in GitHub Desktop.

Select an option

Save LeifAndersen/67128089c3f195b03f6f39fd0f9090eb to your computer and use it in GitHub Desktop.
#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)
#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)
#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