(defun bind-eval (vars values code)
(let* ((src (format nil "(lambda ~a ~a)" vars code))
(fun (eval (read-from-string src))))
(apply fun values)))
(defmacro ceval (vars code)
(loop :for var :in vars
:collect var :into vars
:collect var :into values
:finally (return
`(bind-eval (quote ,vars)
(list ,@values)
,code))))
(defun test (x)
(let ((y 1))
(ceval (y) x)))
(print (test 'y))
KGRlZnVuIGJpbmQtZXZhbCAodmFycyB2YWx1ZXMgY29kZSkKICAobGV0KiAoKHNyYyAoZm9ybWF0IG5pbCAiKGxhbWJkYSB+YSB+YSkiIHZhcnMgY29kZSkpCiAgICAgICAgIChmdW4gKGV2YWwgKHJlYWQtZnJvbS1zdHJpbmcgc3JjKSkpKQogICAgKGFwcGx5IGZ1biB2YWx1ZXMpKSkKCihkZWZtYWNybyBjZXZhbCAodmFycyBjb2RlKQogIChsb29wIDpmb3IgdmFyIDppbiB2YXJzCiAgICAgICAgOmNvbGxlY3QgdmFyIDppbnRvIHZhcnMKICAgICAgICA6Y29sbGVjdCB2YXIgOmludG8gdmFsdWVzCiAgICAgICAgOmZpbmFsbHkgKHJldHVybgogICAgICAgICAgICAgICAgICBgKGJpbmQtZXZhbCAocXVvdGUgLHZhcnMpCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChsaXN0ICAsQHZhbHVlcykKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLGNvZGUpKSkpCgooZGVmdW4gdGVzdCAoeCkKICAobGV0ICgoeSAxKSkKICAgIChjZXZhbCAoeSkgeCkpKQoKKHByaW50ICh0ZXN0ICd5KSk=