3

「プログラミング言語:アプリケーションと解釈」の6ページから、DrRacketで最初の例をコーディングしようとしています。

#lang typed/racket

(define-type AE
 [num (n number?)]
 [add (lhs AE?) (rhs AE?)]
 [sub (lhs AE?) (rhs AE?)])

しかし、私はエラーを受け取ります

aeinterpretter.rkt:5:2: define-type: unexpected term in: (add (lhs AE?) (rhs AE?))

私はここで何が間違っているのですか?

4

1 に答える 1

7

You should run this example in the PLAI language:

#lang plai

(define-type AE
 [num (n number?)]
 [add (lhs AE?) (rhs AE?)]
 [sub (lhs AE?) (rhs AE?)])

The Typed Racket language is a totally different language that gives you most of the power of the base Racket language, but with a static type system. The define-type form in PLAI is a different notion of "type".

于 2012-08-25T18:46:21.787 に答える