[racket] Typed racket problem

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Sun Nov 30 23:18:52 EST 2014

On Sun, 30 Nov 2014 17:47:23 -0500
Matthias Felleisen <matthias at ccs.neu.edu>
wrote:

> 
> In terms of cost, that's identical to what I had __and__ it locks in
> the number of variants you can deal with. 

I agree that in terms of cost there is no difference. Yes, it locks in
the number of variants. Therefore I have one more checking.


> 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. 
> 

This is more flexibility, I agree. But due to my extra checking in
optval I would notice if I had forgotten anything.


> 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. 
> 

This is a great idea. I think I will make it a class with 15 fields.


Thanks for your help.


-- 
Manfred



> 
> 
> 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
> 
> 
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 




Posted on the users mailing list.