[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 3 readline bugs: source positions, readline-options, endless loop on
From: |
Martin Grabmueller |
Subject: |
Re: 3 readline bugs: source positions, readline-options, endless loop on error |
Date: |
Thu, 25 Jan 2001 22:46:10 +0100 |
> Date: Thu, 25 Jan 2001 13:06:59 +0100 (MET)
> From: Dirk Herrmann <address@hidden>
>
> On Thu, 25 Jan 2001, Martin Grabmueller wrote:
>
> > > Date: Thu, 25 Jan 2001 11:41:31 +0100 (MET)
> > > From: Dirk Herrmann <address@hidden>
> > >
> > > On Thu, 25 Jan 2001, Martin Grabmueller wrote:
> > >
> > > > The next problem is that with readline, you don't get source positions
> > > > in error messages. The reason is that the readline port created by
> > > > `make-readline-port' (readline.scm) is not given a file name. The
> > > > following patch fixes the problem for simple cases, but not when
> > > > calling `set-readline-input-port!', which should also copy the
> > > > filename; but I am not sure how to test this procedure.
> > > >
> > > > Maybe this problem is not worth fixing anyway, because the filename is
> > > > always `standard input'.
> > >
> > > I think the problem has to be solved differently: Why should the output
> > > of source positions be dependent of the existence of a filename for an
> > > input port? This does not make sense, for example for string ports.
> > > Thus, I suggest to display source positions independent of whether the
> > > port has an associated file name. If no file name was given, the error
> > > message can use a default string like "<unnamed port>". Or, rather one
> > > could think of storing the port with the source properties instead of a
> > > filename.
> >
> > Your first suggestion is easy to implement and only requires hacking
> > display_header in backtrace.c. I could provide a patch for that.
>
> Yes, that would be nice.
I started to work on the patch, but I got pretty confused. Maybe this
is due to my understanding of the term `memoization'.
I take the discussion to guile-devel, so that someone may enlighten me.
It seems that `memoization' is used for two different concepts:
- Rewriting code expressions to a more efficient internal
representation, like syntax expressions, glocs, ilocs, etc.
- For remembering the positions of source expressions.
So I thought that the macro SCM_MEMOIZEDP indicates whether a source
position has been remembered in the source position hash, and I
changed display_header in backtrace.c to print the filename if that
predicate was true for an expression, and ERROR otherwise.
The new code then tried to print #f as a fixnum, resulting in funny
error messages, until I found out that even expressions without source
positions satisfied the predicate.
With added tests, I got the following patch, but I am not sure whether
it really is The Right Thing. It enables error positions for readline
and string ports, so it is at least A Useful Thing:
guile> (with-input-from-string "\n\n(asas)" (lambda () (eval (read)
(interaction-environment))))
<unnamed port>:3:1: In expression (asas):
<unnamed port>:3:1: Unbound variable: asas
ABORT: (unbound-variable)
Patch follows:
Index: backtrace.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/backtrace.c,v
retrieving revision 1.58
diff -u -r1.58 backtrace.c
--- backtrace.c 2001/01/24 15:58:46 1.58
+++ backtrace.c 2001/01/25 21:46:57
@@ -86,20 +86,25 @@
static void
display_header (SCM source, SCM port)
{
- SCM fname = (SCM_MEMOIZEDP (source)
- ? scm_source_property (source, scm_sym_filename)
- : SCM_BOOL_F);
- if (SCM_STRINGP (fname))
+ int memoized = SCM_MEMOIZEDP (source);
+
+ if (memoized)
{
- scm_prin1 (fname, port, 0);
- scm_putc (':', port);
- scm_intprint (SCM_INUM (scm_source_property (source, scm_sym_line)) + 1,
- 10,
- port);
- scm_putc (':', port);
- scm_intprint (SCM_INUM (scm_source_property (source, scm_sym_column)) +
1,
- 10,
- port);
+ SCM fname = scm_source_property (source, scm_sym_filename);
+ SCM line = scm_source_property (source, scm_sym_line);
+ SCM col = scm_source_property (source, scm_sym_column);
+
+ if (SCM_STRINGP (fname))
+ scm_prin1 (fname, port, 0);
+ else
+ scm_puts ("<unnamed port>", port);
+ if (SCM_NFALSEP (line) && SCM_NFALSEP (col))
+ {
+ scm_putc (':', port);
+ scm_intprint (SCM_INUM (line) + 1, 10, port);
+ scm_putc (':', port);
+ scm_intprint (SCM_INUM (col) + 1, 10, port);
+ }
}
else
scm_puts ("ERROR", port);
--
Martin Grabmueller address@hidden
http://www.pintus.de/mgrabmue/ address@hidden on EFnet
- Re: 3 readline bugs: source positions, readline-options, endless loop on error,
Martin Grabmueller <=