Today I wrote some example code for trying out `serial-lambda` from `(require web-server/lang/serial-lambda)`. Here is what I currently have:
~~~~ #lang racket (require web-server/lang/serial-lambda) (require racket/serialize) (define to-send (serial-lambda (x) (* x x))) (define to-send-2 (serial-lambda (place-id data) (list 'result place-id (for/list ([i (range 1000)] [elem (in-cycle data)]) (* i elem))))) (define to-send-3 (serial-lambda (place-id data custom-proc) (list 'result place-id (custom-proc (for*/list ([i (range 1000)] [elem data]) (* i elem)))))) (define (custom-proc lst) (map (λ (x) (* 2 x)) lst)) (to-send 4) (fprintf (current-output-port) "Serialized lambda:~a~n" (serialize to-send)) (fprintf (current-output-port) "Deserialized Serialized lambda: ~a~n" (deserialize (serialize to-send))) (fprintf (current-output-port) "Deserialized Serialized lambda of 4: ~a~n" ((deserialize (serialize to-send)) 4)) (fprintf (current-output-port) "Deserialized Serialized lambda of 4: ~a~n" ((deserialize (serialize to-send-2)) 3 '(0 1 2 3))) (fprintf (current-output-port) "lenght Deserialized Serialized lambda of 4: ~a~n" (length (caddr ((deserialize (serialize to-send-2)) 3 '(0 1 2 3))))) (fprintf (current-output-port) "lenght Deserialized Serialized lambda of 4: ~a~n" ((deserialize (serialize to-send-3)) 3 '(0 1 2 3) custom-proc)) (fprintf (current-output-port) "lenght Deserialized Serialized lambda of 4: ~a~n" (length (caddr ((deserialize (serialize to-send-3)) 3 '(0 1 2 3) custom-proc)))) ~~~~ Which I can simply run with `racket serial-lambda-example.rkt`. Some time ago I started a project called "work-distributor" (https://github.com/ZelphirKaltstahl/work-distributor), which I want to be usable in a way, that users can simply give some lambda to the distributor and some data, so that the distributor then creates as many places as specified and distributes the data and lambda to these places. Then the places should apply the lambda to their portion of the data and return the results, which the work distributor would merge and return to the user / caller. So far the theory. As it turns out I cannot send lambdas on place channels (https://docs.racket-lang.org/reference/places.html?q=place-message-allowed%3F#%28def._%28%28lib._racket%2Fplace..rkt%29._place-message-allowed~3f%29%29), so the first issue is, that I have to use an import (require web-server/lang/serial-lambda)to use something from a completely unrelated package, in order to get a lambda, which can be serialized and then send that on the place channel. That would not be so bad, if it was constrained to that one usage, when the user builds their lambda, which is going to be given to the work distributor, so that the work distributor can go on and send it to places. In a user program however, such serial-lambda seems to be "infectious": - What if in that serial-lambda the user needs to use some custom procedure? Does that suddenly also have to be serializable? What about its "dependencies"? --> everything in the user program ends up being a serial-lambda. That would be really bad. - OK, lets say the procedure is visible from the places ... I cannot seriously require the user of the work distributor to go into the code of the work distributor and add custom procedures there. That would be like requiring them to write custom parallelization code. Maybe I am missing something simple in this whole line of thought. - Is there a better way than requiring everything to be serial-lambda? - Is there a better way than requiring the user to edit the work distributor code to make custom procedures available to the places? - Is the idea to have lambdas be serializable by default language wide insane? It would be great to be able to simply start a new place and give it some arbitrary lambda to execute. -- 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.