Re: Static/Strong/Implicit Typing

From: Thomas F. Bur*** (tfb_at_famine.OCF.Berkeley.EDU)
Date: 01/27/04


Date: 26 Jan 2004 21:17:18 -0800

Rahul Jain <rjain@nyct.net> writes:

> Jens Axel Søgaard <usenet@jasoegaard.dk> writes:
>
> > Some compilers make several compiled versions of the same function.
> > A little simplified: If the types of the arguments are known in
> > a specific function call, a specialized function is called.
> > If the types are unknown a general version is called. Using this
> > approach [but in a much more sophisticated way] Siskind and others
> > have gotten fine results.
>
> Most of us call this process "inlining" followed by "optimization" which
> includes "unreachable code elision". :)

I see the smiley, but in case anyone following this isn't clear on
what he's referring to, it is different. If you have a function like:

  (defun foo (&optional base)
    (labels ((make-adder (&key base)
               (lambda (x) (+ base x))))
      (if base
          (make-adder :base base)
          #'make-adder)))

Your compiler might do something like this:

  make-adder-arg-parser:
    ;; parse args for call to main body
    ...
    jmp make-adder-noparse
  make-adder-noparse:
    ;; This is a function of one fixed argument, BASE.
    ;; If BASE wasn't supplied, we should get a magic not-supplied
    ;; constant instead.
    ...

The call to MAKE-ADDER will call make-adder-noparse directly. The
function returned by the form #'make-adder, however, has to return a
function callable from any context, so it'll use make-adder-arg-parser.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'