[racket] GUI, places, exe

From: Roman Klochkov (kalimehtar at mail.ru)
Date: Sat Feb 15 10:17:49 EST 2014

 I replaced every

(dynamic-place "test-place.rkt" 'worker)

with 

(get-test-place)

and added
---
(provide get-test-place)
(define (get-test-place) (place ch (worker ch)))
---
to test-place.rkt

and
---
(require "test-place.rkt")
--
to test.rkt

Now it seems to work. I hope, no incompatibilities will be encountered.

Суббота, 15 февраля 2014, 8:12 -07:00 от Matthew Flatt <mflatt at cs.utah.edu>:
>Since "test.rkt" refers to "test-place.rkt" only dynamically, `raco
>exe` can't tell that "test-place.rkt" needs to be included in the
>executable.
>
>You can set up a connection that `raco exe` sees by using
>`define-runtime-module-path-index'.
>
>Unfortunately, I see that using a module path index is tricky, because
>`dynamic-place` wants a module path instead of a module path index.
>(Probably we should improve `dynamic-place`.) the example below shows
>how to convert.
>
> test.rkt
> --------
> #lang racket/gui
> (require racket/runtime-path)
>
> (define-runtime-module-path-index test-place "test-place.rkt")
> (define test-place-module
>   ;; `dynamic-place` needs a module path, not a module path index:
>   (let ([n (resolved-module-path-name
>             (module-path-index-resolve test-place))])
>     (if (path? n)
>         n
>         `(quote ,n))))
>
> (define (main)
>   (define p
>     (dynamic-place test-place-module 'worker))
>   (place-channel-put p 1)
>   (place-channel-get p))
>
> (main)
>
>At Sat, 15 Feb 2014 18:33:16 +0400, Roman Klochkov wrote:
>>  test.rkt
>> -----
>> #lang racket/gui
>> 
>> (define (main)
>>   (define p
>>     (dynamic-place "test-place.rkt" 'worker))
>>   (place-channel-put p 1)
>>   (place-channel-get p))
>> 
>> (main)
>> 
>> test-place.rkt
>> -----
>> #lang racket/base
>> (require racket/place)
>> (provide worker)
>> 
>> (define (worker ch)
>>   (define in (place-channel-get ch))
>>   (place-channel-put ch (+ in 1)))
>> 
>> ----
>> Run test.rkt in DrRacket. OK. Gives 2.
>> 
>> Create excutable / Distribution. Got test.zip. Unpack it to C:\test. Run
>> Fail. Gives
>> 
>> default-load-handler: cannot open module file
>>   module path: #<path:C:\test\test-place.rkt>
>>   path: C:\test\test-place.rkt
>>   system error: File not found; errno=2
>>   context...:
>>    standard-module-name-resolver
>> 
>> 
>> Суббота, 15 февраля 2014, 6:55 -07:00 от Matthew Flatt < mflatt at cs.utah.edu >:
>> >At Sat, 15 Feb 2014 16:14:51 +0400, Roman Klochkov wrote:
>> >>  When I try to use places with racket/gui in one file, it gives me a error, 
>> >> because of double gui initialization.
>> >> 
>> >> When I use places in separate file via dynamic-place, it works, until I 
>> make 
>> >> an executable.
>> >> Then the executable requests all sources for my place.rkt, uncluding all 
>> >> required collects.
>> >> 
>> >> Am I doing something wroing? Please help!
>> >
>> >Can you provide an example?
>> >
>> >I tried:
>> >
>> > x.rkt
>> > -----
>> > #lang racket/gui
>> > (require "y.rkt")
>> > (module+ main (go))
>> >
>> > y.rkt
>> > -----
>> > #lang racket
>> > (provide go)
>> > (define (go) (place-wait (place p 10)))
>> >
>> >and "x.rkt" works both when run directory or as separate executable.
>> >
>> >In contrast,
>> >
>> > z.rkt
>> > -----
>> > #lang racket/gui
>> > (define (go) (place-wait (place p 10)))
>> > (module+ main (go))
>> >
>> >fails in both modes (as you report and as expected).
>> >
>> 
>> 
>> -- 
>> Roman Klochkov


-- 
Roman Klochkov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140215/a0e6b5f8/attachment-0001.html>

Posted on the users mailing list.