]> git.donarmstrong.com Git - lilypond.git/blob - scm/lily.scm
release: 1.3.7
[lilypond.git] / scm / lily.scm
1 ; lily.scm -- implement Scheme output routines for TeX and PostScript
2 ;
3 ;  source file of the GNU LilyPond music typesetter
4
5 ; (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
6
7
8 ;(debug-enable 'backtrace)
9
10 ;;; library funtions
11
12 (use-modules (ice-9 regex))
13
14 ;; do nothing in .scm output
15 (define (comment s)
16   ""
17   )
18
19 (define
20   (xnumbers->string l)
21   (string-append 
22    (map (lambda (n) (string-append (number->string n ) " ")) l)))
23
24 (define (mm-to-pt x)
25   (* (/ 72.27 25.40) x)
26   )
27
28 (define (cons-map f x)
29   (cons (f (car x)) (f (cdr x))))
30
31 (define (reduce operator list)
32       (if (null? (cdr list)) (car list)
33           (operator (car list) (reduce operator (cdr list)))
34           )
35       )
36
37
38 (define (glue-2-strings a b) (string-append a " " b))
39
40 (define
41   (numbers->string l)
42   (reduce glue-2-strings (map number->string l)))
43
44 (define (chop-decimal x) (if (< (abs x) 0.001) 0.0 x))
45
46 (define (number->octal-string x)
47   (let* ((n (inexact->exact x))
48          (n64 (quotient n 64))
49          (n8 (quotient (- n (* n64 64)) 8)))
50     (string-append
51      (number->string n64)
52      (number->string n8)
53      (number->string (remainder (- n (+ (* n64 64) (* n8 8))) 8)))))
54
55 (define (inexact->string x radix)
56   (let ((n (inexact->exact x)))
57     (number->string n radix)))
58
59
60 (define
61   (control->string c)
62   (string-append
63    (string-append (number->string (car c)) " ")
64    (string-append (number->string (cadr c)) " ")))
65
66
67 (define (font i)
68   (string-append
69    "font"
70    (make-string 1 (integer->char (+ (char->integer #\A) i)))
71    ))
72
73
74
75 (define (scm-scm action-name)
76   1)
77
78 (define security-paranoia #f)
79
80
81 ;; See documentation of Item::visibility_lambda_
82 (define (postbreak-only-visibility d) (if (= d 1) '(#f . #f) '(#t . #t)))
83 (define (spanbar-non-postbreak-visibility d) (if (= d -1) '(#t . #t) '(#f . #f)))
84 (define (all-visibility d) '(#f . #f))
85 (define (non-postbreak-visibility d) (if (= d 1) '(#t . #t) '(#f . #f)))
86 (define (non-prebreak-visibility d) (if (= d -1) '(#t . #t) '(#f . #f)))
87
88
89 ;; Score_span_bars are only visible at start of line
90 ;; i.e. if break_dir == RIGHT == 1
91 (define Span_bar_engraver-visibility non-postbreak-visibility)
92 (define mark-visibility non-prebreak-visibility)
93 (define Span_score_bar_engraver-visibility postbreak-only-visibility)
94 (define Piano_bar_engraver-visibility postbreak-only-visibility)
95 (define Staff_group_bar_engraver-visibility postbreak-only-visibility)
96
97 ;; Spacing constants for prefatory matter.
98 ;;
99 ;; rules for this spacing are much more complicated than this. See [Wanske] page 126 -- 134, [Ross] pg 143 -- 147
100 ;;
101 ;;
102
103 (define space-alist
104  '(
105    (("" "Clef_item") . (minimum-space 1.0))
106    (("" "Staff_bar") . (minimum-space 0.0))
107    (("" "Clef_item") . (minimum-space 1.0))
108    (("" "Key_item") . (minimum-space 0.5))
109    (("" "Span_bar") . (extra-space 0.0))
110    (("" "Time_signature") . (extra-space 0.0))
111    (("" "begin-of-note") . (minimum-space 1.5))
112    (("Clef_item" "Key_item") . (minimum-space 4.0))
113    (("Key_item" "Time_signature") . (extra-space 1.0))
114    (("Clef_item"  "Time_signature") . (minimum-space 3.5))
115    (("Staff_bar" "Clef_item") .   (minimum-space 1.0))
116    (("Clef_item"  "Staff_bar") .  (minimum-space 3.7))
117    (("Time_signature" "Staff_bar") .  (minimum-space 2.0))
118    (("Key_item"  "Staff_bar") .  (extra-space 1.0))
119    (("Span_bar" "Clef_item") .   (extra-space 1.0))
120    (("Clef_item"  "Span_bar") . (minimum-space 3.7))
121    (("Time_signature" "Span_bar") . (minimum-space 2.0))
122    (("Key_item"  "Span_bar") . (minimum-space 2.5))
123    (("Staff_bar" "Time_signature") . (minimum-space 1.5)) ;double check this.
124    (("Time_signature" "begin-of-note") . (extra-space 2.0)) ;double check this.
125    (("Key_item" "begin-of-note") . (extra-space 2.5))
126    (("Staff_bar" "begin-of-note") . (extra-space 1.0))
127    (("Clef_item" "begin-of-note") . (minimum-space 5.0))
128    (("" "Breathing_sign") . (minimum-space 0.0))
129    (("Breathing_sign" "Key_item") . (minimum-space 1.5))
130    (("Breathing_sign" "begin-of-note") . (minimum-space 1.0))
131    (("Breathing_sign" "Staff_bar") . (minimum-space 1.5))
132    (("Breathing_sign" "Clef_item") . (minimum-space 2.0))
133    )
134 )
135  
136 (define (break-align-spacer this next)
137   (let ((entry (assoc `(,this ,next) space-alist)))
138     (if entry
139         (cdr entry)
140         (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
141                '(minimum-space 0.0)))))
142   
143         
144
145 ;;;;;;;; TeX
146
147 ;; this is silly, can't we use something like
148 ;; roman-0, roman-1 roman+1 ?
149 (define cmr-alist 
150   '(("bold" . "cmbx") 
151     ("dynamic" . "feta-din") 
152     ("feta" . "feta") 
153     ("feta-1" . "feta") 
154     ("feta-2" . "feta") 
155     ("finger" . "feta-nummer") 
156     ("typewriter" . "cmtt") 
157     ("italic" . "cmti") 
158     ("roman" . "cmr") 
159     ("script" . "cmr") 
160     ("large" . "cmbx") 
161     ("Large" . "cmbx") 
162     ("mark" . "feta-nummer") 
163     ("number" . "feta-nummer") 
164     ("volta" . "feta-nummer"))
165 )
166
167 (define (string-encode-integer i)
168   (cond
169    ((= i  0) "o")
170    ((< i 0)   (string-append "n" (string-encode-integer (- i))))
171    (else (string-append
172           (make-string 1 (integer->char (+ 65 (modulo i 26))))
173           (string-encode-integer (quotient i 26))
174          )
175    )
176   )
177   )
178
179 (define (magstep i)
180   (cdr (assoc i '((-4 . 482)
181                   (-3 . 579)
182                   (-2 . 694)
183                   (-1 . 833)
184                   (0 . 1000)
185                   (1 . 1200) 
186                   (2 . 1440)
187                   (3 . 1728)
188                   (4 . 2074))
189               )
190        )
191   )
192              
193 (define script-alist '())
194 (define (articulation-to-scriptdef a)
195   (assoc a script-alist)
196   )
197
198 ;; Map style names to TeX font names.  Return false if 
199 ;; no font name found. 
200 (define (style-to-cmr s)
201   (assoc s cmr-alist )
202   )
203             
204
205
206 (define font-name-alist  '())
207 (define (font-command name-mag)
208     (cons name-mag
209           (string-append  "magfont"
210                           (string-encode-integer (hash (car name-mag) 1000000))
211                           "m"
212                           (string-encode-integer (cdr name-mag)))
213
214           )
215     )
216 (define (define-fonts names)
217   (set! font-name-alist (map font-command names))
218   (apply string-append
219          (map (lambda (x)
220                 (font-load-command (car x) (cdr x))) font-name-alist)
221   ))
222   
223
224 (define (tex-scm action-name)
225   (define (unknown) 
226     "%\n\\unknown%\n")
227
228
229   (define (select-font font-name-symbol)
230     (let*
231         (
232          (c (assoc font-name-symbol font-name-alist))
233          )
234
235       (if (eq? c #f)
236           (begin
237             (ly-warn (string-append
238                       "Programming error: No such font known " (car font-name-symbol)))
239             "")                         ; issue no command
240           (string-append "\\" (cdr c)))
241       
242       
243       ))
244   
245   (define (beam width slope thick)
246     (embedded-ps ((ps-scm 'beam) width slope thick)))
247
248   (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
249     (embedded-ps ((ps-scm 'bracket) arch_angle arch_width arch_height width height arch_thick thick)))
250
251   (define (dashed-slur thick dash l)
252     (embedded-ps ((ps-scm 'dashed-slur)  thick dash l)))
253
254   (define (crescendo thick w h cont)
255     (embedded-ps ((ps-scm 'crescendo) thick w h cont)))
256
257   (define (char i)
258     (string-append "\\char" (inexact->string i 10) " "))
259   
260   (define (decrescendo thick w h cont)
261     (embedded-ps ((ps-scm 'decrescendo) thick w h cont)))
262
263    ;This sets CTM so that you get to the currentpoint
264   ; by executing a 0 0 moveto
265
266   
267  
268
269   (define (font-load-command name-mag command)
270     (string-append
271      "\\font\\" command "="
272      (symbol->string (car name-mag))
273      " scaled "
274      (number->string (magstep (cdr name-mag)))
275      "\n"))
276
277
278   (define (embedded-ps s)
279     (string-append "\\embeddedps{" s "}"))
280
281   (define (comment s)
282     (string-append "% " s))
283   
284   (define (end-output) 
285     "\n\\EndLilyPondOutput")
286   
287   (define (experimental-on)
288     "")
289
290   (define (font-switch i)
291     (string-append
292      "\\" (font i) "\n"))
293
294   (define (font-def i s)
295     (string-append
296      "\\font" (font-switch i) "=" s "\n"))
297
298   (define (header-end)
299     (string-append
300      "\\special{! "
301      ; fixed in 1.3.4
302      ;(ly-gulp-file "lily.ps")
303
304      (regexp-substitute/global #f "\n" (ly-gulp-file "lily.ps") 'pre " %\n" 'post)
305      "}"
306      "\\input lilyponddefs \\turnOnPostScript"))
307
308   (define (header creator generate) 
309     (string-append
310      "%created by: " creator generate))
311
312   (define (invoke-char s i)
313     (string-append 
314      "\n\\" s "{" (inexact->string i 10) "}" ))
315
316   (define (invoke-dim1 s d)
317     (string-append
318      "\n\\" s "{" (number->dim d) "}"))
319   (define (pt->sp x)
320     (* 65536 x))
321   
322   ;;
323   ;; need to do something to make this really safe.
324   ;;
325   (define (output-tex-string s)
326       (if security-paranoia
327           (regexp-substitute/global #f "\\\\" s 'pre "$\\backslash$" 'post)
328           s))
329       
330   (define (lily-def key val)
331     (string-append
332      "\\def\\"
333      ; fixed in 1.3.4
334      (regexp-substitute/global #f "_" (output-tex-string key) 'pre "X" 'post)
335      ;(output-tex-string key)
336      "{" (output-tex-string val) "}\n"))
337
338   (define (number->dim x)
339     (string-append 
340      (number->string  (chop-decimal x)) " pt "))
341
342   (define (placebox x y s) 
343     (string-append 
344      "\\placebox{"
345      (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
346
347
348
349   (define (bezier-sandwich l thick)
350     (embedded-ps ((ps-scm 'bezier-sandwich) l thick)))
351
352
353   (define (start-line ht)
354     (begin
355       (string-append"\\vbox to " (number->dim ht) "{\\hbox{%\n"))
356     )
357   (define (stop-line) 
358     "}\\vss}\\interscoreline")
359   (define (stop-last-line)
360     "}\\vss}")
361   (define (filledbox breapth width depth height) 
362     (string-append 
363      "\\kern" (number->dim (- breapth))
364      "\\vrule width " (number->dim (+ breapth width))
365      "depth " (number->dim depth)
366      "height " (number->dim height) " "))
367
368   (define (text s)
369     (string-append "\\hbox{" (output-tex-string s) "}"))
370   
371   (define (tuplet ht gapx dx dy thick dir)
372     (embedded-ps ((ps-scm 'tuplet) ht gapx dx dy thick dir)))
373
374   (define (volta h w thick vert_start vert_end)
375     (embedded-ps ((ps-scm 'volta) h w thick vert_start vert_end)))
376
377   ;; TeX
378   ;; The procedures listed below form the public interface of TeX-scm.
379   ;; (should merge the 2 lists)
380   (cond ((eq? action-name 'all-definitions)
381          `(begin
382             (define font-load-command ,font-load-command)
383             (define beam ,beam)
384             (define bezier-sandwich ,bezier-sandwich)
385             (define bracket ,bracket)
386             (define char ,char)
387             (define crescendo ,crescendo)
388             (define dashed-slur ,dashed-slur) 
389             (define decrescendo ,decrescendo) 
390             (define end-output ,end-output)
391             (define experimental-on ,experimental-on)
392             (define filledbox ,filledbox)
393             (define font-def ,font-def)
394             (define font-switch ,font-switch)
395             (define header-end ,header-end)
396             (define lily-def ,lily-def)
397             (define header ,header) 
398             (define invoke-char ,invoke-char) 
399             (define invoke-dim1 ,invoke-dim1)
400             (define placebox ,placebox)
401             (define select-font ,select-font)
402             (define start-line ,start-line)
403             (define stop-line ,stop-line)
404             (define stop-last-line ,stop-last-line)
405             (define text ,text)
406             (define tuplet ,tuplet)
407             (define volta ,volta)
408             ))
409
410         ((eq? action-name 'beam) beam)
411         ((eq? action-name 'tuplet) tuplet)
412         ((eq? action-name 'bracket) bracket)
413         ((eq? action-name 'crescendo) crescendo)
414         ((eq? action-name 'dashed-slur) dashed-slur) 
415         ((eq? action-name 'decrescendo) decrescendo) 
416         ((eq? action-name 'end-output) end-output)
417         ((eq? action-name 'experimental-on) experimental-on)
418         ((eq? action-name 'font-def) font-def)
419         ((eq? action-name 'font-switch) font-switch)
420         ((eq? action-name 'header-end) header-end)
421         ((eq? action-name 'lily-def) lily-def)
422         ((eq? action-name 'header) header) 
423         ((eq? action-name 'invoke-char) invoke-char) 
424         ((eq? action-name 'invoke-dim1) invoke-dim1)
425         ((eq? action-name 'placebox) placebox)
426         ((eq? action-name 'bezier-sandwich) bezier-sandwich)
427         ((eq? action-name 'start-line) start-line)
428         ((eq? action-name 'stem) stem)
429         ((eq? action-name 'stop-line) stop-line)
430         ((eq? action-name 'stop-last-line) stop-last-line)
431         ((eq? action-name 'volta) volta)
432         (else (error "unknown tag -- PS-TEX " action-name))
433         )
434   )
435
436
437 ;;;;;;;;;;;; PS
438 (define (ps-scm action-name)
439
440
441   ;; alist containing fontname -> fontcommand assoc (both strings)
442   (define font-alist '())
443   (define font-count 0)
444   (define current-font "")
445
446   
447   (define (cached-fontname i)
448     (string-append
449      "lilyfont"
450      (make-string 1 (integer->char (+ 65 i)))))
451     
452   (define (mag-to-size m)
453     (number->string (case m 
454                       (0 12)
455                       (1 12)
456                       (2 14) ; really: 14.400
457                       (3 17) ; really: 17.280
458                       (4 21) ; really: 20.736
459                       (5 24) ; really: 24.888
460                       (6 30) ; really: 29.856
461                       )))
462   
463   
464   (define (select-font font-name-symbol)
465     (let*
466         (
467          (c (assoc font-name-symbol font-name-alist))
468          )
469
470       (if (eq? c #f)
471           (begin
472             (ly-warn (string-append
473                       "Programming error: No such font known " (car font-name-symbol)))
474             "")                         ; issue no command
475           (string-append " " (cdr c) " "))
476       
477       
478       ))
479
480     (define (font-load-command name-mag command)
481       (string-append
482        "/" command
483        " { /"
484        (symbol->string (car name-mag))
485        " findfont "
486        (number->string (magstep (cdr name-mag)))
487        " 1000 div 12 mul  scalefont setfont } bind def "
488        "\n"))
489
490
491   (define (beam width slope thick)
492     (string-append
493      (numbers->string (list width slope thick)) " draw_beam" ))
494
495   (define (comment s)
496     (string-append "% " s))
497
498   (define (bracket arch_angle arch_width arch_height width height arch_thick thick)
499     (string-append
500      (numbers->string (list arch_angle arch_width arch_height width height arch_thick thick)) " draw_bracket" ))
501
502   (define (char i)
503     (invoke-char " show" i))
504
505   (define (crescendo thick w h cont )
506     (string-append 
507      (numbers->string (list w h (inexact->exact cont) thick))
508      " draw_crescendo"))
509
510   (define (dashed-slur thick dash l)
511     (string-append 
512      (apply string-append (map control->string l)) 
513      (number->string thick) 
514      " [ "
515      (if (> 1 dash)
516          (number->string (- (* thick dash) thick))
517          "0")
518      " "
519      (number->string (* 2 thick))
520      " ] 0 draw_dashed_slur"))
521
522   (define (decrescendo thick w h cont)
523     (string-append 
524      (numbers->string (list w h (inexact->exact cont) thick))
525      " draw_decrescendo"))
526
527
528   (define (end-output)
529     "\nshowpage\n")
530   
531   (define (experimental-on) "")
532   
533   (define (filledbox breapth width depth height) 
534     (string-append (numbers->string (list breapth width depth height))
535                    " draw_box" ))
536
537   ;; obsolete?
538   (define (font-def i s)
539     (string-append
540      "\n/" (font i) " {/" 
541      (substring s 0 (- (string-length s) 4))
542      " findfont 12 scalefont setfont} bind def \n"))
543
544   (define (font-switch i)
545     (string-append (font i) " "))
546
547   (define (header-end)
548     (string-append
549      (ly-gulp-file "lilyponddefs.ps")
550      " {exch pop //systemdict /run get exec} "
551      (ly-gulp-file "lily.ps")
552      "{ exch pop //systemdict /run get exec } "
553     ))
554   
555   (define (lily-def key val)
556
557      (if (string=? (substring key 0 (min (string-length "mudelapaper") (string-length key))) "mudelapaper")
558          (string-append "/" key " {" val "} bind def\n")
559          (string-append "/" key " (" val ") def\n")
560          )
561      )
562
563   (define (header creator generate) 
564     (string-append
565      "%!PS-Adobe-3.0\n"
566      "%%Creator: " creator generate "\n"))
567   
568   (define (invoke-char s i)
569     (string-append 
570      "(\\" (inexact->string i 8) ") " s " " ))
571   
572   (define (invoke-dim1 s d) 
573     (string-append
574      (number->string (* d  (/ 72.27 72))) " " s ))
575
576   (define (placebox x y s) 
577     (string-append 
578      (number->string x) " " (number->string y) " {" s "} placebox "))
579
580   (define (bezier-sandwich l thick)
581     (string-append 
582      (apply string-append (map control->string l))
583      (number->string  thick)
584      " draw_bezier_sandwich"))
585
586   (define (start-line height)
587     (begin
588       "\nstart_line {\n"))
589   
590   (define (stem breapth width depth height) 
591     (string-append (numbers->string (list breapth width depth height))
592                    " draw_box" ))
593
594   (define (stop-line)
595       "}\nstop_line\n")
596
597   (define (text s)
598     (string-append "(" s ") show  "))
599
600
601   (define (volta h w thick vert_start vert_end)
602     (string-append 
603      (numbers->string (list h w thick (inexact->exact vert_start) (inexact->exact vert_end)))
604      " draw_volta"))
605
606   (define (tuplet ht gap dx dy thick dir)
607     (string-append 
608      (numbers->string (list ht gap dx dy thick (inexact->exact dir)))
609      " draw_tuplet"))
610
611
612   (define (unknown) 
613     "\n unknown\n")
614
615
616   ;; PS
617   (cond ((eq? action-name 'all-definitions)
618          `(begin
619             (define beam ,beam)
620             (define tuplet ,tuplet)
621             (define bracket ,bracket)
622             (define char ,char)
623             (define crescendo ,crescendo)
624             (define volta ,volta)
625             (define bezier-sandwich ,bezier-sandwich)
626             (define dashed-slur ,dashed-slur) 
627             (define decrescendo ,decrescendo) 
628             (define end-output ,end-output)
629             (define experimental-on ,experimental-on)
630             (define filledbox ,filledbox)
631             (define font-def ,font-def)
632             (define font-switch ,font-switch)
633             (define header-end ,header-end)
634             (define lily-def ,lily-def)
635             (define font-load-command ,font-load-command)
636             (define header ,header) 
637             (define invoke-char ,invoke-char) 
638             (define invoke-dim1 ,invoke-dim1)
639             (define placebox ,placebox)
640             (define select-font ,select-font)
641             (define start-line ,start-line)
642             (define stem ,stem)
643             (define stop-line ,stop-line)
644             (define stop-last-line ,stop-line)
645             (define text ,text)
646             ))
647         ((eq? action-name 'tuplet) tuplet)
648         ((eq? action-name 'beam) beam)
649         ((eq? action-name 'bezier-sandwich) bezier-sandwich)
650         ((eq? action-name 'bracket) bracket)
651         ((eq? action-name 'char) char)
652         ((eq? action-name 'crescendo) crescendo)
653         ((eq? action-name 'dashed-slur) dashed-slur) 
654         ((eq? action-name 'decrescendo) decrescendo)
655         ((eq? action-name 'experimental-on) experimental-on)
656         ((eq? action-name 'filledbox) filledbox)
657         ((eq? action-name 'select-font) select-font)
658         ((eq? action-name 'volta) volta)
659         (else (error "unknown tag -- PS-SCM " action-name))
660         )
661   )
662
663
664 (define (gulp-file name)
665   (let* ((port (open-file name "r"))
666          (content (let loop ((text ""))
667                        (let ((line (read-line port)))
668                             (if (or (eof-object? line)
669                                     (not line)) 
670                                 text
671                                 (loop (string-append text line "\n")))))))
672         (close port)
673         content))
674
675 (define (scm-gulp-file name)
676   (set! %load-path 
677         (cons (string-append 
678                (getenv 'LILYPONDPREFIX) "/ps") %load-path))
679   (let ((path (%search-load-path name)))
680        (if path
681            (gulp-file path)
682            (gulp-file name))))
683
684 (define (scm-tex-output)
685   (eval (tex-scm 'all-definitions)))
686                                 
687 (define (scm-ps-output)
688   (eval (ps-scm 'all-definitions)))
689
690                                 
691 ; Russ McManus, <mcmanus@IDT.NET>  
692
693 ; I use the following, which should definitely be provided somewhere
694 ; in guile, but isn't, AFAIK:
695
696
697
698 (define (hash-table-for-each fn ht)
699   (do ((i 0 (+ 1 i)))
700       ((= i (vector-length ht)))
701     (do ((alist (vector-ref ht i) (cdr alist)))
702         ((null? alist) #t)
703       (fn (car (car alist)) (cdr (car alist))))))
704
705 (define (hash-table-map fn ht)
706   (do ((i 0 (+ 1 i))
707        (ret-ls '()))
708       ((= i (vector-length ht)) (reverse ret-ls))
709     (do ((alist (vector-ref ht i) (cdr alist)))
710         ((null? alist) #t)
711       (set! ret-ls (cons (fn (car (car alist)) (cdr (car alist))) ret-ls)))))
712
713
714 ;; guile-1.3.4 has list->string
715 (define (scmlist->string exp)
716   (list->string exp))
717
718 ;; obsolete, maybe handy for testing
719 ;; print a SCM expression.  Isn't this part of the std lib?
720 (define (xxscmlist->string exp)
721   (cond
722    ((null? (car exp)) (begin (display ("urg:") (newline))))
723    ((pair? (cdr exp)) (string-append (scm->string (car exp)) " " (scmlist->string (cdr exp))))
724    ((eq? '() (cdr exp)) (string-append (scm->string (car exp)) ")"))
725    ;; howto check for quote?
726    (else (string-append (scm->string (car exp)) " . " (scm->string (cdr exp)) ")"))
727    ))
728
729 (define (scm->string exp)
730   (cond
731    ((pair? exp) (string-append "(" (scmlist->string exp)))
732    ((number? exp) (number->string exp))
733    ((symbol? exp) (symbol->string exp))
734    ((string? exp) (string-append "\"" exp "\""))
735    ;; probably: #@quote
736    (else (begin (display "programming error: scm->string: ") (newline) "'"))
737    ))
738