Search found 4 matches

by Dolda
Mon Mar 29, 2010 6:44 pm
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32380

Re: What little functions/macros do you use?

I can see your point about (loop while (...)) does the job of while. I guess I just avoid keyworded LOOPs like the plague. I find the syntax so un-Lisp-like. :)
by Dolda
Mon Mar 29, 2010 6:12 pm
Forum: Common Lisp
Topic: Local variables with indefinite extent?
Replies: 10
Views: 8750

Re: Local variables with indefinite extent?

I can't believe I didn't even think of just using LET. But, well, that brain fart aside, there are reasons to avoid it. In particular, the LET has to be outside the function being declared, which makes it difficult to use in macros. What I have in mind, in the end, is the ability to do something lik...
by Dolda
Sun Mar 28, 2010 7:28 pm
Forum: Common Lisp
Topic: Local variables with indefinite extent?
Replies: 10
Views: 8750

Local variables with indefinite extent?

Hi forum, What would be the reasonable way to create a function-local variable with indefinite extent; i.e. that keeps its value between invocations of the function? The "function-local" part isn't really critical, of course, as long as it doesn't dirty the namespace otherwise. My naive im...
by Dolda
Sun Mar 28, 2010 7:08 pm
Forum: Common Lisp
Topic: What little functions/macros do you use?
Replies: 23
Views: 32380

Re: What little functions/macros do you use?

I quite enjoy these ones. An augmentation of unwind-protect makes it easy to e.g. open sockets or X displays, initialize them, and clean up if unsuccessful: (defmacro abnormal-protect (protected &body cleanup) (with-gensyms (done) `(let ((,done nil)) (unwind-protect (prog1 ,protected (setf ,done...