chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Add with-error-to-string to ports unit


From: Peter Bex
Subject: Re: [Chicken-hackers] Add with-error-to-string to ports unit
Date: Mon, 20 Jun 2016 13:54:58 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Sun, Jun 19, 2016 at 10:07:03PM -0400, Michael Silver wrote:
> Hello chicken-hackers,
> 
> I think it would be nice to add Guile’s with-error-to-string function to 
> CHICKEN’s ports unit:
> 
> ;; Call procedure THUNK with the current error output-port temporarily
> ;; bound to a string-output-port and return the accumulated output
> ;; string.
> (define with-error-to-string
>   (lambda (thunk)
>     (fluid-let ([##sys#standard-error (open-output-string)])
>       (thunk)
>       (get-output-string ##sys#standard-error))))
> 
> This would neatly compliment the port unit’s with-output-to-string. Thoughts?

We already have with-error-output-to-port, so I think it would be more
consistent to use the name with-error-output-to-string.

Alternatively, we could decide to do this for CHICKEN 5 only, and rename
both procedures to match the Guile naming convention.  Maybe do a survey
of existing implementations that offer such a procedure and see what names
they use.

But it's all rather arbitrary: why is there no with-error-to-file?
And if there were, it would be jarring to have to (import scheme) to
get with-output-to-file, but have to do (import (chicken ports)) to get
with-error-to-file...

Cheers,
Peter

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]