Re: [racket-users] "Live" REPL to cooperate with event loops?

2017-12-10 Thread Greg Hendershott
Although I haven't tried to put the pieces together to do this, I
_think_ the pieces are:

1. It's easy to make a "REPL server". Following the early sections of
the tutorial from https://docs.racket-lang.org/more/index.html you
could something like the following. (For production you might want to
go further into the tutorial and e.g. use custodians.)

#lang racket/base

(require racket/tcp)

(define (serve port)
  (define listener (tcp-listen port 5 #t))
  (let loop ()
(accept-and-handle listener)
(loop)))

(define (accept-and-handle listener)
  (define-values (in out) (tcp-accept listener))
  (parameterize ([current-input-port  in]
 [current-output-port out])
(read-eval-print-loop))
  (close-input-port in)
  (close-output-port out))


2. When you connect to that REPL server, at its prompt you could use
`dynamic-rerequire` to (re)load your code.

https://docs.racket-lang.org/reference/interactive.html#%28def._%28%28lib._racket%2Frerequire..rkt%29._dynamic-rerequire%29%29


As I mentioned on IRC last night before I had to run, one example of
wrapping up dynamic-rerequire is the racket-reloadable package:

https://github.com/tonyg/racket-reloadable


I hope this helps a little? If not hopefully someone with more
hands-on experience could chime in.

(I love the idea of live-coding music and games! But how I actually
use Racket, my comfort zone is "version-controlled source files are
the single source of recreatable truth". So, I don't have a lot of
mileage with this.)

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] "Live" REPL to cooperate with event loops?

2017-12-09 Thread Christopher Lemmer Webber
Hello!  I'm fairly new to Racket, but not to Scheme.  I'm very impressed
with everything that's available.

One thing I miss from Guile is the cooperative REPL support:
  
https://www.gnu.org/software/guile/manual/html_node/Cooperative-REPL-Servers.html

It's possible to spawn a REPL that runs in such a way that coordinates
with an event loop, or (egads) runs inside its own thread.  This turns
out to be very helpful when doing web development or game
development... *especially* networked game development.  If you see the
video on this page (scroll down a bit):

  https://www.gnu.org/software/8sync/

you can see me giving a talk where the talk is itself a multiplayer text
adventure, in which the audience is participating.  Thanks to Guile's
cooperative REPL, I'm able to change components of the world in response
to players' suggestions, without kicking everyone out.

I looked and I couldn't find such a thing in Racket.  Does it exist and
I'm just missing it?  How hard would it be to integrate with a program?

Thanks!
 - Christopher Lemmer Webber

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.