<commit_before>(cl:in-package #:sicl-extrinsic-environment)

(defun import-special-operators (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	when (special-operator-p symbol)
	  do (setf (sicl-env:special-operator symbol environment) t)))

(defun import-nil-and-t (environment)
  (setf (sicl-env:constant-variable t environment) t)
  (setf (sicl-env:constant-variable nil environment) nil))

;;; Enter every Common Lisp class into the environment.
(defun import-classes (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	for class = (find-class symbol nil)
	unless (null class)
	  do (setf (sicl-env:find-class symbol environment)
		   class)))

(defun import-variables (environment)
  (let ((variables '(*standard-input* *standard-output* *error-output*
		     *terminal-io* *trace-output* *query-io*
		     *print-base* *read-base* *package*)))
    (loop for symbol in variables
	  do (setf (sicl-env:special-variable symbol environment t)
		   (cl:symbol-value symbol)))))

;;; Rather than explicitly enumerating the functions to import, we
;;; just import them all initially.  Later, we redefine the ones for
;;; which the host definition will not be appropriate.
(defun import-functions (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	when (and (fboundp symbol)
		  (null (macro-function symbol))
		  (not (special-operator-p symbol)))
	  do (setf (sicl-env:fdefinition symbol environment) t)
	when (fboundp `(setf ,symbol))
	  do (setf (sicl-env:fdefinition `(setf ,symbol) environment) t)))

(defun import-from-host-common-lisp (environment)
  (import-special-operators environment)
  (import-nil-and-t environment)
  (import-classes environment)
  (import-variables environment))
  <commit_msg>Import the function from the host.<commit_after>(cl:in-package #:sicl-extrinsic-environment)

(defun import-special-operators (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	when (special-operator-p symbol)
	  do (setf (sicl-env:special-operator symbol environment) t)))

(defun import-nil-and-t (environment)
  (setf (sicl-env:constant-variable t environment) t)
  (setf (sicl-env:constant-variable nil environment) nil))

;;; Enter every Common Lisp class into the environment.
(defun import-classes (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	for class = (find-class symbol nil)
	unless (null class)
	  do (setf (sicl-env:find-class symbol environment)
		   class)))

(defun import-variables (environment)
  (let ((variables '(*standard-input* *standard-output* *error-output*
		     *terminal-io* *trace-output* *query-io*
		     *print-base* *read-base* *package*)))
    (loop for symbol in variables
	  do (setf (sicl-env:special-variable symbol environment t)
		   (cl:symbol-value symbol)))))

;;; Rather than explicitly enumerating the functions to import, we
;;; just import them all initially.  Later, we redefine the ones for
;;; which the host definition will not be appropriate.
(defun import-functions (environment)
  (loop for symbol being each external-symbol in '#:common-lisp
	when (and (fboundp symbol)
		  (null (macro-function symbol))
		  (not (special-operator-p symbol)))
	  do (setf (sicl-env:fdefinition symbol environment)
		   (fdefinition symbol))
	when (fboundp `(setf ,symbol))
	  do (setf (sicl-env:fdefinition `(setf ,symbol) environment)
		   (fdefinition `(setf ,symbol)))))

(defun import-from-host-common-lisp (environment)
  (import-special-operators environment)
  (import-nil-and-t environment)
  (import-classes environment)
  (import-variables environment))
  
{'fraction_non_alphanumeric': 0.12431693989071038, 'fraction_numerical': 0.0, 'mean_word_length': 4.546969696969697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4741252', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1121, 'n_words': 352}