[Top][All Lists]

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

Re: I don't want to maintain this

From: Ludovic Courtès
Subject: Re: I don't want to maintain this
Date: Wed, 30 Nov 2005 14:46:14 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Bruce Korb <address@hidden> writes:

> Well, okay, I don't find the stuff obvious.  With effort, I'm sure
> I could puzzle it out.  I have never found Lisp to be inherently
> "obvious".

Oh, but things are different here: this is Scheme!  ;-)

Just out of curiosity: why are you writing Scheme if you don't like it?

> I extract the scheme code from a file.  Now, I have a string in memory
> and I want it eval-ed.  If I was reading your suggestion correctly,
> I would need to write that string to a real file.  I want to avoid
> that.  I want to hand that string, from memory, to Guile and tell
> Guile, "This string came from file XXX on line NNN."  (That is what
> the ag_scm_c_eval_string_from_file_line() does.)

While you're at reading Scheme code from a file, why not use Scheme
construct (be it from Scheme of C code) whose purpose are exactly that?
Consider the following excerpt:

  (with-input-from-file "chbouib.scm"

This will read a single balanced expression (S-exp) from "chbouib.scm"
and return it[0].  Additionally, Guile does something interesting: it
attaches to that returned S-exp information about its original location.
IOW, you can then use the source property API[1] with that S-exp to know
where it came from (file name, line number, etc.).

It seems to be exactly the kind of feature you are looking for, isn't
it?  What you are describing (reading a file into memory, asking Guile
to evaluate its content as a string, adding location information to it)
is just what Guile's `read' already does.



reply via email to

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