Stephane Le Cornec coleste@videotron.ca writes:
At 10:56 AM -0500 1/10/08, Joel J. Adamson wrote:
Dear Gambit List,
I have a set of datatypes defined with c-define-type based on the GNU Scientific Library. The Gambit-C manual says "For type checking on the Scheme side..." to use the TAG function of the type definition as in
(c-define-type gsl-matrix* (pointer gsl-matrix "gsl-matrix*"))
IIRC, you only use the tag if you multiple c-define-type that are equivalent.
(c-define-type type1* (pointer type1 #f) (c-define-type type2* (pointer type2 "type") (c-define-type type3* (pointer type3 "type")
Here all 3 types are exchangeable.
Good to know. The difference I noted was that if I leave off the tag, I get the C name "gsl_matrix*" in the external representation of the pointer. If I use the tag, I can make it the more lispy "gsl-matrix*" or "gsl-matrix-pointer". Is that not a compelling reason to use it? In other words, is it a waste to do it except in the case you outlined?
What is the best way to use this to define a boolean test (e.g. gsl-matrix*?) for this type?
[...]
NULL converts to #f, if that's what you're asking.
That was not specifically my question, but it certainly points me in the right direction ;) Phrased in those terms I'm looking for a C procedure (macro?) that returns NULL for only the type I'm querying, i.e. returns anything other than NULL for the intialized datatype.
I'll think about this some more.
Thanks, Joel