Function Entry: TERPRI

← Prev | ↑ Chapter | Next → | Index | Symbols

Function Entry: TERPRI

Name

terpri

Class

Function

Syntax

(terpri)

Arguments and Values

None.

Description

Prints a newline character to the command line. Has no file-handle parameter — the printer-surface family takes a file handle on the per-output-call functions (prin1, princ, print), but terpri is command-line-only. (clautolisp adds an optional file handle as a dialect-gated extension; see Extension (clautolisp) below.)

Return Values

Always returns nil.

Side Effects

Emits a newline to the command line.

Notes

Bricsys recommends (princ) (with no arguments) instead of (terpri) when ending a defun body, because (princ) returns void and does not print an extra newline.

Tested Behaviour (BricsCAD V26 / macOS, 2026-04-26)

The probe suite emits (terpri stream) against an open file handle. BricsCAD V26 reports:

Probe Outcome
(terpri file-desc) error: too few / too many arguments at [TERPRI]
(princ "A" file-desc) + (terpri file-desc) first call writes A; second call errors with the same message

This empirically confirms BricsCAD V26's documented zero-arity contract. AutoLISP code that wishes to write a newline to a file handle must use (princ "\n" stream) (BricsCAD V26 confirmed acceptance: princ-string.txt test produced hello\n). terpri is reserved for command-line output. The same code shape ported from Common Lisp via (terpri stream) will not portably work in AutoLISP.

Extension (clautolisp): optional file handle

clautolisp extends terpri with an optional file-descriptor argument:

(terpri [file-desc])

When file-desc is supplied, a newline is written to that open file (equivalent to (princ "\n" file-desc)); when omitted, behaviour is the vendor-standard command-line newline. The extension exists so that Common-Lisp-shaped output code (e.g. (foreach x xs (prin1 x f) (terpri f))) runs unchanged under clautolisp.

Dialect handling mirrors the other clautolisp extensions:

Dialect (terpri file-desc)
clautolisp accepted silently — writes a newline to file-desc
lax accepted silently (catch-all "accept every extension" mode)
strict warned — non-fatal out-of-dialect warning; newline written
autocad-2026 warned — non-fatal out-of-dialect warning; newline written
bricscad-v26 warned — non-fatal out-of-dialect warning; newline written

Dialect problems are signalled with WARNINGS, never errors (alfe-clautolisp-dialect.issue point 4): under the warning dialects a [terpri-file-extension] line is written to standard error and the newline is still written, so existing code keeps running. The warning points at the portable (princ "\n" file-desc) form. Note this is an intentional divergence from real AutoCAD 2026 / BricsCAD V26, which reject (terpri file-desc) at runtime; portable programs that must run on a real CAD should use (princ "\n" file-desc). Implemented 1.2.23 (warn, not error: 1.2.24).

Availability

  • AutoCAD 2026: documented (Autodesk reference page).
  • BricsCAD V26: documented + product-tested on macOS (probe suite, 2026-04-26). Arity is exactly zero; the 2-argument form (terpri stream) is rejected at runtime.
  • Status: documented in both vendors and tested against BricsCAD V26 / macOS. Phase-5 closure: arity nailed down (zero arguments, command-line-only) by direct citation and product test.

See Also