Search found 94 matches

by Kompottkin
Fri Mar 02, 2012 3:20 am
Forum: Common Lisp
Topic: Create a method dynamically for an instance of a class
Replies: 4
Views: 6571

Re: Create a method dynamically for an instance of a class

Sheeple is fun.

In case you happen to be using Clozure CL, you might want to use my fork, which contains a Clozure CL 1.7 workaround that hasn't yet been merged into mainline.

Alternatively, execute

Code: Select all

(setq cl:*print-pprint-dispatch* (copy-pprint-dispatch nil))
before loading Sheeple.
by Kompottkin
Fri Feb 24, 2012 8:50 am
Forum: Common Lisp
Topic: Optimizing speed and fixnum literal
Replies: 7
Views: 11897

Re: Optimizing speed and fixnum literal

Actually, that is not quite accurate. If M was declared to be a fixnum, SBCL would still be able to optimize the call (* 3 m) (see the note that says that SBCL could optimize it if the first argument to - was a (SIGNED-BYTE 64). AFAICT, fixnums are 63 bits wide on AMD64. (The SBCL internals wiki cl...
by Kompottkin
Thu Feb 23, 2012 6:24 pm
Forum: Common Lisp
Topic: Optimizing speed and fixnum literal
Replies: 7
Views: 11897

Re: Optimizing speed and fixnum literal

The problem is not that the 3 itself, it's that (* 3 m) isn't guaranteed to be a fixnum if m is, because it's thrice as large as m . If you're certain that (* 3 m) will never exceed the fixnum range, you can annotate it by saying (the fixnum (* 3 m)) . Alternatively, you can specify a more restricti...
by Kompottkin
Wed Feb 15, 2012 2:10 am
Forum: Common Lisp
Topic: Hunchentoot installation questions... [solved]
Replies: 4
Views: 6910

Re: Hunchentoot installation questions...

In addition, note that you don't need to use asdf:oos at all. (ql:quickload :hunchentoot-test) should always work fine (and is easier to type, too), regardless of whether the system in question has already been downloaded or not. It's magic! :)
by Kompottkin
Mon Feb 13, 2012 2:10 am
Forum: Common Lisp
Topic: ERROR: Duplicate Binding in LOOP: (result)
Replies: 1
Views: 4178

Re: ERROR: Duplicate Binding in LOOP: (result)

When using collect into, you are not expected to bind the variable specified somewhere else. It will be bound by collect into. Therefore, the with result = nil clause will cause a conflict.

(Unrelated: finally return result should read finally (return result).)
by Kompottkin
Tue Feb 07, 2012 1:09 am
Forum: The Lounge
Topic: macro
Replies: 1
Views: 6865

Re: macro

You're quite close! Some remarks: (let ((second lista) 0) ...) tries to bind a variable called (second lista) to the value 0 at macro expansion time. That does not make sense, and you don't need it. Your binding list (the thing right after do ) is probably supposed to read ((,(first lista) 0 (+ 2 ,(...
by Kompottkin
Mon Jan 16, 2012 2:40 am
Forum: Common Lisp
Topic: Detect String
Replies: 2
Views: 4611

Re: Detect String

You can use STRINGP . [1]> (stringp "abc") T [2]> (stringp 100) NIL In general, TYPECASE and CTYPECASE are often more useful. (typecase x (string (format t "~&X is a string.")) (number (format t "~&X is a number.")) (t (format t "~&X is... something.&qu...
by Kompottkin
Fri Jan 13, 2012 3:27 am
Forum: Common Lisp
Topic: let vs setf in regards to macros
Replies: 4
Views: 7062

Re: let vs setf in regards to macros

LET works at run-time, not at macro expansion time, so you can't do it that way. There are at least three possible solutions: Use run-time code instead of a macro. Use COMPILE instead of DEFUN. Use MACROLET instead of LET. Expand into code that closes over *B* by rebinding it lexically. The first ap...
by Kompottkin
Tue Jan 10, 2012 2:29 pm
Forum: Common Lisp
Topic: let vs setf in regards to macros
Replies: 4
Views: 7062

Re: let vs setf in regards to macros

The problem is not with setf versus let . The problem is that foo-mac will directly insert the value of *b* at macro expansion time into the generated code as a literal. To illustrate this: CL-USER(10): (defvar *b* 'a) *B* CL-USER(11): (funcall (lambda () (setf *b* 'x) (foo-mac "setf") (fo...
by Kompottkin
Mon Nov 14, 2011 2:43 pm
Forum: Emacs
Topic: auto loading a file
Replies: 2
Views: 25441

Re: auto loading a file

Put the expressions to be executed into a file called ~/.clisprc.lisp. CLISP should read it on launch by default.