Re: Lisp object code versus that of other languages



It depends on your optimization settings. Remember, Lisp takes care of
types for you. So, something as simple as:

(defun add (a b)
(+ a b))

can produce lots of assembly code; it has to handle adding integers,
reals, complex numbers, .... However, now try:

(defun add-optimized (a b)
(declare (fixnum a b))
(the fixnum (+ a b)))

Now that is looking much better and there is still debugging
information in there, so you can declare even more (optimize 3),
(safety 0), (debug 0), and now you're starting to get extremely close
to C.

Jeff M.

.



Relevant Pages

  • Re: Easier type declarations?
    ... (declare (fixnum n)) ... One thing is the DECLARE, the other is the THE form. ... (defun fb:fixnum (n:fixnum) ... with a syntax gotten from McDermott's NISP and descendants. ...
    (comp.lang.lisp)
  • Re: factorial of largish numbers
    ... CL-USER> ... (declare (fixnum n m)) ... STYLE-WARNING: redefining K in DEFUN ...
    (comp.lang.lisp)
  • (exp (/ z))
    ... (defun xycorg (cx cy xab nx ny) ... (declare (double-float cx cy xab) ... (fixnum nx ny) ...
    (comp.lang.lisp)
  • Re: sound synthesis
    ... > the declarations and using short float helped, ... (defun mix (target-samples source-samples start sample-rate) ... (declare (float sample-rate seconds) ... (defun fm-gong (time freq) ...
    (comp.lang.lisp)
  • Asking for Alioth shootout help on "fasta" benchmark
    ... The benchmark says that the floats need to be double floats. ... (declare (double-float max)) ... HomoSapiens) ... (defun make-cumulative (freqs) ...
    (comp.lang.lisp)