Thanks for your response!

> 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.

Sounds reasonable to me.

> 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 :)

> 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.

Michael


> On Jun 20, 2016, at 7:54 AM, Peter Bex <[email protected]> wrote:
> 
> 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: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to