Eclipse behavior for
Function COMPILE-FILE
Syntax:
Eclipse defines the following additional &KEY argument for the compile-file function:
loader-name -- a symbol. The default is the result of
interning the result of (pathname-name output-pathname :case
:common) in the current package.
output-format --- a compile-file output format designator. Complicated defaulting behavior. See below.
Description:
Output-pathname is the pathname as returned by
compile-file-pathname. If output-format is specified as :C, the
type component of output-pathname will default to "C"
(:common :case). Otherwise, it defaults to "BIN".
Output-format defaults to a keyword created from the pathname type component of output-pathname.
If output-format is :DEFAULT,
:BIN, or :BYTE, the result is a file
of implementation-dependent format, suitable for use by
load. The format is independent of the Lisp image. Moreover,
all implementations of Eclipse can load files of this format,
even if they were produced by compile-file on an implementation
of Eclipse for a different platform than the one in which load is
executed. Loader-name is not used for this output-format.
If output-format is :C, the result is an ASCII C
file. This file defines an init
function who's name is specified by loader-name. The C
file must be compiled by a C compiler and linked with the Eclipse
library. The resulting application must call the appropriate
system initialization functions
before calling the init function.
Calling the init function results
in the same behavior that occurs when a :DEFAULT format
file is loaded. After that, the application can use any utilities defined in the file as though
they were a part of the Eclipse library.
Examples:
; Compile a file to C.
(in-package :user)
(compile-file "foo" 'output-format :c)
; Specify a different loader name.
(compile-file "foo" 'output-format :c 'loader-name 'initialize-foo)
; Specify that foo.lisp contains only ASCII characters.
(compile-file "foo" 'output-format :c
'loader-name 'initialize-foo
:external-format :ascii)
; Create a C version of foo.lisp, in the src subdirectory.
; It is not necessary to specify OUTPUT-FORMAT because OUTPUT-FILE
; specifies a c file.
(compile-file "foo" :output-file "src/foo.c" :external-format :ascii)
See Also:
The Packages section of "Eclipse-Defined ANSI Features", the Character Repertoires and Interaction with Streams sections of "Characters in Eclipse", load.
Notes:
The package of the loader-name and output-format
&key designators is the ECLIPSE package.
The current package used in creating the default value for loader-name is the package at the time compile-file is called; it is not effected by in-package forms within the file.
When a Lisp source file or a :default format
compiled file is loaded, *package* and
*readtable* are bound during the load to the values they
had before, while *load-truename* and *load-pathname* are
bound to appropriate values. The init function generated by a
:C format compiled file also binds all four of
these. However, the actual values to which *load-truename* and
*load-pathname* are bound is not specified.
Reader macros, including read-time feature conditionalization, are
processed at read time, and are not present in compiled
files. If the same :default format compiled
file is to be used on several different platforms, and it is
desired to have different behavior on different platforms, than it is
necessary to define the different behavior using conditionals at
load-time or at run-time.
ANSI defines compile-file to accept an external-format
&KEY argument, but not an
element-type argument. This is because compiling a source file
must handle any implementation-supported character. The Eclipse
implementation of compile-file recognizes that only
base-chars can be read using the :ASCII
external-format. The consequence is that when the
:ASCII external-format is specified for
compile-file, string literals will be of type
base-string. Otherwise, it is only specified that these will
be of type string. This is important because when
coalescing any string literal, the file compiler is not
allowed to change the actual element-type. String literals
that are read as strings and not as base-strings must
appear in compiled files with character
element-types.
Note that regardless of external-format, implementations are allowed to copy and perform other optimizations on the names used to intern symbols. Eclipse may convert string symbol-names that happen to contain only base-char elements to base-string during compilation.