Convince me not to use eval



So I'm new to LISP and even more-so to macros (as you can see by my
recent posts), but I know enough or have read enough to know that if
you're using eval, you're doing something wrong.

The macro takes a directory name and a filename (it's meant to be
called in a loop) and creates a global variable using defparameter
that is the filename with the 3rd character replaced with a '-' and
affixed with a '*' on either side. I'm using ltk (lisp wrapper for
TK) and then take this new variable and load the actual filename onto
it.

And hey while we're at it - I hate to hardcode and would like to
replace the
(setf (aref var-name 2) #\-) line to something that replaces the last
(or all) '.' in a string with a '-' easily. If you know one, let me
in on that too.

Well here's my code, and I cannot figure out how to get around using
eval:

(defmacro make-gif (dirname filename)
`(let ((var-name (string-upcase ,filename)))
(setf (aref var-name 2) #\-)
(setf var-name (concatenate 'string "*" var-name "*"))
(format t "var-name: ~a filename: ~a dirname:~a~%"
var-name ,filename ,dirname)
(eval `(defparameter ,(intern var-name) (make-image)))
(eval `(image-load
,(intern var-name)
,(concatenate 'string ,dirname ,filename)))))

Thanks * Infinity,
JW

.



Relevant Pages

  • Re: Convince me not to use eval
    ... The macro takes a directory name and a filename (it's meant to be ... manipulate symbols/identifiers in Lisp is much greater than in other ... TK) and then take this new variable and load the actual filename onto ... Look ma, no EVALs. ...
    (comp.lang.lisp)
  • Re: Automating creation of a PDF document from Word via VBA
    ... with the "original" macros back in the Days of DOS. ... > the filename I see no way to ... > by-pass that without access to the Adobe code. ... > Word MVP web site http://word.mvps.org ...
    (microsoft.public.word.docmanagement)
  • Re: Importing a text file into Excel with too many rows?
    ... Dim ResultStr As String ... FileName = InputBox("Please enter the Text File's name, ... If you are not familiar with macros, you may wish to visit David McRitchie's ...
    (microsoft.public.excel.misc)
  • Re: A "killer" macro
    ... (with-input-file (in filename) ... Because of indentation issues. ... for the issues surrounding why people write macros and yet why it's useful ... when the do-something is ...
    (comp.lang.lisp)
  • Re: How do you set up a macro that lists filename and path?
    ... In your Tools/Customize dialog box on the Commands tab locate the ... Then locate "Filename and path" on the right. ... MVP FAQ site: http://mvps.org/ ... I have set up several other macros today - so I am ...
    (microsoft.public.word.docmanagement)