chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] specialized-io egg version discrepancy


From: Matt Gushee
Subject: Re: [Chicken-users] specialized-io egg version discrepancy
Date: Sat, 9 May 2015 14:25:22 -0600

Hi, Jeronimo--

Thanks for your very prompt attention!

On Fri, May 8, 2015 at 9:09 PM, Jeronimo Pellegrini <address@hidden> wrote:

On Fri, May 08, 2015 at 06:48:48PM -0600, Matt Gushee wrote:
> In addition to shadowing the builtin write-string, this write-string causes
> a segfault when I attempt to use it within 'with-output-to-string' in csi.
> Haven't looked into it any further yet, but that doesn't seem very good.

[....]

This seems to work fine:

(use specialized-io)
(define out (open-output-file "out.txt"))
(write-string (with-output-to-string (lambda () (write "xyz") )) out)
(close-output-port out)

... except that it appears to do redundant writes, and is *not* what I was trying to do. As I said in the original post, I was attempting to use write-one-string *within* with-output-to-string, e.g.:

    (define s
        (with-output-to-string
            (lambda () (write-one-string "Blardip!" (current-output-port))))

Mind you, I don't know if I would ever do this in a real program. My reason for trying it was that I wanted to find out exactly what bytes were written - I was wondering if by chance the result would be null-terminated.

I've since looked at your code, and I see that you've implemented write-one-string as a foreign lambda calling fprintf; so I suppose the reason for the segfault was that Chicken string ports are not compatible with fprintf. I guess that's a fair tradeoff for improved performance, but I would suggest that you add a LIMITATIONS section to the documentation, explaining that certain procedures are unsafe, along with whatever details of that unsafety you are aware of.

Also, one more minor issue with the documentation: I happened to notice that you tagged

specialized-io-error

+specialized-io-string-buffer-size+

as [parameter]. But they are not parameters in the Chicken Scheme sense [ref: http://api.call-cc.org/doc/chicken/parameters ], they're just global variables. It might be a good idea to make them parameters, since then they would be thread-local. Either way, they should be documented correctly.

Thanks for your work!

--
Matt Gushee

reply via email to

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