Function: oclosure--fix-type

oclosure--fix-type is a byte-compiled function defined in oclosure.el.gz.

Signature

(oclosure--fix-type IGNORE OCLOSURE)

Documentation

Helper function to implement oclosure-lambda via a macro.

This has 2 uses:
- For interpreted code, this converts the representation of type information
  by moving it from the docstring to the environment.
- For compiled code, this is used as a marker which cconv uses to check that
  immutable fields are indeed not mutated.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/oclosure.el.gz
(defun oclosure--fix-type (_ignore oclosure)
  "Helper function to implement `oclosure-lambda' via a macro.
This has 2 uses:
- For interpreted code, this converts the representation of type information
  by moving it from the docstring to the environment.
- For compiled code, this is used as a marker which cconv uses to check that
  immutable fields are indeed not mutated."
  (if (byte-code-function-p oclosure)
      ;; Actually, this should never happen since the `cconv.el' should have
      ;; optimized away the call to this function.
      oclosure
    ;; For byte-coded functions, we store the type as a symbol in the docstring
    ;; slot.  For interpreted functions, there's no specific docstring slot
    ;; so `Ffunction' turns the symbol into a string.
    ;; We thus have convert it back into a symbol (via `intern') and then
    ;; stuff it into the environment part of the closure with a special
    ;; marker so we can distinguish this entry from actual variables.
    (cl-assert (eq 'closure (car-safe oclosure)))
    (let ((typename (nth 3 oclosure))) ;; The "docstring".
      (cl-assert (stringp typename))
      (push (cons :type (intern typename))
            (cadr oclosure))
      oclosure)))