Ticket #1097 (closed defect: notabug)

Opened 4 years ago

Last modified 4 years ago

function watch documentation error

Reported by: drunkedcat Owned by:
Priority: normal Milestone:
Component: Documentation Version: trunk
Keywords: Cc:


The documentation of function 'watch' is wrong. It says

? (defvar *s* "xxxxx") *S* ? (watch *s*) "xxxxx"

but it should be ======= ? (watch (quote *s*)) =======

Change History

comment:2 Changed 4 years ago by rme

  • Status changed from new to closed
  • Resolution set to notabug

The example is correct. The example is trying to show that you can watch the contents of a string (which is just a vector of characters) for modification. In the example, *s* is just a reference to the string object; watch is concerned with modifications to data objects, not bindings.

Saying (watch '*s*) would indicate that you want to watch the symbol object itself. This may be useful in restricted circumstances, but if *s* were lambda-bound (via let/lambda/progv), then watch wouldn't notice modifications to *s*'s value cell.

For example (on a 32-bit system):

(defparameter *x* 3)
(watch '*x*)
(let ((*x* *x*))
  (setq *x* 100))
=> 100
=> 3  (and watch doesn't signal)

Additionally (as you mention in ticket:1098), on 64-bit systems, symbols are not exactly uvectors, so watch doesn't know what to do with them. I could probably make watch handle symbols specially, but I'm not sure it would be worth the trouble. If you really want that, please make an enhancement ticket for it.

Note: See TracTickets for help on using tickets.