首页 > 解决方案 > Typed Racket 扩展 gui 类

问题描述

我想扩展课程 horizontal-panel%,但不知何故我收到了这个错误信息:

class has init `stretchable-height' that is not in expected type in: (class horizontal-panel% (super-new))

到目前为止,这是我的代码:

#lang typed/racket
(require typed/racket/gui)

(define-type Graph-Tab%
  (Class #:implements  Horizontal-Panel%

         ))
(: graph-tab% : Graph-Tab%)
(define graph-tab%
  (class horizontal-panel%
    (super-new)

    ))

你可能会说我对球拍很陌生,而且我还在学习。

标签: rackettyped-racket

解决方案


我很确定该错误消息的含义是您需要“初始化”该类中的所有内容。

一种有用的方法是在您的类型定义中更改 from#:implements#:implements/inits在缺少的值上调用 init (在这种情况下stretchable-height)。

如果你不知道它们到底是什么,你可以简单地把(init-rest)它放在一边。

(这里是Initialization Variableshorizontal-panel%文档)


推荐阅读