This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
forcer@mindless.com writes: > Hi there. > I'm currently facing a problem while writing an extension library for guil > e: > I created a smob, which i use extensively in the library, > but i don't know how to type-check for this smob. > Currently i'm checking wether ((long)gh_car(scm) == my_smob_tag), and if > not i'll throw an error. > The problem i encountered is that if a wrong object (that is, any immediat > e > type) it will bomb for obvious reasons (car will not point to anything > useful) > I tried to also do a gh_pair_p and scm_pair_p but both return 0/#f (which > is quite logical, you don't want a smob to be a pair for anyone but guile) > so now i'm on the search for a scm_smob_p. Any ideas? What you want to use is the SCM_NIMP(x) macro, which checks that x is a non-immediate type, guaranteeing that it has a car with a type tag in it. I think there is a template smob implementation somewhere on the Guile web site which tells you how to typecheck smobs correctly, among other things. - Maciej