David Nicol wrote: > On 5/9/07, Vadim <[EMAIL PROTECTED]> wrote: > >> I consider eval "$string" as a replacement of macros. > > > for instance, I did the following in a curl wrapper package, to make > the curlies optional around the fieldnames: > > BEGIN { for (qw/ > BUFFER CALLBACK DATA EVENT FAILURE FETCHTIMEOUT > GET MAXAGE MAXSTALE MESSAGE NOCACHE POST > READY STARTED UH URL USER/){ > eval <<FIELD; > sub $_ : lvalue { > \$_[0]->{$_} > } > FIELD > }} > > What would that look like in LISP? > I'm LISP novice (although met it some 15 years ago, now I'm more serious with our relationship at our second attempt :) :) so I can be easily wrong but my vision of your BEGIN block is:
(eval-when :when-compile (dolist (fname '(BUFFER CALLBACK ETCETERA)) (eval (read-from-string (format nil "(defun ~A () (do-something-useful))" fname))))) Why didn't you placed functions in AUTOLOAD, and creating them only when needed? My Tcl::Tk module do heavy usage of AUTOLOADing, you may want to look at the approach :) Initially I did "eval $string" but then come to safer approach. PS. now this *is* off-topic, sorry for that. I'll try to be more on-topic from now on :)