Search found 35 matches

by danb
Thu Jul 31, 2008 12:23 pm
Forum: Common Lisp
Topic: reader macro communicating with a compile-time macro
Replies: 4
Views: 5969

Re: reader macro communicating with a compile-time macro

Harnon wrote:

Code: Select all

(let ((program-alternatives (gensym)))
  ...
Do you think this lexical variable would be fine?
I think so, as long as you make sure the function and the read macro are always (re)defined together.
by danb
Thu Jul 31, 2008 12:30 am
Forum: Common Lisp
Topic: reader macro communicating with a compile-time macro
Replies: 4
Views: 5969

Re: reader macro communicating with a compile-time macro

So, i'm trying to make a certain macro each 'case' in the argument to the with-program-cases macro has a slight different body, which is given by a list of different choices which is prefixed by the #? reader macro. I figured i would implement this by making the reader macro #? append the appropria...
by danb
Sat Jul 26, 2008 1:14 am
Forum: Common Lisp
Topic: Programming Style & (eval ...)
Replies: 17
Views: 22312

Re: Programming Style & (eval ...)

So my question, stated with the most precision I can muster at this stage of my learning, is, given that a macro seems to at most be able to refer to the text (so to speak) of its arguments, does that not necessarily mean that once one is using a macro (let's call it m ) which does not itself evalu...
by danb
Wed Jul 16, 2008 3:20 pm
Forum: Common Lisp
Topic: closures
Replies: 6
Views: 8875

Re: closures

what if you wanted two counters? You could do something like this: CL-USER 12 > (defun make-counter () (let ((count 0)) (lambda (operation) (case operation (increment (incf count)) (reset (setf count 0)) (otherwise (error "Unknown operation ~a" operation)))))) MAKE-COUNTER Or, at compile time: (def...
by danb
Tue Jul 15, 2008 8:00 pm
Forum: Common Lisp
Topic: question about recursion (easy)
Replies: 8
Views: 11343

Re: question about recursion (easy)

I now understand better how to implement left-hand side in Lisp with pure recursion instead of loops. Here's another way. It avoids both appending and reversing. (defun c-series (n a) (labels ((c-cons (i x) (unless (> i n) (cons x (c-cons (+ i 1) (if (oddp i) (log x) (* x x))))))) (c-cons 0 a)))