Neil Jerram <[EMAIL PROTECTED]> writes: > Kevin Ryde <[EMAIL PROTECTED]> 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. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel