This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: *print-right-margin* ineffective for write


On 12/01/2011 02:52 PM, Charles Turner wrote:
On 01/12/11 17:39, Taylor Venable wrote:
Is there a way to turn this automatic breaking off so that output just
runs on and on?

When writing to strings or files, you get what I think is the desired behaviour. For instance,

(call-with-output-string (lambda (str) (output-some-stuff str))

will ignore the *print-right-margin*, amongst other pretty-printing
related parameters.

*print-right-margin* affects file ports:


#|kawa:1|# (import (net metasyntax list))
#|kawa:2|# (define *out* (open-output-file "tmp"))
#|kawa:3|# (fluid-let ((*print-right-margin* 40)) (write (seq 0 100) *out*))
#|kawa:4|# (close-output-port *out*)

$ cat tmp
(0 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 45 46 47 48 49 50 51 52 53 54
55 56 57 58 59 60 61 62 63 64 65 66 67
68 69 70 71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90 91 92 93
94 95 96 97 98 99 100)

#|kawa:5|# (define *out* (open-output-file "tmp"))
#|kawa:6|# (write (seq 0 100) *out*)
#|kawa:7|# (close-output-port *out*)

$ cat tmp
(0 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 45 46 47 48 49 50 51 52 53 54
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100)


But you're right that it doesn't affect string ports. FWIW, I think that's the Right Thing (to affect file ports, but not string ports).

I agree that negative values are good to identify when *print-right-margin* should be disabled; perhaps additionally:

#f = disable (same as e.g. -1 or -42)
#t = enable w/ hard-coded default (same as #!null)

It makes the code a tiny bit more complicated (can't just call #toString and then Integer.parseInt) but to me at least it makes sense.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]