-
Notifications
You must be signed in to change notification settings - Fork 2
PRIN
PRIN is a convenient printing facility for SubText streams. During bulk text output it is painful to programmatically tag text runs, and even without tags and presentations, the format statements become bulky. PRIN form establishes a context within which it is extremely easy to output values, whether constant or computed using the familiar parenthetical structure (to tag text insert a `(tg tagid ...) form, etc). In addition, arbitrary expressions may be executed without printing, as long as the form returns NIL.
(prin stream &rest forms)
- stream evaluates to a subtext stream;
- forms are evaluated in context and result is output, except for the following forms:
nil
and anything evaluating to nil - Nil is not printed. This may be used for conditional output, or for side effects of the expression.
prog0
macro is provided to facilitate that.
(tg tagid &rest forms)
- tagid resolves to a string or a gtk-text-tag
(pr class init &rest forms)
- class evaluates to a pres-derived class;
- init is a list spliced into (make-instance 'class ...) form to create the presentation
(prin out
"ok," (tg tag1 " Test, ") 1 #\space 2 3 "!" #\newline ;; anything princ-able goes
(tg "blue" "hello" (tg tag2 " cruel") " world") ;; nested tags
(tag1 "hello" (+ 1 2)))) ;; generate output
1 2 (tg "blue" "hello") (pr button (:code ...) "what") ;; ad-hoc presentations
ok null "null does not print" ) ;; (prog0 ... nil) works too.
Internally, prin subforms are either items to be printed, or a form that generates a list whose car is the promise (such as a tag), and the rest is items to be printed in that context. Nil is ignored by the printer. You can extend it by following these premises.