<div dir="ltr">Yay!<br><br>A caveat: I've never touched iOS, but some event-based systems will not call back unless an event for which you have registered is triggered.  In games, where you redraw the whole screen many times per second this is not a problem, since the 'draw' callbacks should give plenty of opportunity for Scheme land code to run.  But in a more static GUI application this might not be the case.  It could be that the REPL freezes until the user interacts with the app window in some way.  Hence the suggestion for timer or idle handlers.<br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 8, 2014 at 11:56 AM, Álvaro Castro-Castilla <span dir="ltr"><<a href="mailto:alvaro.castro.castilla@gmail.com" target="_blank">alvaro.castro.castilla@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><div class="">On Fri, Aug 8, 2014 at 1:19 AM, Estevo <span dir="ltr"><<a href="mailto:euccastro@gmail.com" target="_blank">euccastro@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>One thing I'd try would be to launch a gambit thread running ##repl-debug-main and set up a timer or idle handler in the main gambit thread that just 'thread-sleep!'s for a small amount of time.  Hopefully experimentation yields a delay that is small enough to be unnoticeable in your application, but large enough to give the REPL enough time to do its work.  If you use a timer for this (or, I imagine, if you handle timers in Gambit at all), the trick to run it in the same OS thread would be required.  I don't know, from the top of my head, whether and how SDL does idle events.<br>



<br></div>A fancier approach would be to look up the implementation of ##repl-debug-main and try and see if there are any hooks by which the trick I mentioned in the previous message could be enabled.  If there are not, you could try running your own modified version of ##repl-debug-main (factoring out the hooks that would enable the just-wait-for-as-long-as-the-REPL-is-doing-actual-work trick would be a nice contribution to gambit IMHO).<br>



</div><br></blockquote></div><div><br>Thanks all for your insights and help :)<br><br>I found a solution, which is very simple: just create the REPL thread, then create the SDL Cocoa draw loop callback, and finally let the main function return. Since the callback is going to 
be called repeatedly by iOS, the REPL thread will be resumed since it 
didn't terminate. The key insight is realizing that the current thread in 
Scheme returns to C, but the other threads will continue their execution
 as soon as you come back to Scheme. <br><br></div><div>It works now, with both custom application loops and event-loop hooks models.<br></div></div></div></div>
</blockquote></div><br></div>