[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU Guile 2.1.7 released (beta)
From: |
Daniel Llorens |
Subject: |
Re: GNU Guile 2.1.7 released (beta) |
Date: |
Tue, 28 Feb 2017 02:49:51 +0100 |
On 28 Feb 2017, at 01:04, David Pirotte <address@hidden> wrote:
> Hi Andy,
>
>> So! Release blockers.
>> ...
>
> Not a blocker, at all, but I was thinking to this, wrt manipulating (very)
> large
> vectors, arrays, lists ...
>
> -] repl - truncated-print
>
> Right now I edit the installed (system repl common), and wrote a tip in
> Guile-CV's
> manual so users can do that as well: less then optimal :). It would be nice
> to
> provide an option, so users could set it 'just like that', in the repl, or as
> a
> global config in their .guile (I did see lloda does that in his for arrays,
> but it's
> not an obvious option to set, it is a 'sophisticated' little piece of code
> (for an
> end-user at least)).
I think this is the minimum for .guile:
(import (system repl common) (ice-9 format))
(repl-default-option-set! 'print (lambda (repl val) (format #t "address@hidden"
val)))
That doesn't seem so bad. For the current repl you can do:
(repl-option-set! (car (fluid-ref *repl-stack*)) 'print (lambda (repl val)
(format #t "address@hidden" val)))
We could have shortcuts, something like:
; not in current Guile
(repl-default-print-truncate! 200)
(repl-print-truncate! (current-repl) 200)
What do you think?
I'm guilty of finding these things by googling mailing lists and browsing the
Guile source... repl-default-option-set! is documented, but
repl-option-set!/ref isn't. There seems to be a chunk of text missing here:
https://www.gnu.org/software/guile/manual/html_node/System-Commands.html
There's one thing that I realized recently, that something like #1:5(a b c d e)
or address@hidden:5(a b c d e) is actually valid read syntax, although #:5(a b
c d e) is invalid, not sure if it should be. (Of course the truncated-print
output doesn't *have* to be readable.) So it may be a good idea to print
truncated arrays/vectors/etc that way, maybe even by default.
> -] error(s) while manipulating (very) large vectors or arrays
>
> Unlike the above, it appears there is currently no way to have error (the
> procedure)
> and raised exceptions in general, to use truncated-print, it would be cool to
> 'link'
> the above option so error reports use it as well.
Agreed, this is a serious issue for me. Unfortunately the current API lets the
error reporter decide how to print the arguments using a format string (cf
scm_error) so you have to work around that.
The hack I posted recently to guile-devel was buggy, so I'll repeat it here
without the bug. It needs this patch:
http://git.savannah.gnu.org/gitweb/?p=guile.git;a=commitdiff;h=6118d9dd0cc7733ca71c6b803a942a15f463663a
and this code in .guile:
; Truncate output on exceptions. Requires exception-format to be used in
ice-9/boot.scm.
; FIXME doesn't handle e.g. "x~~~s" -> "address@hidden"
(define (rewrite-fmt fmt)
(let loop ((f "") (b 0))
(let ((next (string-contains-ci fmt "~s" b)))
(if next
(loop
(if (or (zero? next) (not (char=? #\~ (string-ref fmt (- next 1)))))
(string-append f (substring fmt b next) "address@hidden")
f)
(+ next 2))
(string-append f (substring fmt b))))))
(define (truncate-format port fmt . args)
(apply format port (rewrite-fmt fmt) args))
(set! exception-format truncate-format)
This can't work in general, since the call to scm_error may decide to use ~a
instead of ~s, etc. I'd limit further what can go into that format string.
But I would welcome a proper solution.
Regards
—lloda
- Re: GNU Guile 2.1.7 released (beta), (continued)
- Re: GNU Guile 2.1.7 released (beta), Andy Wingo, 2017/02/24
- Re: GNU Guile 2.1.7 released (beta), Arne Babenhauserheide, 2017/02/24
- Re: GNU Guile 2.1.7 released (beta), Thomas Morley, 2017/02/27
- Re: GNU Guile 2.1.7 released (beta), Andy Wingo, 2017/02/28
- Re: GNU Guile 2.1.7 released (beta), David Kastrup, 2017/02/28
- Re: GNU Guile 2.1.7 released (beta), Andy Wingo, 2017/02/28
Re: GNU Guile 2.1.7 released (beta), David Pirotte, 2017/02/27
- Re: GNU Guile 2.1.7 released (beta),
Daniel Llorens <=