]>
Even better would be to have a "parametrized finite" type. This would
really need to be built into the compiler, as I don't think it can
actually be emulated by either camlp4 or the C interface.
The idea is very simple: add a primitive "n finite" type to the
language, where n is a positive integer constant.
For example:
type bit = 2 finite
type mod3 = 3 finite
Then, fill the type by coercion so that "(x :> n finite)", where both x
and n are known to be constant at compile-time and 0 <= x < n, becomes a
value of type "n finite".
This should be pretty straightforward to implement, and it may simplify
code that depends on types such as "T1 | T2 | T3 | T4"
I don't know how much it would be possible to relax the constraint above
while maintaining the typesystem sound. Does anybody whether this is
a known problem?
Thanks,
Fernando
On Fri, Nov 16, 2007 at 05:43:39PM +0100, Martin Jambon wrote:
>
> Please don't take my suggestions too seriously, but it could be cool to
> define types such as:
>
> type bit = [ 0 | 1 ]