Search found 25 matches

by makia
Wed Oct 19, 2011 12:59 pm
Forum: Common Lisp
Topic: help understanding a simple function
Replies: 23
Views: 14356

Re: help understanding a simple function

it's working like this:

(my-length '(list with four objects))
(1+ (my-length '(with four objects)))
(1+ (1+ (my-length '(four objects))))
(1+ (1+ (1+ (my-length '(objects)))))
(1+ (1+ (1+ (1+ (my-length '())))))
(1+ (1+ (1+ (1+ 0))))

p.s. you can (trace my-length) to see something like this
by makia
Fri Nov 06, 2009 1:51 am
Forum: Common Lisp
Topic: Runtime compilation strategy
Replies: 10
Views: 7323

Re: Runtime compilation strategy

Not that I've got any experience, but instead of generating assembly directly, why not use something like http://llvm.org/, and benefit from all of the optimisers :mrgreen: and things in that project :?: It mentions some type of run-time compilation too. I looked llvm couple of days ago, problem fo...
by makia
Thu Nov 05, 2009 12:46 am
Forum: Common Lisp
Topic: Runtime compilation strategy
Replies: 10
Views: 7323

Re: Runtime compilation strategy

Yup, take a look at ECL. When you call COMPILE-FILE in ECL, it effectively spits out a temporary .c file, invokes GCC on it, and then when you LOAD it, it dynamically loads the resulting dynamic lib. Most other Lisp compilers don't work this way, BTW. Others, like SBCL, have their own compiler/asse...
by makia
Wed Nov 04, 2009 8:02 am
Forum: Common Lisp
Topic: Runtime compilation strategy
Replies: 10
Views: 7323

Runtime compilation strategy

I'm doing small lisp like compiler (to x86 asm) and what is bothering me is "runtime compilation", it's simple enough to do simple static C-like compiler with basic Lisp stuff (C runtime/gc and Lisp compiler emiting x86 asm) but i'm not sure how to do runtime compilation and all the problems that go...
by makia
Wed Nov 04, 2009 2:34 am
Forum: Common Lisp
Topic: HowTo: string-parameter to use as function call
Replies: 1
Views: 1823

Re: HowTo: string-parameter to use as function call

(funcall (intern (string-upcase string)) arg1 arg2 ...)
by makia
Tue Oct 13, 2009 11:31 pm
Forum: Common Lisp
Topic: Optimal boolean expressions evaluation
Replies: 6
Views: 4317

Re: Optimal boolean expressions evaluation

of course there is no mutating tests here, we can simplify this:

Code: Select all

(OR (AND (= A B) (= C D))
    (AND (= A B) (= Y P)))
to

Code: Select all

(OR (AND a b)
    (AND a c))
and this should lead to:

Code: Select all

(AND a (OR b c))
by makia
Tue Oct 13, 2009 10:08 am
Forum: Common Lisp
Topic: Optimal boolean expressions evaluation
Replies: 6
Views: 4317

Re: Optimal boolean expressions evaluation

btw. i posted this here because it's part of something i'm doing in Common Lisp and i'm interested in CL solutions (also it's natural to do this in sexp) .... wiki link can help too :)
by makia
Tue Oct 13, 2009 10:02 am
Forum: Common Lisp
Topic: Optimal boolean expressions evaluation
Replies: 6
Views: 4317

Optimal boolean expressions evaluation

What is known tactic for creating optimal boolean query expressions, for example if i have this query: (OR (AND (= A B) (= C D)) (AND (= A B) (= Y P))) faster evaluation would be: (AND (= A B) (OR (= C D) (= Y P))) , this is not only lisp related but it's natural to solve this in lisp form Thanks
by makia
Sat Jan 17, 2009 5:01 am
Forum: Common Lisp
Topic: A "declare" form returned by macro
Replies: 19
Views: 15848

Re: A "declare" form returned by macro

i really like sbcl "declarations are assertions" principle, it does helps sometimes, specially for interface (it's ugly writing assert everywhere)
by makia
Fri Jan 09, 2009 4:31 pm
Forum: Common Lisp
Topic: SICP Exercise related Question
Replies: 2
Views: 2999

Re: SICP Exercise related Question

Code: Select all

(defun a-plus-abs-b (a b)
	   (funcall (if (> b 0) '+ '-) a b))
SICP examples are in scheme, scheme is so-called lisp-1 and common lisp is lisp-2 (common lisp has different namespaces for functions and variables) ...