[Top][All Lists]

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

Set source property on an evaluated expression

From: Neil Jerram
Subject: Set source property on an evaluated expression
Date: Tue, 31 May 2005 19:56:43 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

In 1.6.7, given these tests -

(with-test-prefix "set-source-property!"
  (read-enable 'positions)
  (let ((s (read (open-input-string "(display \"\")"))))

    (pass-if "set-source-property! before eval"
      (set-source-property! s 'test-sym 10)
      (eval s the-scm-module)

    (pass-if "set-source-property! after eval"
      (hash-fold (lambda (x props acc)
                   (if (eq? (source-property x 'test-sym) 10)
                       (set-source-property! x 'test-sym 11)))

- the second test fails because set-source-property! throws a wrong-type-arg exception, which is because the car of x has been memoized to a gloc: in other words, x is now (address@hidden ""), not (display "").

A fix is to change the 3 occurrences of SCM_NCONSP in srcprop.c to SCM_NECONSP, as SCM_ECONSP allows both normal pairs and those in which the car is a gloc, whereas SCM_CONSP only allows normal pairs. However, comments in the 1.6 code suggest that the design w.r.t. glocs is that they should never be visible on the Scheme level, so this may not be the best fix. Instead, the real problem theoretically speaking may be that the source-whash (which is Scheme-accessible) contains glocs.

I suspect that it would be hard to remove glocs from the source-whash. Given that the source-whash is only of interest to people writing debugging tools (i.e. probably just me), I propose that the SCM_NECONSP fix is good enough in practice, and would like to release it into 1.6.x. Any objections?

(In 1.8 glocs have been removed, so I presume there is no analogous problem there.)

(Curiously, the first quarter of this fix was made in 1999:

1999-09-12  Mikael Djurfeldt  <address@hidden>


        * srcprop.c (scm_source_property): Bugfix: Use SCM_NECONSP instead
        of SCM_NCONSP.  (Thanks to Greg Badros.)


reply via email to

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