Re: "Live coding" on Mac OS X

2021-05-27 Thread Kristian Lein-Mathisen
Hi Arnaud,

I know I'm a bit late here, but did you get this working? When you say "not
working", what is/isn't happening? Is it your REPL that's not responding,
or your game-thread?

Sometimes these things are caused by the REPL i/o blocking the game-thread.
That is, the read on stdin from the main thread is blocking the
game-threads Perhaps that is what you are seeing. If so, just giving the
REPL a newline should unfreeze the game-thread.

For various technical reasons, this blocking i/o is often less
problematical on a REPL that's over a network port instead of just stdin.
You could try hosting the repl with the nrepl egg, start it outside of
emacs, and connect to it from emacs with `C-u run-scheme nc localhost 1234`
for example.

This sort of thing is a pretty common problem, unfortunately, were srfi-18
threads can easily block each other. Here is one session where we worked
through this. Maybe the code here might be helpful to you:
https://paste.call-cc.org/paste?id=dc1ec82557b9ea5846ec976a9987d53d83f401e3

K.

On Tue, May 11, 2021, 16:26 Arnaud Bailly  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
>
> Thanks for your answer Vasilij!
>
> You're right, this works when I copy/paste in the REPL And define from
> there, but not when I evaluate it from Emacs buffer.
> I am using basic scheme-mode with run-scheme function and using C-M-x to
> evaluate top-level definition and send it to the REPL which "should" work
> but seems like it's not.
>
> - --
> - --
> Arnaud Bailly - @dr_c0d3
>
> On 2021-05-11 at 14:16, m...@vasilij.de wrote:
> > Hello Arnaud,
> >
> > > But it's not working properly: What I observe is that when I change a
> > > procedure that's called from the background thread, the thread becomes
> > > blocked. Is this some new behaviour that's not taken into account in
> > > those posts?
> >
> > It's tricky to reproduce such issues without a minimal repro. I wrote my
> > own and I do not experience such behavior. When I run the attached file
> > with `csi -:x test.scm`, I see it printing 1 every 10s. I can then
> > copy-paste `(define (game-loop-iteration) (print 2))` into the REPL and
> > if I wait another 10 seconds, it prints 2. Do you have the same
> > behavior? If yes, then chances are it's the fault of the code change
> > (for example it might perform a thread blocking operation).
> >
> > > $ csi -version
> > > CHICKEN
> > > (c) 2008-2020, The CHICKEN Team
> > > (c) 2000-2007, Felix L. Winkelmann
> > > Version 5.2.0 (rev 317468e4)
> > > macosx-unix-clang-x86-64 [ 64bit dload ptables ]
> > >
> > > I am on Mac OS X Catalina 10.15.7.
> >
> > I'm on the same CHICKEN version, but on Arch Linux.
> >
> > Vasilij
> -BEGIN PGP SIGNATURE-
> Version: FlowCrypt Email Encryption 8.0.6
> Comment: Seamlessly send and receive encrypted email
>
> wsFzBAEBCAAGBQJgmpP7ACEJEAgADOwkMld2FiEENp8aNWMznkzbE41KCAAM
> 7CQyV3bwGA//djzC+xN0djgNOs29OWsCPayOnVTZg1UN138Onk72m6QzaDs2
> DozVEWL11hg2uJOvOQVDWSYdPFdau6+gIdsK3MIHmrREhYknMU3zp5S7axVg
> 8zT3sU3451/6LHLxpnv8ObmuwBEzGXfxj4UieXlWv7pVkhbFxSLy0n8JJtAN
> z6Dbt3l/WDjRPYqAJGiQo0AapZqVmRRcXGSa4z7pcBPY2dbHPVuxAP4/vLuN
> 43zZDQ+em7oKn5Q7k7tLXF+Ho3/0AX04Cd8pS1TERp+mAAuKqRK52mIKxpoh
> nQHewJxLuklaQdATI6uuzPmTQUkGYVzoWmgsSfqy0eRnSNtymLgAs/roWkrD
> /fgw2A81VTb4Q+D8rEQ7E/pIk4ARUH7yRM8UTbB/l5pAdjGlJfgbz0A35eLy
> ENsCUU7x/jnWPJuhe2Oa0JSwOhsS6Bz4vie1CpsDRJftqr+jyg+E3Wg/32sw
> ECuWO/+uDHUYYsoannCwuSuZA/OZe51F0V2FuwqYYkSLL16oBJ665CzWtnpX
> bfSuj8ACe5qD4zGOQlfVVQeFD4ig/etjkHpKHTctGq1cPa9v6VCHUr+CiDJm
> JuyKEhKO5LYW23IapTfoyS9o30yv3HYfaKVSrz5KbaoPsbFBYI3SMmV5V2PP
> yxDja2AuMAp0v+McZi5+AzR1yRUWs70kWUk=
> =5yE8
> -END PGP SIGNATURE-
>


Re: "Live coding" on Mac OS X

2021-05-11 Thread Vasilij Schneidermann
Hello Arnaud,

> But it's not working properly: What I observe is that when I change a
> procedure that's called from the background thread, the thread becomes
> blocked. Is this some new behaviour that's not taken into account in
> those posts?

It's tricky to reproduce such issues without a minimal repro. I wrote my
own and I do not experience such behavior. When I run the attached file
with `csi -:x test.scm`, I see it printing 1 every 10s. I can then
copy-paste `(define (game-loop-iteration) (print 2))` into the REPL and
if I wait another 10 seconds, it prints 2. Do you have the same
behavior? If yes, then chances are it's the fault of the code change
(for example it might perform a thread blocking operation).

> $ csi -version
> CHICKEN
> (c) 2008-2020, The CHICKEN Team
> (c) 2000-2007, Felix L. Winkelmann
> Version 5.2.0 (rev 317468e4)
> macosx-unix-clang-x86-64 [ 64bit dload ptables ]
> 
> I am on Mac OS X Catalina 10.15.7.

I'm on the same CHICKEN version, but on Arch Linux.

Vasilij
(import scheme)
(import (chicken base))
(import (srfi 18))

(define (game-loop-iteration)
  (print 1))

(define (main)
  (let loop ()
(game-loop-iteration)
(thread-sleep! 10)
(loop)))

(define game-thread (thread-start! main))

(cond-expand
 ((or chicken-script compiling)
  (thread-join! game-thread))
 (else))

(cond-expand
 (csi (import live-define))
 (else))

#;
(when (eqv? 'terminated (thread-state game-thread))
  (set! game-thread (thread-start! main)))


signature.asc
Description: PGP signature


Re: "Live coding" on Mac OS X

2021-05-11 Thread Arnaud Bailly
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Thanks for your answer Vasilij!

You're right, this works when I copy/paste in the REPL And define from
there, but not when I evaluate it from Emacs buffer.
I am using basic scheme-mode with run-scheme function and using C-M-x to
evaluate top-level definition and send it to the REPL which "should" work
but seems like it's not.

- --
- --
Arnaud Bailly - @dr_c0d3

On 2021-05-11 at 14:16, m...@vasilij.de wrote:
> Hello Arnaud,
>
> > But it's not working properly: What I observe is that when I change a
> > procedure that's called from the background thread, the thread becomes
> > blocked. Is this some new behaviour that's not taken into account in
> > those posts?
>
> It's tricky to reproduce such issues without a minimal repro. I wrote my
> own and I do not experience such behavior. When I run the attached file
> with `csi -:x test.scm`, I see it printing 1 every 10s. I can then
> copy-paste `(define (game-loop-iteration) (print 2))` into the REPL and
> if I wait another 10 seconds, it prints 2. Do you have the same
> behavior? If yes, then chances are it's the fault of the code change
> (for example it might perform a thread blocking operation).
>
> > $ csi -version
> > CHICKEN
> > (c) 2008-2020, The CHICKEN Team
> > (c) 2000-2007, Felix L. Winkelmann
> > Version 5.2.0 (rev 317468e4)
> > macosx-unix-clang-x86-64 [ 64bit dload ptables ]
> >
> > I am on Mac OS X Catalina 10.15.7.
>
> I'm on the same CHICKEN version, but on Arch Linux.
>
> Vasilij
-BEGIN PGP SIGNATURE-
Version: FlowCrypt Email Encryption 8.0.6
Comment: Seamlessly send and receive encrypted email

wsFzBAEBCAAGBQJgmpP7ACEJEAgADOwkMld2FiEENp8aNWMznkzbE41KCAAM
7CQyV3bwGA//djzC+xN0djgNOs29OWsCPayOnVTZg1UN138Onk72m6QzaDs2
DozVEWL11hg2uJOvOQVDWSYdPFdau6+gIdsK3MIHmrREhYknMU3zp5S7axVg
8zT3sU3451/6LHLxpnv8ObmuwBEzGXfxj4UieXlWv7pVkhbFxSLy0n8JJtAN
z6Dbt3l/WDjRPYqAJGiQo0AapZqVmRRcXGSa4z7pcBPY2dbHPVuxAP4/vLuN
43zZDQ+em7oKn5Q7k7tLXF+Ho3/0AX04Cd8pS1TERp+mAAuKqRK52mIKxpoh
nQHewJxLuklaQdATI6uuzPmTQUkGYVzoWmgsSfqy0eRnSNtymLgAs/roWkrD
/fgw2A81VTb4Q+D8rEQ7E/pIk4ARUH7yRM8UTbB/l5pAdjGlJfgbz0A35eLy
ENsCUU7x/jnWPJuhe2Oa0JSwOhsS6Bz4vie1CpsDRJftqr+jyg+E3Wg/32sw
ECuWO/+uDHUYYsoannCwuSuZA/OZe51F0V2FuwqYYkSLL16oBJ665CzWtnpX
bfSuj8ACe5qD4zGOQlfVVQeFD4ig/etjkHpKHTctGq1cPa9v6VCHUr+CiDJm
JuyKEhKO5LYW23IapTfoyS9o30yv3HYfaKVSrz5KbaoPsbFBYI3SMmV5V2PP
yxDja2AuMAp0v+McZi5+AzR1yRUWs70kWUk=
=5yE8
-END PGP SIGNATURE-


0x08000CEC24325776.asc
Description: application/pgp-keys


"Live coding" on Mac OS X

2021-05-11 Thread Arnaud Bailly
Hello,

I am a chicken noob (and so far loving it). I am trying to do some
live coding/hot reloading like it's explained in this blog post by
Kooda https://www.upyum.com/en/post/7.xhtml and this video
https://www.youtube.com/watch?v=eXB3I3S3vJc
But it's not working properly: What I observe is that when I change a
procedure that's called from the background thread, the thread becomes
blocked. Is this some new behaviour that's not taken into account in
those posts?

$ csi -version
CHICKEN
(c) 2008-2020, The CHICKEN Team
(c) 2000-2007, Felix L. Winkelmann
Version 5.2.0 (rev 317468e4)
macosx-unix-clang-x86-64 [ 64bit dload ptables ]

I am on Mac OS X Catalina 10.15.7.

Thanks for your help.
-- 
Arnaud Bailly - @dr_c0d3