cisco/ChezScheme

cp0 improvement: kill `call/cc` when the captured procedure is never invoked

Closed this issue · 1 comments

dpk commented

Chez 10.0.0:

> (expand/optimize '(lambda () (call/cc (lambda (k) 'foo))))
(lambda ()
  (#2%call/cc
    (lambda (#{k hjfex6sqm22nfqdreunm4v2sg-0}) 'foo)))

Perhaps there is some reason why this optimization is not sound in the general case, but at least here, when call/cc is invoked but the captured continuation is provably never invoked, the call/cc can be killed. That example should optimize to:

(lambda () 'foo)

(Alternatively, maybe this optimization happens later on. That would be useful to know, too.)

This was completed in b631337 and can be closed.