Summary

enable-warnings time-travelling shenanigans

Metadata

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!

Changes and comments

[2021-06-12 12:56:42 UTC] Idiomdrottning wrote:

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

(enable-warnings #f)
(define wtf (ignore-errors (procedure? if)))
(enable-warnings #t)
wtf)
; notices at the REPL

[2021-06-12 13:08:09 UTC] Idiomdrottning changed priority from major to not urgent at all

[2023-11-06 23:57:03 UTC] felix changed status from new to closed

[2023-11-06 23:57:03 UTC] felix set resolution to worksforme

[2023-11-06 23:57:03 UTC] felix wrote:

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.