[racket-dev] 'case' using equal?
I spoke too soon. Now I get a lot of these:
/Users/jaz/src/racket/collects/images/private/flomap-transform.rkt:106:2:
Type Checker: untyped identifier check-em imported from module
<case.rkt>
in: (define-values (x-min y-min x-max y-max) (case bounded-by ((id)
(values 0 0 w h)) ((corners) (for*/fold: ((x-min : Float +inf.0)
(y-min : Float +inf.0) (x-max : Float -inf.0) (y-max : Float -inf.0))
((y : Integer (list 0 h)) (x : Integer (list 0 w))) (m...
context...:
/Users/jaz/src/racket/collects/typed-racket/typecheck/tc-toplevel.rkt:295:0:
type-check
success
/Users/jaz/src/racket/collects/typed-racket/typed-racket.rkt:38:4
/Users/jaz/src/racket/collects/compiler/cm.rkt:353:0: compile-zo*
/Users/jaz/src/racket/collects/compiler/cm.rkt:560:26
/Users/jaz/src/racket/collects/compiler/cm.rkt:553:42
/Users/jaz/src/racket/collects/compiler/cm.rkt:518:0: maybe-compile-zo
/Users/jaz/src/racket/collects/compiler/cm.rkt:631:2: do-check
/Users/jaz/src/racket/collects/compiler/cm.rkt:741:4:
compilation-manager-load-handler
standard-module-name-resolver
success
/Users/jaz/src/racket/collects/typed-racket/typed-racket.rkt:38:4
/Users/jaz/src/racket/collects/compiler/cm.rkt:353:0: compile-zo*
/Users/jaz/src/racket/collects/compiler/cm.rkt:560:26
/Users/jaz/src/racket/collects/compiler/cm.rkt:553:42
/Users/jaz/src/racket/collects/compiler/cm.rkt:518:0: maybe-compile-zo...
Is there a way to give check-em a type for TR without breaking it for
non-typed code?
On Sun, Nov 25, 2012 at 10:28 PM, Jon Zeppieri <zeppieri at gmail.com> wrote:
> Thanks! With that approach, I can get it to build. -J
>
> On Sun, Nov 25, 2012 at 10:11 PM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> I'm not sure what that error message means, but I think I was thinking
>> of a different strategy. Something like this (but where you deal with
>> 'else' properly and write in '#%kernel (so you have to use the
>> expansion of log-info etc etc)), all staying in the same file.
>>
>> #lang racket
>> (provide (rename-out [new:case case]))
>> (define-syntax (new:case stx)
>> (with-syntax ([line (syntax-line stx)]
>> [fn (syntax-source stx)])
>> (syntax-case stx ()
>> [(_ exp [(d ...) exp ...])
>> #'(let ([x exp])
>> (check-em 'fn line x '(d ... ...))
>> (case exp [(d ...) exp ...] ...))])))
>>
>> (define (check-em file line val datums)
>> (for ([datum (in-list datums)])
>> (unless (eq? (equal? datum val)
>> (eqv? datum val))
>> (log-info
>> (format "found a difference in ~a:~a; ~s vs ~s"
>> file line datum val)))))
>>
>> Robby
>>
>> On Sun, Nov 25, 2012 at 8:57 PM, Jon Zeppieri <zeppieri at gmail.com> wrote:
>>> On Sun, Nov 25, 2012 at 7:49 PM, Jon Zeppieri <zeppieri at gmail.com> wrote:
>>>>
>>>> Looking back at the users thread, I see what you mean. I'll create a
>>>> branch that will do what you suggest: evaluate the expression both
>>>> ways, compare, and complain if the results differ.
>>>>
>>>
>>> This is not turning out to be as simple as expected.
>>>
>>> I created modules equal-case.rkt and eqv-case.rkt, and then a simple
>>> case macro in case.rkt that uses both. However, the build fails at:
>>>
>>> make xsrc/precomp.h
>>> env XFORM_PRECOMP=yes ../racketcgc -cqu ../../../racket/gc2/xform.rkt
>>> --setup . --cpp "gcc -E -I./.. -I../../../racket/gc2/../include -DOS_X
>>> -D_DARWIN_UNLIMITED_SELECT -pthread -fno-common " --keep-lines -o
>>> xsrc/precomp.h ../../../racket/gc2/precomp.c
>>> /Users/jaz/src/racket/collects/s-exp/lang/reader.rkt:1:36:
>>> syntax/module-reader: got two #:language keywords
>>> in: #:language
>>> context...:
>>> /Users/jaz/src/racket/collects/syntax/module-reader.rkt:19:14: loop
>>> /Users/jaz/src/racket/collects/syntax/module-reader.rkt:35:4:
>>> construct-reader
>>> standard-module-name-resolver
>>> standard-module-name-resolver
>>> standard-module-name-resolver
>>> /Users/jaz/src/racket/src/racket/gc2/xform.rkt:95:24
>>> /Users/jaz/src/racket/src/racket/gc2/xform.rkt: [running body]
>>> make[4]: *** [xsrc/precomp.h] Error 1
>>> make[3]: *** [all] Error 2
>>> make[2]: *** [3m] Error 2
>>> make[1]: *** [3m] Error 2
>>> make: *** [all] Error 2