Re: [Chicken-users] Wrapping C's printf
> A pure Scheme implementation that (IIRC) comes relatively close to > C's printf is part of slib: [...] Or, if only basic support for sequences such as "%d" and "%s" is needed, this should be very easy to implement on top of format-modular: (use format-modular) (define printf-formatter (make-format-function #f #\% `(((#\D ,(formatter-padded display)) (#\S ,(formatter-padded display)) (define (printf . args) (apply printf-formatter #t args)) (define (sprintf . args) (apply printf-formatter #f args)) You can then do: (printf "There are %d %s, its halloween!\n" 4 "pirates") (sprintf "There are %d %s, its halloween!\n" 4 "pirates") Of course, if you actually want to support things like "%04d" with the exactsame syntax as C's printf does it gets a little bit hairy (but it's perfectly doable, you'll just have to copy formatter-padded and tweak it somewhat). Hmm, perhaps we should add printf and sprintf to format-modular and start adding more printf-esque escape sequences? Or perhaps make a separate 'printf' egg with them? Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Updated installation of Svnwiki
Hi. Mario and I have just updated the version of Svnwiki in Galinha to the latest. This should have some minor user interface improvements and bug fixes. If you notice anything unusual, please let me know. Thanks! Alejo. http://azul.freaks-unidos.net/ ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] print returns void
In svn r6219 print was changed to return void at all times. Just wondering what prompted this change as it was useful for quick debugging, i.e. replace x with (print x) without affecting your results. ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
Ozzi wrote: > Thomas Christian Chust wrote: > >> I think it would suffice for daemonize to wrap the call to the daemon's >> main procedure in a dynamic-wind block and call the cleanup function >> from the exit thunk. Unless the daemon procedure terminates itself with >> a low-level _exit or by sending itself a kill signal, the cleanup code >> should then always be executed. > > > Ok, I think I understand what you're getting it. Unfortunately I can't > get it to work. You'll have to excuse the thrown-together quality of the > code below, but it demonstrates the problem I have. Perhaps I am just > mis-using dynamic-wind, or I have to use something besides (exit) when > catching the kill signal, I'm not sure. > [...] Oops 8-( On my machine this fails as well -- I was apparently mistaken thinking that (exit) would honor dynamic-wind guards. In that case you could still use (on-exit CLEANUP-PROC), though. cu, Thomas ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On Wed, Oct 31, 2007 at 12:09:27PM +0100, felix winkelmann wrote: > On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > > > > Well, so be it. I'll add a note to 'extensions to the standard' and the > > documentation of 'exit' because I'm sure there are more people out there > > who are not aware of this. > > This has nothing to do with the standard. "exit" is not a standard procedure. I understand that, but as I said before it is possible to read the standard in such a way that there is no possibility to ever execute a thunk without also executing the 'after' part. So the nonstandard 'exit' procedure interacts with the standard dynamic-wind procedure in a way that may or may not be expected depending on how you read the standard. > Adding a note to the actual "exit" documentation is of course fine. Note that > this is a highly subjective matter, and just because you think it is natural > to do X, it doesn't necessarily have to be so for others. Absolutely. The key word is 'necessarily'. It may or it may not be expected. It is important to make the documentation crystal clear so that there will be no misundertandings. For people who understand it the way you do (as opposed to the way I do), the extra note will just a be a bit of additional clutter they can skip over when reading it. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth pgpOPjVKqpz0Z.pgp Description: PGP signature ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > > Well, so be it. I'll add a note to 'extensions to the standard' and the > documentation of 'exit' because I'm sure there are more people out there > who are not aware of this. This has nothing to do with the standard. "exit" is not a standard procedure. Adding a note to the actual "exit" documentation is of course fine. Note that this is a highly subjective matter, and just because you think it is natural to do X, it doesn't necessarily have to be so for others. Personally, if I say "(exit)" I want to exit and not run through whatever handlers have been set up, there is too much hidden state expecting. The exit is explicit, not implicit (by falling off the end). Hooking into the exit procedures is possible via various means, if one wants to perform some cleanup. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On Wed, Oct 31, 2007 at 11:23:59AM +0100, felix winkelmann wrote: > > Why wouldn't it if you use dynamic-wind? The thunk is exited by > > calling (exit), isn't it? So I would *expect* it to call the 'after' > > part of the dynamic-wind. Just from reading the standard I would never > > consider the possibility that a program ever leaves the thunk without > > calling the 'after' part. > > > > People use dynamic-wind because they *want* the 'after' part to be called > > whenever the thunk is exited. > > > > > I guess we disagree here. Well, so be it. I'll add a note to 'extensions to the standard' and the documentation of 'exit' because I'm sure there are more people out there who are not aware of this. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth pgpSFLgctP6im.pgp Description: PGP signature ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > On Wed, Oct 31, 2007 at 10:24:44AM +0100, felix winkelmann wrote: > > On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > > > > > > > > The "exit" will not invoke any pending dynamic-wind thunks > > > > > > Why not? Shouldn't it? IMHO it violates POLA not to do so. > > > > Because it might not be desired. > > Why wouldn't it if you use dynamic-wind? The thunk is exited by > calling (exit), isn't it? So I would *expect* it to call the 'after' > part of the dynamic-wind. Just from reading the standard I would never > consider the possibility that a program ever leaves the thunk without > calling the 'after' part. > > People use dynamic-wind because they *want* the 'after' part to be called > whenever the thunk is exited. > I guess we disagree here. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On Wed, Oct 31, 2007 at 10:24:44AM +0100, felix winkelmann wrote: > On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > > > > > > The "exit" will not invoke any pending dynamic-wind thunks > > > > Why not? Shouldn't it? IMHO it violates POLA not to do so. > > Because it might not be desired. Why wouldn't it if you use dynamic-wind? The thunk is exited by calling (exit), isn't it? So I would *expect* it to call the 'after' part of the dynamic-wind. Just from reading the standard I would never consider the possibility that a program ever leaves the thunk without calling the 'after' part. People use dynamic-wind because they *want* the 'after' part to be called whenever the thunk is exited. > It shouldn't. And I don't know who POLA is, nor did I meeet her before. $ wtf is POLA POLA: principle of least astonishment Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth pgpWy7EVmf7uD.pgp Description: PGP signature ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On 10/31/07, Peter Bex <[EMAIL PROTECTED]> wrote: > > > > The "exit" will not invoke any pending dynamic-wind thunks > > Why not? Shouldn't it? IMHO it violates POLA not to do so. Because it might not be desired. It shouldn't. And I don't know who POLA is, nor did I meeet her before. cheers, felix ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] daemonize egg: redirect I/O?
On Wed, Oct 31, 2007 at 07:44:19AM +0100, felix winkelmann wrote: > On 10/31/07, Ozzi <[EMAIL PROTECTED]> wrote: > > > > Ok, I think I understand what you're getting it. Unfortunately I can't get > > it to > > work. You'll have to excuse the thrown-together quality of the code below, > > but > > it demonstrates the problem I have. Perhaps I am just mis-using > > dynamic-wind, or > > I have to use something besides (exit) when catching the kill signal, I'm > > not sure. > > > > The "exit" will not invoke any pending dynamic-wind thunks Why not? Shouldn't it? IMHO it violates POLA not to do so. Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth pgp5OzvgVSZaM.pgp Description: PGP signature ___ Chicken-users mailing list Chicken-users@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-users