[racket] `assert' in Typed Racket

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Tue May 24 16:40:37 EDT 2011

On Tue, May 24, 2011 at 1:41 PM, Richard Lawrence
<richard.lawrence at berkeley.edu> wrote:
> Sam Tobin-Hochstadt <samth at ccs.neu.edu>
> writes:
>
>> (assert x p?) is equivalent to (if (p? x) x (error ...)) except that
>> the result is known to have the appropriate type (here `String').
>
> Ah, OK, I think I see my mistake; is this the right way to put it?
> Although the expression
>
> (assert x string?)
>
> has type String, and evaluates to the same value as `x' provided that
> value is indeed a string, this does not mean that the expression `x' has
> type String.

Right.

Typed Racket doesn't, in general, handle the following idiom as
usefully as it could:

(begin
  (unless (string? x) (error ...))
  (string-append x "blah"))

Improving this is a long term goal for Typed Racket.
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.