File: format

package info (click to toggle)
gcl 2.6.7%2Bdfsga-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 84,796 kB
  • sloc: ansic: 452,686; lisp: 156,133; asm: 111,405; sh: 29,299; cpp: 18,599; perl: 5,602; makefile: 5,201; tcl: 3,181; sed: 469; yacc: 378; lex: 174; fortran: 48; awk: 30; csh: 23
file content (44 lines) | stat: -rw-r--r-- 1,413 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

We have added a user extensible feature to the common lisp 
function format.

For some applications, for example in maxima, it is very desirable
to be able to define a new control character, so that

(format t "~%The polynomial ~m is not zero" polynomial)

would work.  It is desirable to extend format itself, since then
calls to the error and other functions which use format will work
correctly. For example:

(error "~%The polynomial ~m is not zero" polynomial)


For an application to do this we would evaluate the following:

(setf (get 'si::*indent-formatted-output* (char-code #\m)) 'maxima-print)

(defun maxima-print (item stream colon atsign &rest l)
   colon atsign l  ;ignoring these
  (internal-maxima-print item stream))

Note this extension is case sensitive, so that to have this apply to
capital M as well, the property for (char-code #\M) must be added as
well.

A call with "~:m" would make colon=1 and atsign=0.
A call with "~@m" would make colon=0 and atsign=1.

To Do:
The &rest l is currently unused, a future addition will probably
store into l the current column of the format output stream.

This also implies that new print functions should return what they think is 
the new column.  Since I believe that 98% of the current calls to format
do not use column information in an important way, this is probably not worth
the additional hair involved.

Numeric args are not passed.