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 and it helps code become less cluttered.
Well, lets take a step back. I just realized I can't even successfully map any primitive type to a new type. For example:
(c-declare #<<END
int add(int a) { return a+5; }
END )
(c-define-type num (type "int" #f))
(define add (c-lambda (num) int "add"))
Compiling and calling `(add 5)` throws a type error for the argument (can't convert to C type). I thought the third parameter of the 'type' expression bypassed type checking. What am I doing wrong?
Assuming I get that working, I could just bypass type checking altogether, but I don't want that. I was hoping to define a type along the lines of
(c-define-type real (type "float" "float int"))
where the third parameter of 'type' is a space-delimited list of type tags that should pass for this type. Is this possible, or on the todo list for c-interface improvements?
Thanks!