Sat Jul 23 16:06:17 CEST 2011
Types for DSP language
To simplify type conversions, let's stick to two types: machine
integers and floating point numbers. Integers can represent bools,
but floats and ints are fundamentally different.
I don't like the Pure Data approach of encoding ints in floats. Many
algorithms need exact counting and using floats for that is too
dangerous and unnecessarily inefficient for low-level rep.
Now it's important to distinguish two factors:
- embedding of constants
- being able to qualify operations or values as typed
The embedding isn't such a big deal. I don't think I ever ran into
integer constants that can't be embedded in a double apart from raw
memory addresses. The real issue is typed computations.
I run into this problem with (Expr a) as (Expr Double) or (Expr
Integer). The type only refers to constants, not necessarily to the
type of variables (which are essentially untyped).