pprint-coalton-codegen pretty-prints the Common Lisp code generated by coalton-codegen to *standard-output*.

Syntax

(pprint-coalton-codegen
  ⟨toplevel-form⟩*)

Semantics

  • pprint-coalton-codegen accepts the same top-level forms as coalton-toplevel.
  • It compiles the forms via coalton-codegen (with host type declarations omitted) and pretty-prints the resulting Common Lisp (progn ...) form to *standard-output*.
  • Before printing, it creates a temporary package that uses #:cl and imports all symbols accessible in the current *package*, so user and Coalton symbols print cleanly without redundant package prefixes, and deletes the temporary package via cl:unwind-protect.
  • Returns zero values (cl:values).

Examples

;; Replace `coalton-toplevel` with `pprint-coalton-codegen` to inspect generated Lisp
(pprint-coalton-codegen
  (declare sum-upto (UFix -> UFix))
  (define (sum-upto n)
    (for ((i 0 (+ i 1))
          (acc 0 (+ acc i)))
      :returns acc
      :while (< i n))))

Other notes