Opened 3 years ago
Closed 13 months ago
#1765 closed defect (worksforme)
enable-warnings time-travelling shenanigans
Reported by: | Idiomdrottning | Owned by: | |
---|---|---|---|
Priority: | not urgent at all | Milestone: | someday |
Component: | unknown | Version: | 5.2.0 |
Keywords: | REPL | Cc: | |
Estimated difficulty: |
Description
(import miscmacros (chicken condition))
(define-syntax-rule
(bound-procedure? name)
(handle-exceptions
ex
#f
(procedure? name)))
(enable-warnings #f)
(define wtf (bound-procedure? if))
(enable-warnings #t)
wtf
;; ↑↑ quietly and politely evals to #f
(begin
(enable-warnings #f)
(define wtf (bound-procedure? if))
(enable-warnings #t)
wtf)
;; ↑↑ expands to a let form (which is fine of course) and complains in
;; the REPL because warnings apply retroactively to the entire form.
I've tried enabling the warnings via (let ((ret ...)) enable ret) dynamic-wind or via force/delay or via just a lambda that gets called, but no matter how I do it, it retroactively wants to print warnings.
I even did
(define (re-enable-warnings val ret)
(enable-warnings val)
ret)
(re-enable-warnings #f (bound-procedure? if))
;;; politely evals to #f
(re-enable-warnings #t (bound-procedure? if))
;;; causes a ruckus
The time travelling super powers of call-with-current-continuation that the REPL uses is haunting me…!
This just can't be right!
Change History (3)
comment:1 Changed 3 years ago by
comment:2 Changed 3 years ago by
Priority: | major → not urgent at all |
---|
comment:3 Changed 13 months ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
The "begin" for is expanded before the enable-warnings parameter is changed, this is simply because expansion time precedes run-time. You need to define syntax here that performs the parameter-change at expansion time.
Oh, ignore-errors already exist so forget my custom bound-procedure.
Here is an already miscmacros-established way to get the same weird behavior:
(import miscmacros)
(enable-warnings #f)
(define wtf (ignore-errors (procedure? if)))
(enable-warnings #t)
wtf
;; politely evals #f
(begin
;; notices at the REPL