This is the mail archive of the 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]

Re: implementing data tags via object properties -- help with debugging? (Robert Brown) writes:

> [Note: I'm resending this because I got no response.  Perhaps my change in
>  subject will attract people's attention...]

OK, I'll bite.

> I cannot get this tag stuff to work (see my message "global variables &
> data tags") and was hoping someone could help me debug it.  For some
> reason, every time I call gh_get_tag_data() (see below), I receive a
> different (and seemingly random) value.  And I assume that that's because
> gh_eval_str() is returning a different SCM object each time I call it,
> even if I call it with the same string.

Have you checked that you get a different value each time from
gh_eval_str()?  If not, I suggest adding a printf of the SCM value,
which will determine whether this is true.  From examining the code, I
think that you would get the same value each time.

One thing that I wonder about, is whether scm_intern() and
gh_eval_str() are both working in the same module.  If they are, then
you should have no problem.  I know that scm_intern() does it's work
in 'the-root-module'.  I suspect that gh_eval_str() might do it's work
in '(guile-user)'.  If so, then this could be the source of the
problem.  Given my limited time at the moment, I don't want to write a
test program right now, but I suggest you give it a spin.

> I tried stepping through the code, but what the SCM/Guile
> interpreter is doing is mystifying.  So, I don't understand its
> return values.

You should not need to step through the interpreter.  If I understand
your question, you are trying to associate a void* with a SCM object,
and then given the SCM object, you want to be able to retreive the

I could be wrong about what you are trying to achieve, if so, please
correct me.

But anyway, this can be done with a smob that wraps the void*, much as
you have done, but without the name field, which should be
unnecessary, and a weak hash table.  Remember to call scm_protect_obj
on the weak hash table.

After reading some code, it appears that this is what the object
properties stuff is doing, anyway.


"Whenever you find yourself on the side of the majority, it is time to
pause and reflect."
             -- Mark Twain

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]