Type limits

So I went in and added the most basic data-driven type system and all was good…until I realized there is no elegant way to define value limits. For instance if you wanted the valid value of a key to be a floating point between 0 and 1, you’re out of luck. It can only say it’s a float (by matching a regular expression). It doesn’t even know it’s a numeric value.

So I have to add numeric types to the type definitions, at least. But, only allowing limits in type definitions would be cumbersome. Imagine having to use types like float_0_1. Actually, that’s not completely terrible, but I would desperately enjoy a shorthand range syntax. Then I don’t have to go around creating tonnes of type definitions with slightly different value limits.

Type definitions still have their uses, though. Like, I don’t know, if you wanted to make sure all your integer values could fit into 16-bits, you could define a custom type called ‘myint’ (or maybe I’ll allow the built-in type ‘int’ to be redefined!) and give it the appropriate limits (−32768,32767) and use it throughout your data definitions. Then one day you decide 32-bits is where it’s at, and you can just change the limits on ‘myint’ and you’re done!

So, there will be built-in primitive types after all and shorthand value range syntax. Not so bad I guess. I suppose the types will end up being something like: string, int, float, float2, float3, float4 with some kind of range syntax. Then I can go around saying things like: float(0,1). Hmm, I’m still undecided…

Leave a Reply