Subject: Re: Dynamic function generation, HOW?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sun, 08 Oct 2006 03:19:18 -0500
Newsgroups: comp.lang.lisp
Message-ID: <ZMmdnbmqqvobKbXYnZ2dnUVZ_vudnZ2d@speakeasy.net>
<sankymoron@gmail.com> wrote:
+---------------
| I am usually uncomfortable when programming in lisp because I
| cannot tell what the code is going to look like at run-time.
+---------------

Are you "uncomfortable when programming in C or C++ because you
cannot tell what the code is going to look like at run-time"?
If not, then why are you uncomfortable when programming in Lisp?

If so, then what do you do about it in C or C++? Answer: Probably
the same thing people do in Lisp, that is, write a small test case
and see what it compiles into:

    > (defun +/2-arg/fast (a b)
	(declare (fixnum a b)
		 (optimize (speed 3) (safety 0)))
	(the fixnum (+ a b)))

    +/2-ARG/FAST
    > (compile *)
    ; Compiling LAMBDA (A B): 
    ; Compiling Top-Level Form: 

    +/2-ARG/FAST
    NIL
    NIL
    > (disassemble *)
    4850A288:  .ENTRY +/2-ARG/FAST(a b) ; (FUNCTION (FIXNUM FIXNUM) FIXNUM)
	  A0:  POP   DWORD PTR [EBP-8]
	  A3:  LEA   ESP, [EBP-32]
	  A6:  ADD   EDX, EDI           ; No-arg-parsing entry point
	  A8:  MOV   ECX, [EBP-8]
	  AB:  MOV   EAX, [EBP-4]
	  AE:  ADD   ECX, 2
	  B1:  MOV   ESP, EBP
	  B3:  MOV   EBP, EAX
	  B5:  JMP   ECX
	  B7:  NOP
    > 


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607