I saw an interesting bug today. Can you guess the cause of this error? ERROR: In procedure memoization: ERROR: Bad formal #...@0+0 in expression (lambda (#...@0+0) (apply (lambda (#{filename\ 2520}# #{proc\ 2521}# #{reference\ 2522}#) (let ((#{template\ 2523}# (string-append #{filename\ 2520}# ".XXXXXX"))) (let ((#{tmp\ 2524}# #)) (call-once (lambda () #))))) #...@0+0)).
The reason is that the expansion of `(cond (foo => (apply (lambda (args) ,x) args))) Is something like (list 'cond (list 'foo '=> (cons 'apply (cons (list 'lambda '(args) x) '(args))))) The '(args) is duplicated, the compiler notices that, and stores it only once. When the memoizer processes the '(args) *argument* it memoizes args to point to its lexical location (#...@0+0; I didn't show the let in my example). But that side-effects the formals of the lambda too! Yet another reason to replace the evaluator... A -- http://wingolog.org/