[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Source properties on arbitrary non-immediate values
From: |
Ludovic Courtès |
Subject: |
Re: [PATCH] Source properties on arbitrary non-immediate values |
Date: |
Mon, 10 Oct 2005 14:10:22 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
Neil Jerram <address@hidden> writes:
> Kevin Ryde <address@hidden> writes:
>> A symbol used in two places is the same object, so file/line attached
>> by both occurrances will overwrite, or whatever. Ditto other uniques
>> like keywords, and immediates like fixnums and chars.
Symbols and strings are different from immediates. What you say is true
for symbols, not for strings:
guile> (define x 'sym)
guile> (define y 'sym)
guile> (set-source-properties! x '((hello . world)))
((hello . world))
guile> (source-properties y)
((hello . world))
guile> (define x "str")
guile> (define y "str")
guile> (set-source-properties! x '((hello . world)))
((hello . world))
guile> (source-properties y)
()
This is because (1) `source-properties' looks up objects using
`hashq-ref' (and, therefore, `eq?'), and (2) because `eq?' behaves
differently on symbols than on strings (quoting R5RS):
`Eq?' and `eqv?' are guaranteed to have the same behavior on
symbols, booleans, the empty list, pairs, procedures, and non-empty
strings and vectors.
In particular, `(eq? "a" "a")' returns `#f' with Guile.
> Indeed. What was your motivation for wanting to attach source
> properties to non-pairs, though?
Well, the manual doesn't mention this restriction and, rather than
fixing the manual, I wanted to understand the rationale behind this
restriction.
I see no reason not to allow source properties to be attached to
arbitrary non-immediates. The fact that this "won't work" for symbols
is not, IMO, a sufficiently good reason to the current restriction. For
instance, one might want to have the following definition of `eval':
(let ((real-eval eval))
(set! eval
(lambda (expr env)
(let ((props (source-properties expr))
(result (real-eval expr env)))
(if (or (vector? result) (record? result) (pair? result))
(set-source-properties! result props))
result))))
This allows to keep source information further at run-time.
Thanks,
Ludovic.
- [PATCH] Source properties on arbitrary non-immediate values, Ludovic Courtès, 2005/10/07
- Re: [PATCH] Source properties on arbitrary non-immediate values, Kevin Ryde, 2005/10/07
- Re: [PATCH] Source properties on arbitrary non-immediate values, Neil Jerram, 2005/10/08
- Re: [PATCH] Source properties on arbitrary non-immediate values,
Ludovic Courtès <=
- Re: [PATCH] Source properties on arbitrary non-immediate values, Neil Jerram, 2005/10/10
- Re: [PATCH] Source properties on arbitrary non-immediate values, Ludovic Courtès, 2005/10/11
- Re: [PATCH] Source properties on arbitrary non-immediate values, Neil Jerram, 2005/10/11
- Re: [PATCH] Source properties on arbitrary non-immediate values, Ludovic Courtès, 2005/10/12
- Re: [PATCH] Source properties on arbitrary non-immediate values, Neil Jerram, 2005/10/15
- Re: [PATCH] Source properties on arbitrary non-immediate values, Neil Jerram, 2005/10/15
- Re: [PATCH] Source properties on arbitrary non-immediate values, Ludovic Courtès, 2005/10/17
- Re: [PATCH] Source properties on arbitrary non-immediate values, Kevin Ryde, 2005/10/10
- Re: [PATCH] Source properties on arbitrary non-immediate values, Ludovic Courtès, 2005/10/11