PasteRack.org
Paste # 83833
2022-07-20 01:51:45

Forked from paste # 25105.

Fork as a new paste.

Paste viewed 1426 times.


Embed:

  1. #lang racket  ; A picture
  2. (define-type Hello-Class%
  3.   (Class
  4.    [say-hello (-> Void)]))
  5.  
  6. (: hello-class% Hello-Class%)
  7. (define hello-class%
  8.   (class object%
  9.     (super-new)
  10.     (define/public (say-hello)
  11.       (printf "Hello World!~%"))))
  12.  
  13. (: the-instance (U #f (Instance Hello-Class%)))
  14. (define the-instance #f)
  15.  
  16. (: say-hello (-> Void))
  17. (define (say-hello)
  18.   (unless the-instance
  19.     (set! the-instance (new hello-class%)))
  20.   (when (class? the-instance)
  21.     (send the-instance say-hello)))

=>

define-type: undefined;

 cannot reference an identifier before its definition

  in module: 'm

:: undefined;

 cannot reference an identifier before its definition

  in module: 'm

:: undefined;

 cannot reference an identifier before its definition

  in module: 'm

:: undefined;

 cannot reference an identifier before its definition

  in module: 'm