On 7/1/2021 2:36 PM, David Storrs wrote:
What is the best way to pass a function into a child `place`?

1.  just define the functions in a context the place can see
2.  send the name of a local file for the recipient to dynamic-require
3.  send the definition file for the recipient to save locally and dynamic-require
4.  define the function(s) with serial-lambda and serialize / deserialize


I've got a server function that accepts a dispatch function as one of its arguments and I need to be able to run the server in a separate `place` (in the dynamic-place sense) because it's part of a GUI application. [details]

Not a problem if using /dynamic/  (thread in same process) places.
See
   https://docs.racket-lang.org/reference/places.html
https://docs.racket-lang.org/reference/places.html?q=place#%28part._places-syntax%29

I considered passing a string or symbol list and then eval'ing it in the child place.  I immediately rejected this idea and told my brain that it was being bad and it got no cookies.

You /can/ do that ... but you don't ever have to stoop to eval.

At this point my only remaining idea is to place-channel-(put/get) a module name that can be dynamic-required in the child place in order to get the dispatch function.  Is there a better way?

Depends on whether you're using /dynamic/ (same process) or /distributed/ (separate process) places.

With dynamic places you can (often) just provide the code for the place to execute.  For complicated things you may have to use serial-lambda/serialize/deserialize, but often you can simply provide the necessary functions in context.


[details]
The Racket GUI library has an issue where e.g. launching an 'Open File' dialog will freeze all of Racket until the user closes the dialog.  This can cause the server to time out. Since it's all of Racket that's being frozen and not just the current thread it's necessary to put the server code into an entirely different `place`.

And invalidating any part of the visible window does the same thing until the window is redrawn.


George

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/cc734b4f-f59e-7536-b336-5225ba93752d%40comcast.net.

Reply via email to