guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting source location information


From: Bruce Korb
Subject: Re: Getting source location information
Date: Wed, 30 Nov 2005 08:58:49 -0800
User-agent: KMail/1.7.1

On Wednesday 30 November 2005 08:04 am, Ludovic Courtès wrote:
*Thank you*, Ludvic!  Now we're getting some where.  :-D

> That the input file does not contain only Scheme source wasn't clear to
> me.

  What I am doing is extracting Scheme code from an encompassing
  template and handing it off for evaluation.

When I said that, I was meaning to say that the file was
not pure scheme code.

> Then, in fact, it would make sense to use `scm_c_eval_string ()', 
> provided your tool is able to determine the boundaries of the Scheme
> expression (if it's not, you'd better use `scm_read ()').

It is easily done.

> If you want to use source locations in a
> Guile-friendly way (so that Guile can, for instance, display location
> information in backtraces),

*YES* !!!

> then you may want to use 
> `scm_set_source_property_x (sexp, key, datum)' (where KEY may be one of
> SCM_SYM_FILENAME, SCM_SYM_LINE, SCM_SYM_COLUMN) which is defined in
> `srcprop.h'.

So, again, I need clarity.  Are you saying this:

  SCM res;
  SCM code = scm_from_locale_string (extracted_text);
  SCM file = scm_from_locale_string (file_name);
  SCM line = scm_from_int (line);
  scm_set_source_property_x (code, SCM_SYM_FILENAME, file);
  scm_set_source_property_x (code, SCM_SYM_LINE, line);
  res = scm_primitive_eval (code)

> But again, this is a problem (and a solution) relevant to your tool, not
> to Guile in general.

Well, actually, I disagree.  If any application wants to cope with
embedded Guile extensions in their input files, they either have to
solve this problem or else give up on being able to have Guile error
messages reference the source location.  My guess is is that other
folks just invoke scm_c_eval_string() and don't sweat the message
locations.  That is what I first did.  Then, I learned that getting
location information was possible.  However, the only way I could do
it was by writing a piece of obnoxious code that delved deep into the
bowels of Guile.  That was wrong, but more important than not having
file and line information.  Now, the 1.7 implementation has invalidated
portions of the non-deprecated 1.6 interface that I have been using.
I am forced to rewrite a lot of stuff as a consequence.  Here I am. :)

Thanks again for all your help.  Regards, Bruce




reply via email to

[Prev in Thread] Current Thread [Next in Thread]