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: Wed, 22 Jun 2016 20:56:35 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On Mon, Jun 20, 2016 at 10:14:52PM -0400, Michael Silver wrote:
> > 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.
> 
> Maybe, but even coming from someone who is porting a huge Guile codebase to 
> CHICKEN, I don’t mind CHICKEN having a different naming for the function. 
> Find and replace is easy :)

Scheme xref says with-error-to-port is supported by Gauche, SCM and Stk:
http://practical-scheme.net/wiliki/schemexref.cgi?with-error-to-port
versus ours, which is only in CHICKEN:
http://practical-scheme.net/wiliki/schemexref.cgi?with-error-output-to-port

I don't know how complete the xref is.  Obviously it's not comprehensive,
because it doesn't mention Guile on the page about with-error-to-string.
But it seems to have the most important implementations.

> > 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…
> 
> Makes sense, but since with-output-to-string requires importing ports, I 
> don’t think its unreasonable to ask for the same for it’s sister function 
> with-error-output-to-string. It makes as much sense to group those two 
> functions together in one unit as it does to group with-output-to-port and 
> with-error-output-to-port, which seems totally fine to me. The ports unit 
> doesn’t seem to have anything relating to file output, but it does have both 
> output and error output to ports, and output to string, but misses error 
> output to string. Looked like an obvious “what’s missing from the pattern” to 
> me, which is why I suggested the patch.

Yeah, it makes the most sense to at least make our own extensions to
the standard internally consistent, even if the standard itself is not
complete in this aspect (r5rs doesn't have current-error-port, r7rs does
have current-error-port but, oddly, no procedures to manipulate it).

Maybe we should add with-error-to-file to chicken.base, or whereever we
put current-error-port?

The attached patch adds with-error-to-string and renames
with-error-output-to-port to with-error-to-port, for chicken-5 only.
We probably shouldn't be adding new procedures to CHICKEN 4 at this
point: any CHICKEN 4 egg that used this would be depending on exactly
one minor release of CHICKEN that supports this.

The patch also tweaks types.db a bit to improve the type for the
*-to-string procedures, indicating they always return one value,
which is always a string.

Thanks for your suggestion, Michael!

Cheers,
Peter

Attachment: 0001-Add-with-error-to-string-and-rename-with-error-outpu.patch
Description: Text Data

Attachment: signature.asc
Description: Digital signature


reply via email to

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