[racket] Typed racket problem

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Nov 30 17:47:23 EST 2014

In terms of cost, that's identical to what I had __and__ it locks in the number of variants you can deal with. In contrast, mine allows extensions at the point where you define Myopt; for the new "fields", just pass in the additional type at the new call site. 

Now if you are sure that the 15 options you have are all you ever need, why not use a struct with 15 fields or a class with 15 fields? Then you get static checking, without needing any instance-of checks plus occurrence typing. 

-- Matthias





On Nov 30, 2014, at 4:52 PM, Manfred Lotz wrote:

> On Sun, 30 Nov 2014 22:21:14 +0100
> Manfred Lotz <manfred.lotz at arcor.de> wrote:
> 
>> No I hadn't considered the variant using type?. Thanks for this. 
>> 
>> Not quite sure if I'm happy about it as I would prefer to have the
>> type checking at one place instead of providing a type each time I
>> check/use options.
>> 
> 
> Saying this I think I like this version:
> 
> (define-syntax-rule (optval s ol)
>  (let ([found (assoc s ol)])
>    (if found
>        (let ([val (cdr found)])
>          (case s
>            ['size (assert val integer?)]
>            ['dir (assert val string?)]
>            ['verbose (assert val boolean?)]
>            [else (error "Forgot to check in optval: option" s)]))
>        (error "not found"))))
> 
> 
> -- 
> Manfred
> 
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.