From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dirk Herrmann Newsgroups: gmane.lisp.guile.devel Subject: memoization and error messages Date: Sun, 24 Nov 2002 11:43:15 +0100 (CET) Sender: guile-devel-admin@gnu.org Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1038134638 25431 80.91.224.249 (24 Nov 2002 10:43:58 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 24 Nov 2002 10:43:58 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18FuF2-0006by-00 for ; Sun, 24 Nov 2002 11:43:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18FuFC-0006sJ-00; Sun, 24 Nov 2002 05:44:06 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18FuER-00069P-00 for guile-devel@gnu.org; Sun, 24 Nov 2002 05:43:19 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18FuEP-00066O-00 for guile-devel@gnu.org; Sun, 24 Nov 2002 05:43:18 -0500 Original-Received: from sallust.ida.ing.tu-bs.de ([134.169.132.52]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18FuEO-000632-00 for guile-devel@gnu.org; Sun, 24 Nov 2002 05:43:16 -0500 Original-Received: from localhost (dirk@localhost) by sallust.ida.ing.tu-bs.de (8.9.3+Sun/8.9.1) with ESMTP id LAA28143 for ; Sun, 24 Nov 2002 11:43:15 +0100 (CET) Original-To: guile-devel@gnu.org Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1750 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1750 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 # 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) #] : In procedure memoization in expression (eval (quote #) (interaction-environment)): : 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)) #] ?: 1* [if (if #t (foo . bar)) (#)] : In procedure memoization in expression (eval (quote #) (interaction-environment)): : 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 #))) #] ?: 1* [if (if #t (if #t (if #t #))) (#)] ?: 2* [if (if #t (if #t (foo . bar))) (#)] ?: 3* [if (if #t (foo . bar)) (#)] 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