5 Fév
2008
5 Fév
'08
04:58
James Long wrote:
Is there anyway to specify multiple tags for a type so that, for example, I could pass either a float or an int to a c function? C's basic type coercion, in my opinion, is not a bad thing
See the two attached solutions. floatorint.scm is a type-safe variant, it lets you pass around the original value (a union type), while coerce.scm really coerces the value directly (feel free to add code to check whether a float is within the int range yourself ;)). Christian.