Re: [Chicken-users] Live programming with Chicken
Am 03.07.2014 17:34, schrieb Daniel Leslie: Unless I missed a radical change in Chicken, its SRFI-18 threads are green threads and not real system threads. As a result, blocking operations will block all threads and no real gain is had from the hardware's support for multithreading. Because of those issues I suggest avoiding SRFI-18 threads altogether. They aren't worth the hassle. -Dan Depends... If your job is to manage a lot of network i/o or other asynchronous events, what would you do without SRFI-18? Probably write your own event loop. That would be equivalent to green threads in turn. Having said that let me add a note about my personal taste: I'm using a wrapper over SRFI-18 (which could be implemented without SRFI-18) to provide a more Schemish API to threads. Like: (!map proc list) (!apply proc list) Which would do the same thing as map and apply, just returning a promise to the result and apply proc in parallel to the calling thread and (in case of !map) in parallel to all elements in the list. So yes, SRFI-18 is kind of a hassle. But green threads retain their purpose. On 3 Jul 2014 04:13, Kristian Lein-Mathisen kristianl...@gmail.com mailto:kristianl...@gmail.com wrote: That is strange, I've experienced alex's problem too - having to yield a little to give the REPL some room. Anyhow, for others who might come across this thread: alex's idea works great, but you need to be careful with blocking IO on your REPL. If you don't use parley http://api.call-cc.org/doc/parley or something similar, chances are that your REPL srfi-18-thread will block your srfi-18-game-thread while it's waiting for IO. K. On Wed, Jul 2, 2014 at 9:07 PM, John Cowan co...@mercury.ccil.org mailto:co...@mercury.ccil.org wrote: alex scripsit: I had some trouble with this last part at first: the original thread waited several seconds before evaluating my input. I think that the fix was nothing more than calling thread-yield! every loop iteration. If you are depending on thread-yield! for correctness rather than efficiency, you are doing something wrong (but I don't know what). SRFI 18 schedulers are not required to be fair in any way. -- John Cowan http://www.ccil.org/~cowan http://www.ccil.org/%7Ecowan co...@ccil.org mailto:co...@ccil.org He that would foil me must use such weapons as I do, for I have not fed my readers with straw, neither will I be confuted with stubble. --Thomas Vaughan (1650) ___ Chicken-users mailing list Chicken-users@nongnu.org mailto:Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org mailto:Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
That is strange, I've experienced alex's problem too - having to yield a little to give the REPL some room. Anyhow, for others who might come across this thread: alex's idea works great, but you need to be careful with blocking IO on your REPL. If you don't use parley http://api.call-cc.org/doc/parley or something similar, chances are that your REPL srfi-18-thread will block your srfi-18-game-thread while it's waiting for IO. K. On Wed, Jul 2, 2014 at 9:07 PM, John Cowan co...@mercury.ccil.org wrote: alex scripsit: I had some trouble with this last part at first: the original thread waited several seconds before evaluating my input. I think that the fix was nothing more than calling thread-yield! every loop iteration. If you are depending on thread-yield! for correctness rather than efficiency, you are doing something wrong (but I don't know what). SRFI 18 schedulers are not required to be fair in any way. -- John Cowan http://www.ccil.org/~cowanco...@ccil.org He that would foil me must use such weapons as I do, for I have not fed my readers with straw, neither will I be confuted with stubble. --Thomas Vaughan (1650) ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
Unless I missed a radical change in Chicken, its SRFI-18 threads are green threads and not real system threads. As a result, blocking operations will block all threads and no real gain is had from the hardware's support for multithreading. Because of those issues I suggest avoiding SRFI-18 threads altogether. They aren't worth the hassle. -Dan On 3 Jul 2014 04:13, Kristian Lein-Mathisen kristianl...@gmail.com wrote: That is strange, I've experienced alex's problem too - having to yield a little to give the REPL some room. Anyhow, for others who might come across this thread: alex's idea works great, but you need to be careful with blocking IO on your REPL. If you don't use parley http://api.call-cc.org/doc/parley or something similar, chances are that your REPL srfi-18-thread will block your srfi-18-game-thread while it's waiting for IO. K. On Wed, Jul 2, 2014 at 9:07 PM, John Cowan co...@mercury.ccil.org wrote: alex scripsit: I had some trouble with this last part at first: the original thread waited several seconds before evaluating my input. I think that the fix was nothing more than calling thread-yield! every loop iteration. If you are depending on thread-yield! for correctness rather than efficiency, you are doing something wrong (but I don't know what). SRFI 18 schedulers are not required to be fair in any way. -- John Cowan http://www.ccil.org/~cowanco...@ccil.org He that would foil me must use such weapons as I do, for I have not fed my readers with straw, neither will I be confuted with stubble. --Thomas Vaughan (1650) ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
[Chicken-users] Live programming with Chicken
Hello, I wanted to do some live game programming with Chicken Scheme. I would like to adjust my game whilst it is running a game loop. I tried srfi-18 threads for this but found it to be too unwieldy. So I wondered if there is a way to process the repl inside the loop. An example of what I would like: (let loop () (process-repl) ; - this (unless (do-game-stuff) (loop))) I could not find if anything like this exists. Does anybody know of a way? thanks, Pluizer ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
Hi Pluizer, I've tried to make a poll-based repl like you're talking about for the same purpose. Have a look here and see if that helps: https://github.com/Adellica/prepl K. On Wed, Jul 2, 2014 at 12:40 PM, Richard plui...@freeshell.de wrote: Hello, I wanted to do some live game programming with Chicken Scheme. I would like to adjust my game whilst it is running a game loop. I tried srfi-18 threads for this but found it to be too unwieldy. So I wondered if there is a way to process the repl inside the loop. An example of what I would like: (let loop () (process-repl) ; - this (unless (do-game-stuff) (loop))) I could not find if anything like this exists. Does anybody know of a way? thanks, Pluizer ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
Thanks Kristian and Daniel, Both options seem to be the thing I was looking for. I'll test them both and see what I like best. thanks, Richard On 07/02/14 17:43, Kristian Lein-Mathisen wrote: Hi Pluizer, I've tried to make a poll-based repl like you're talking about for the same purpose. Have a look here and see if that helps: https://github.com/Adellica/prepl K. On Wed, Jul 2, 2014 at 12:40 PM, Richard plui...@freeshell.de mailto:plui...@freeshell.de wrote: Hello, I wanted to do some live game programming with Chicken Scheme. I would like to adjust my game whilst it is running a game loop. I tried srfi-18 threads for this but found it to be too unwieldy. So I wondered if there is a way to process the repl inside the loop. An example of what I would like: (let loop () (process-repl) ; - this (unless (do-game-stuff) (loop))) I could not find if anything like this exists. Does anybody know of a way? thanks, Pluizer ___ Chicken-users mailing list Chicken-users@nongnu.org mailto:Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
I have something like this set up on Unix. I start a separate SRFI-18 thread with a procedure that starts the main loop. Then (in the original thread) I call repl. The main loop calls thread-yield! after every iteration to make sure that the original thread evaluates each expression as soon as I press the return key. I had some trouble with this last part at first: the original thread waited several seconds before evaluating my input. I think that the fix was nothing more than calling thread-yield! every loop iteration. —Alex On 2014-07-02 09:42, Richard wrote: Thanks Kristian and Daniel, Both options seem to be the thing I was looking for. I'll test them both and see what I like best. thanks, Richard On 07/02/14 17:43, Kristian Lein-Mathisen wrote: Hi Pluizer, I've tried to make a poll-based repl like you're talking about for the same purpose. Have a look here and see if that helps: https://github.com/Adellica/prepl K. On Wed, Jul 2, 2014 at 12:40 PM, Richard plui...@freeshell.de mailto:plui...@freeshell.de wrote: Hello, I wanted to do some live game programming with Chicken Scheme. I would like to adjust my game whilst it is running a game loop. I tried srfi-18 threads for this but found it to be too unwieldy. So I wondered if there is a way to process the repl inside the loop. An example of what I would like: (let loop () (process-repl) ; - this (unless (do-game-stuff) (loop))) I could not find if anything like this exists. Does anybody know of a way? thanks, Pluizer ___ Chicken-users mailing list Chicken-users@nongnu.org mailto:Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users
Re: [Chicken-users] Live programming with Chicken
alex scripsit: I had some trouble with this last part at first: the original thread waited several seconds before evaluating my input. I think that the fix was nothing more than calling thread-yield! every loop iteration. If you are depending on thread-yield! for correctness rather than efficiency, you are doing something wrong (but I don't know what). SRFI 18 schedulers are not required to be fair in any way. -- John Cowan http://www.ccil.org/~cowanco...@ccil.org He that would foil me must use such weapons as I do, for I have not fed my readers with straw, neither will I be confuted with stubble. --Thomas Vaughan (1650) ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users