guile-user
[Top][All Lists]
Advanced

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

Re: macro like "my" in Perl


From: Neil Jerram
Subject: Re: macro like "my" in Perl
Date: 13 Jul 2002 01:09:28 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Paul" == Paul Jarc <address@hidden> writes:

    Paul> I don't suppose there's any way to find line numbers for the error
    Paul> message, is there?

Yes, assuming that you haven't disabled the recording of source
properties.

Anything that created a pair (or list, or improper list ...) when it
was read has the filename, line and column number of the pair's
opening parenthesis recorded as a `source property'.

Here's an example of how to access the information.

guile> (define-macro (list-no-pairs . elements)
         (let loop ((elts elements))
           (if (null? elts)
               (cons 'list elements)
               (if (pair? (car elts))
                   (error (format #f "Bad element ~S at ~A:~A:~A"
                                     (car elts)
                                     (source-property (car elts) 'filename)
                                     (source-property (car elts) 'line)
                                     (source-property (car elts) 'column)))
                   (loop (cdr elts))))))
guile> (list-no-pairs 1 2 3)
(1 2 3)
guile> (list-no-pairs 1 (2 2) 3)
standard input:25:20: In procedure error in expression (error (format #f "Bad 
element ~S at ~A:~A:~A" ...)):
standard input:25:20: Bad element (2 2) at standard input:36:17
ABORT: (misc-error)
guile> 

        Neil




reply via email to

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