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] |
hi, SCM_ASSERT(SCM_NIMP(potential_smob) && SCM_CAR(potential_smob) == my_smob_tag, potential_smob, SCM_ARG1, "foo_function") you must check that the potential_smob is a non-immediate data type (using SCM_NIMP) prior to making any "finer distinctions". Check out Jim Blandy's excellent "Data Representation in Guile", available under the doc directory (as a texinfo file) in guile release 1.2.9*. There's a section, 1.2.3, entitled "Typechecking", that gives an example of how to typecheck a smob. Also, section 1.1.5, "Non-Immediate Data Types", may prove useful. Jay Glascoe jglascoe@jay.giss.nasa.gov On Fri, 16 Oct 1998, forcer wrote: > Hi there. > I'm currently facing a problem while writing an extension library for guile: > 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 immediate > 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? > -forcer > > -- > /* Computer programmers never die, they just get lost in the processing. */ > /* email: forcer@mindless.com -><- www: http://webserver.de/forcer/ */ > /* IRC: forcer@#StarWars (IRCnet) -><- PGP/GPG: available on my website */ >