On 16-10-2022 11:39, Paul Jarc wrote: > Hi. I'm updating some old code to work with newer versions of Guile. > This example used to work with 1.8, but gives an error with 2.2 and > later: > > (begin > (eval '(define-syntax-rule (rule x) x) (current-module)) > (display (rule "ok\n"))) > > ERROR: Wrong type to apply: # > > The error happens for define-syntax-rule and define-macro, but not > plain define. It happens when eval is within begin or let, but not at > the top level. Is there some way to make this work? In my real code, > the expression is read from a file, where it might be a macro > definition or anything else, and it's evaluated in a different module > from the current one. Surround (eval ...) by (eval-when (expand) ...). Section '(guile)Eval-when' explains the 'why'. Depending on where you are using 'rule' and what the real 'rule' is, you might need the other 'load' and 'eval' as well. IIUC, the previous 'lazy macros' (?) system of 1.8 (which didn't need the eval-when thing (?)) was rather impractical to do optimisation with, hence the more conventional 'eval-when' as found in other Schemes. Greetings, Maxime.