Commit 1fad6582 authored by William G Hatch's avatar William G Hatch
Browse files

don't use the `case` form, use `cond` instead

The `case` form is terrible, and I wish it didn't exist.  I never use
it, and I've only seen new Racketeers use it wrong.  You never want
`case`, you want `cond` or `match` instead.

The `case` form only allows literal data in the match, so if you try
to use a variable it will be interpreted as a symbol instead!
Moreover, `case` and `cond` both have a terrible design mistake that
the fall-through case returns `void` instead of raising an error!
I've only seen `case` result in tiresome debugging.
parent a5fa7e15
......@@ -326,11 +326,12 @@
(λ (n t) ;; int to float or float to int, but only in the same bitwidth
(begin
(printf (format "node: ~a, type: ~a" n t))
(case t
[(i32) (hash 'expr f32)]
[(f32) (hash 'expr i32)]
[(i64) (hash 'expr f64)]
[(f64) (hash 'expr i64)])))]]
(cond
[(can-unify? t i32) (hash 'expr f32)]
[(can-unify? t f32) (hash 'expr i32)]
[(can-unify? t i64) (hash 'expr f64)]
[(can-unify? t f64) (hash 'expr i64)]
[else (eprintf "bad reinterpret, got ~v\n" t)])))]]
)
;; Define structured control instruction property
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment