[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Issue: WITH-COMPILATION-UNIT (Version 1)
- To: CL-Compiler@SAIL.Stanford.EDU
- Subject: Issue: WITH-COMPILATION-UNIT (Version 1)
- From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Thu, 29 Sep 88 18:11 EDT
- Cc: KMP@STONY-BROOK.SCRC.Symbolics.COM
Issue: WITH-COMPILATION-UNIT
References: None
Category: ADDITION
Edit history: 29-Sep-88, Version 1 by Pitman
Status: For Internal Discussion
Problem Description:
Some actions done by the compiler (and particularly the file compiler)
are typically deferred until the "very end" of compilation. For example,
some compilers complain about "functions seen but not defined".
Unfortunately, since COMPILE-FILE is the largest unit of granularity,
and since systems often extend over more than one file, it often happens
that the compiler needlessly complains at the end of compiling one file
about the absence of functions defined in the next file.
Proposal (WITH-COMPILATION-UNIT:NEW-MACRO):
Add the following new macro:
WITH-COMPILATION-UNIT &BODY forms [Macro]
Executes forms from left to right. Within the dynamic context
of this form, actions deferred by the compiler until "the end of
compilation" will be deferred until the end of the outermost call
to WITH-COMPILATION-UNIT. The result(s) are the same as that of
the last of the FORMS (or NIL if FORMS is null).
It follows that the functions COMPILE and COMPILE-FILE should
provide the effect of WITH-COMPILATION-UNIT around their code.
Note that if nested, either lexically or dynamically, only the
outer call to WITH-COMPILATION-UNIT has any effect.
Note also that not all warnings are deferred. In some
implementations, it may be that none are deferred. This proposal
only creates an interface to the capability where it exists, it
does not require the creation of the capability. An implementation
which does not do deferred warnings may correctly implement this
as expanding into PROGN.
Test Case:
(DEFUN COMPILE-FILES (&REST FILES)
(WITH-COMPILATION-UNIT ()
(MAPCAR #'(LAMBDA (FILE) (COMPILE-FILE FILE)) FILES)))
(COMPILE-FILES "A" "B" "C")
processes deferred warnings only after compiling all of A, B, and C.
Rationale:
This will make the development of portable system-construction tools
considerably more convenient.
Current Practice:
Symbolics Genera does something similar to this internally, allowing
programs that compile whole systems of files to defer warnings until
the end.
Cost to Implementors:
In implementations which have no deferred warnings, there is no cost.
In implementations which have deferred warnings, the cost is probably
fairly small.
Cost to Users:
None. This is a compatible addition.
Cost of Non-Adoption:
Portable system-construction tools would continue to print lots of
spurious warnings because they would have no way to tell the system
that a set of files was working together.
Benefits:
The cost of non-adoption is avoided.
Aesthetics:
The ability to create a compilation unit other than a file is important.
Discussion:
One could imagine a further extension which allowed user-code to be added
to the list of things done at the end of a compilation-unit. Probably
best to deal first with this issue and then with potentially more
controversial extensions.
Pitman supports this addition.