Name: Anonymous 2013-08-06 1:50
What are the good and bad things about Ruby, in your opinion?
(defmacro define-with-macro (name allocate-func cleanup-func)
`(defmacro ,name ((var-name &optional initial-value) &body body)
`(let ((,var-name (,',allocate-func ,initial-value)))
(unwind-protect
,@body)
(,',cleanup-func ,var-name))))
(define-with-macro with-file open close)
(with-file (in "/Users/erik/test.txt")
(print (read-line in)))
=> "XMJYAUZ;MZJAWXU"
(macroexpand '(with-file (in "/Users/erik/test.txt")
(print (read-line in))))
(LET ((IN (OPEN "/Users/erik/test.txt")))
(UNWIND-PROTECT (PRINT (READ-LINE IN)))
(CLOSE IN))