Compiler or interpreter?

How to determine if a program is running in the interpreter or as compiled code?

Alex Shinn suggested:

  (cond-expand
    (compiling
     ...)
    (else
     ...))

Based on that, John Cowan came with:

(cond-expand (compiling (define (compiled?) #t)) (else (define (compiled?) #f)))

Felix Winkelmann mentioned the feature? procedure which can do the proposed job too:

(feature? 'script)      ; running via csi -s
(feature? 'compiling)   ; running as a compiler extension (-X)
(feature? 'csi)         ; running in csi

References