+
+;;; NOTE: It is probably wrong in many cases but we will not use this
+;;; heavily. Please, do not rely on wrong cases of this
+;;; implementation.
+(define-compilation eval-when (situations &rest body)
+ ;; TODO: Error checking
+ (cond
+ ;; Toplevel form compiled by !compile-file.
+ ((and *compiling-file* (zerop *convert-level*))
+ ;; If the situation `compile-toplevel' is given. The form is
+ ;; evaluated at compilation-time.
+ (when (find :compile-toplevel situations)
+ (eval (cons 'progn body)))
+ ;; `load-toplevel' is given, then just compile the subforms as usual.
+ (if (find :load-toplevel situations)
+ (convert `(progn ,@body))))
+ ((find :execute situations)
+ (convert `(progn ,@body) *multiple-value-p*))
+ (t
+ (convert nil))))
+