From: Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de>
Subject: memoization and error messages
Date: Sun, 24 Nov 2002 11:43:15 +0100 (CET) [thread overview]
Message-ID: <Pine.GSO.4.05.10211240903440.27851-100000@sallust.ida.ing.tu-bs.de> (raw)
Hi folks,
since yesterday I have made some progress with the memoizer, I just feel
like showing you :-))) I will show you some transcripts of how my
modified version of guile works, with some explanations. The focus of
this mail is on error messages for syntax errors. Part of this mail is
for showing you things that already work (and how they work), some parts
indicate open points. In general, the handling of syntax errors is not
perfect yet, but its a start.
1) Syntactic keywords are no longer accepted as expressions. Formerly,
guile would have accepted the following:
guile> define
#<macro 4020ada0>
But now, the correct position of syntactic keywords is checked by the
memoizer:
guile> define
ERROR: In procedure memoization:
ERROR: Misplaced syntactic keyword define.
ABORT: (syntax-error)
2) Error messages are, where possible, more explicit:
guile> (if)
ERROR: In procedure memoization:
ERROR: In line 1: Missing or extra expression in (if).
ABORT: (syntax-error)
***
guile> (lambda (a a) #t)
ERROR: In procedure memoization:
ERROR: In line 2: Duplicate formal a in expression (lambda (a a) #t).
ABORT: (syntax-error)
***
guile> (lambda (1 a) #t)
ERROR: In procedure memoization:
ERROR: In line 3: Bad formal 1 in expression (lambda (1 a) #t).
ABORT: (syntax-error)
***
guile> ()
ERROR: In procedure memoization:
ERROR: Illegal empty combination ().
ABORT: (syntax-error)
It should be noted, that checks for the empty combination () were formerly
done during evaluation. Now, these checks are removed from the evaluator!
The bad thing with this example is, that information about line numbers
can't be issued for expressions that are no lists. Since () is an
immediate value, there is no linenumber information available. Currently,
it also doesn't work for the following example:
guile> (foo () bar)
ERROR: In procedure memoization:
ERROR: Illegal empty combination ().
ABORT: (syntax-error)
although here at least the line number of the outer expression could be
printed. This, however, requires to carry a stack of outer expressions
around while doing memoization. This is not implemented yet, but could
certainly be done. I will add this feature eventually.
***
guile> (foo . bar)
ERROR: In procedure memoization:
ERROR: In line 7: Bad expression (foo . bar).
ABORT: (syntax-error)
Expressions are always checked to be proper lists during memoization.
Please note: The example above shows that if a linenumber is available it
is printed.
3) Bad expressions are detected before evaluating the code!
guile> (define (foo) (foo . bar))
ERROR: In procedure memoization:
ERROR: In line 10: Bad expression (foo . bar).
ABORT: (syntax-error)
Formerly, this error would have remained undetected until foo was actually
executed.
4) Backtraces are somewhat strange. Compare the following backtraces:
guile> (eval '(foo . bar) (interaction-environment))
Backtrace:
In unknown file:
?: 0* [eval (foo . bar) #<directory (guile-user) 8051a40>]
<unnamed port>: In procedure memoization in expression (eval (quote #) (interaction-environment)):
<unnamed port>: In line 0: Bad expression (foo . bar).
ABORT: (syntax-error)
*****
guile> (eval '(if #t (foo . bar)) (interaction-environment))
Backtrace:
In unknown file:
?: 0* [eval (if #t (foo . bar)) #<directory (guile-user) 8051a40>]
?: 1* [if (if #t (foo . bar)) (#<eval-closure 40271520>)]
<unnamed port>: In procedure memoization in expression (eval (quote #) (interaction-environment)):
<unnamed port>: In line 1: Bad expression (foo . bar).
ABORT: (syntax-error)
*****
guile> (eval '(if #t (if #t (if #t (foo . bar)))) (interaction-environment))
Backtrace:
In unknown file:
?: 0* [eval (if #t (if #t (if #t #))) #<directory (guile-user) 8051a40>]
?: 1* [if (if #t (if #t (if #t #))) (#<eval-closure 40271520>)]
?: 2* [if (if #t (if #t (foo . bar))) (#<eval-closure 40271520>)]
?: 3* [if (if #t (foo . bar)) (#<eval-closure 40271520>)]
ERROR: In procedure memoization:
ERROR: In line 2: Bad expression (foo . bar).
ABORT: (syntax-error)
What surprises me is that with every additional (if #t ...) I get another
backtrace frame displayed. But, within the memoizer I am pretty sure that
I don't add backtrace information for the debugger. If someone knows how
backtraces are computed, I would appreciate that information.
As you see, there are still some open points with respect to reporting
syntax errors. But I also hope that you see that a separation of
memoization and execution also brings benefits with respect to early error
detection. And, it should be obvious that the executor benefits from the
fact that all syntax checks are done in advance.
Please let me know if you can help in any of the open points above. And,
certainly, if you have suggestions for improvement of the above style of
error reporting.
Best regards,
Dirk Herrmann
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2002-11-24 10:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-24 10:43 Dirk Herrmann [this message]
2002-11-24 12:57 ` memoization and error messages tomas
2002-11-24 16:49 ` Dirk Herrmann
2002-11-24 22:25 ` Daniel Skarda
2002-11-28 18:02 ` Dirk Herrmann
2002-12-02 20:45 ` Daniel Skarda
2002-12-03 0:09 ` Lynn Winebarger
2002-11-26 10:42 ` tomas
2002-11-28 19:34 ` Neil Jerram
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.05.10211240903440.27851-100000@sallust.ida.ing.tu-bs.de \
--to=dirk@sallust.ida.ing.tu-bs.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).