Search found 43 matches

by garethw
Thu Aug 11, 2016 7:24 am
Forum: Common Lisp
Topic: RFC: mapcar with an index
Replies: 1
Views: 7059

RFC: mapcar with an index

Hi all, From time to time, I find myself wanting to use MAPCAR where the function would like to make use of the index. I've done it in some kind of stupid ways in the past, and then came up with this: (defun make-counter () (let ((count 0)) (lambda () (prog1 count (incf count))))) (defun make-counte...
by garethw
Thu Feb 04, 2016 8:09 am
Forum: Common Lisp
Topic: Is #S(quux ...) a literal?
Replies: 5
Views: 13333

Re: Is #S(quux ...) a literal?

FWIW, Fare agreed this is likely a bug.

Thanks for your help, Goheeca and pjstirling.
by garethw
Wed Feb 03, 2016 12:04 pm
Forum: Common Lisp
Topic: Is #S(quux ...) a literal?
Replies: 5
Views: 13333

Re: Is #S(quux ...) a literal?

Can you describe what SBCL is doing? I have right now installed pretty old version 1.1.12. It returns => (#S(QUUX :NAME "Guy")) Nevertheless, sharpsign syntax denotes a reader macro and that means it is by a standard way evaluated before the quasiquotation takes a place or in other words ...
by garethw
Tue Feb 02, 2016 9:52 pm
Forum: Common Lisp
Topic: Is #S(quux ...) a literal?
Replies: 5
Views: 13333

Is #S(quux ...) a literal?

Hi all, Given some structure, say: (defstruct quux name) is the following a "literal"? #S(quux :name "Guy") I ask because I was playing with OPTIMA, and wanted to use FARE-QUASIQUOTE for specifying patterns with backquotes, but FARE-QUASIQUOTE is not pleased: `(#S(quux :name &quo...
by garethw
Thu May 14, 2015 2:09 pm
Forum: Common Lisp
Topic: Establishing a condition handler at the REPL
Replies: 2
Views: 8650

Establishing a condition handler at the REPL

Is it possible to establish a condition handler at the REPL in such a way that it can handle conditions that occur at the REPL? So, for example, if I were sitting at my SLIME prompt, and I tried to evaluate CL-USER> (foo) where #'foo was not bound, I'd like to be able to effectively handle it by cal...
by garethw
Mon Mar 17, 2014 8:12 pm
Forum: Common Lisp
Topic: Help on elusive CLHS symbol
Replies: 3
Views: 6762

Re: Help on elusive CLHS symbol

It was indeed PROGV.

Thank you, both.
by garethw
Sun Mar 16, 2014 7:46 pm
Forum: Common Lisp
Topic: Help on elusive CLHS symbol
Replies: 3
Views: 6762

Help on elusive CLHS symbol

A few weeks back, I stumbled on an interesting entry in the CLHS dictionary. Seems I didn't bookmark it, and I can't for the life of me remember what it was called. I *think* that what it did was created a set of lexical bindings from a list of symbols. I believe that the description said it could b...
by garethw
Sun Feb 02, 2014 7:46 pm
Forum: Common Lisp
Topic: Macro function executed twice in SBCL
Replies: 4
Views: 9104

Re: Macro function executed twice in SBCL

The short answer is: Don't do that! :) ... Now, back to the general point, relying on side-effects in macro-expander functions is the wrong thing, as I said above the expander may be run all over the place, but also, if your code is compiled and saved to a fasl file, then when you load the fasl int...
by garethw
Thu Jan 30, 2014 8:09 pm
Forum: Common Lisp
Topic: Macro function executed twice in SBCL
Replies: 4
Views: 9104

Macro function executed twice in SBCL

Hi all, I was wondering if someone could explain this SBCL behaviour to me. I have a macro that appears to be executed twice. First, something that works just fine: (defmacro heaven () (print "Everything is fine.") 100) => HEAVEN (heaven) "Everything is fine." =>100 But if I retu...
by garethw
Fri Nov 15, 2013 10:34 pm
Forum: Common Lisp
Topic: macro-friendly equivalent of APPLY
Replies: 10
Views: 22014

Re: macro-friendly equivalent of APPLY

This can be even simplified to: (defmacro plus (&rest args) `(+ ,@(mapcar #'arg-dispatcher args))) CL-USER> (macroexpand-1 '(plus "one" "two" "three")) (+ 1 2 3) T CL-USER> (plus "one" "two" "three") 6 Using an argument dispatcher also...