[racket-users] Racket, Erlang, concurrency and performance

2016-08-13 Thread Cary Cherng
Do Racket places suffer performance-wise in comparison to Erlang in that the 
garbage collector cannot assume that everything in one thread is immutable and 
inaccessible to anyone else so that each thread can have its own garbage 
collector.

-- 
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] HtDP 2e

2016-08-13 Thread Matthias Felleisen

[[ http://www.ccs.neu.edu/home/matthias/HtDP2e/ ]]

Hi everyone, 

I have pushed out the stable release for 2016/17. This release also went to MIT 
Press, which has owned the copyright for some time. Once we agree on the book, 
the final release of HtDP 2e will move to the htdp.org  web 
site. As since 1997, our contract includes a clause that the book stays on the 
web as a free resource. 

As a reminder, the black closing markers of an exercise are actually a link to 
the exercise itself so that instructors can hyperlink it if desired. The 
hyperlinks are unlikely to change for the academic year but the final version 
will move to the .org site and I will eventually take down the draft. 

If I re-release the book at this site in the next nine months, no labels will 
change. 

Thanks to all those who have sent in corrections over the years — Matthias

-- 
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.


Re: [racket-users] Problems with modules and with raco

2016-08-13 Thread Matthew Flatt
Just after sending, I realized that you may be running a program like
"app.rkt" directly with `racket`, and then trying to deserialize from
an application created with `raco exe`. That would fail in much the way
you describe for my example.

If that's the problem, then one possible solution is to generate the
serialized data after creating an executable. Creating the data that
way might not be desirable or practical, though.

Another approach is to use a collection/package. When you create an
executable, `racket` goes out of its way to hide path information from
the original context; that's why data serialized based on running a
file will no deserialize in a `raco exe` executable, because the only
identity of the `serializable-struct` declaration is the filesystem
path of its containing module. In contrast to filesystem path, `raco
exe` preserves collection-mapping information. So, if you serialized
data based on a module referenced through a collection path, it will
work for the `raco exe` executable.

Concretely:

 * Put "app.rkt" in a collection/package. I'll call it "app":

 $ mkdir app
 $ mv app.rkt words.rkt app/
 $ raco pkg install app/

 * Run the application using a module path, as opposed to a filesystem
   path:

 $ racket -l app/app
 ((3) 1 (((lib "app/words.rkt") )

 # Not this way:
 $ racket app/app.rkt
 ((3) 1 ((#"/tmp/app/words.rkt" .)

 * Unfortunately, `raco exe` doesn't currently know how to make an
   executable based on a module path. So, make a module that refers to
   "app.rkt" through it's module path:

 go.rkt:
   #lang racket/base
   (require app/app)

   Then create an executable from "go.rkt":

 $ raco exe go.rkt
 $ raco dist go-dist go
 $ ./go-dist/bin/go

That `./go-dist/bin/go` will work with serialized data produced by
`racket -l app/app`.


Hope that helps,
Matthew


At Sat, 13 Aug 2016 16:25:44 -0600, Matthew Flatt wrote:
> I think we need more of your program to help. In particular, I don't
> know what you have in mind with `(define-namespace-anchor a)`, and I
> wonder whether your program uses `load` or `dynamic-require`.
> 
> 
> I tried completing your example with
> 
> app.rkt:
> 
>  #lang racket
>  (require "words.rkt"
>   racket/serialize)
> 
>  ;; write serialized
>  (writeln (serialize (word 1 2)))
>  ;; read something that must have been previously serialized
>  (deserialize (read (current-input-port)))
> 
>  
> words.rkt:
> 
>  #lang racket
>  (require racket/serialize)
>  (provide (struct-out word))
> 
>  (serializable-struct word
>(type
> ecc.))
> 
> but that works as expected, where the serialized output has something
> like "#%embedded:g2140:words" instead of a path.
> 
> 
> At Fri, 12 Aug 2016 05:53:35 -0700 (PDT), rumpz wrote:
> > app.rkt:
> > 
> > #lang racket
> > (require "words.rkt"
> >  web-server/servlet)
> > 
> > 
> > 
> > 
> > words.rkt:
> > 
> > #lang racket
> > (require racket/serialize)
> > (provide (struct-out word) save-words load-words decline)
> > 
> > (serializable-struct word
> >   (type
> >ecc.))
> > 
> > (define-namespace-anchor a)
> > (define ns (namespace-anchor->namespace a))
> > 
> > 
> > 
> > 
> > If I compile app.rkt with "raco exe app.rkt" and "raco distribute appdir 
> > app"
> > and I move the "appdir" directory to another system, when I run ./app it 
> > crashes with this error:
> > 
> > default-load-handler: cannot open module file
> >   module path: #
> >   path: /home/rumpz/webapp/words.rkt
> >   system error: No such file or directory; errno=2
> >   context...:
> >standard-module-name-resolver
> >/usr/share/racket/collects/racket/private/serialize.rkt:654:8: loop
> >/usr/share/racket/collects/racket/private/serialize.rkt:649:2: 
> > deserialize
> >#%mzc:app: [running body]
> > 
> > 
> > Even if I don't move from my system but just rename words.rkt, it still 
> > crashes. From the examples and the documentation I assumed that raco 
> > automatically included required modules, but it looks like it's just 
> > looking 
> > for the .rkt file (and even with the exact path that it has on the original 
> > system). What am I doing wrong?
> > 
> > Also, a secondary problem with modules that may be related: I've tried to 
> make 
> > a copy of the "webapp" directory, called webapp2. When I launch app from 
> > the 
> > new directory, it loads a list of "word" structures from a file I saved 
> > them 
> > in previously, and try to access them with a "word" field (like 
> > "word-type") 
> > it crashes with:
> > 
> > word-type: contract violation;
> >  given value instantiates a different structure type with the same name
> >   expected: word?
> >   given: #
> > 
> > It's like it marked down somewhere that those structs refer to the 
> definition 
> > of "word" in webapp/words.rkt, and not the one in webapp2/words.rkt
> > 
> > -- 
> > You received this message because you are subscribed 

Re: [racket-users] Problems with modules and with raco

2016-08-13 Thread Matthew Flatt
I think we need more of your program to help. In particular, I don't
know what you have in mind with `(define-namespace-anchor a)`, and I
wonder whether your program uses `load` or `dynamic-require`.


I tried completing your example with

app.rkt:

 #lang racket
 (require "words.rkt"
  racket/serialize)

 ;; write serialized
 (writeln (serialize (word 1 2)))
 ;; read something that must have been previously serialized
 (deserialize (read (current-input-port)))

 
words.rkt:

 #lang racket
 (require racket/serialize)
 (provide (struct-out word))

 (serializable-struct word
   (type
ecc.))

but that works as expected, where the serialized output has something
like "#%embedded:g2140:words" instead of a path.


At Fri, 12 Aug 2016 05:53:35 -0700 (PDT), rumpz wrote:
> app.rkt:
> 
> #lang racket
> (require "words.rkt"
>web-server/servlet)
> 
> 
> 
> 
> words.rkt:
> 
> #lang racket
> (require racket/serialize)
> (provide (struct-out word) save-words load-words decline)
> 
> (serializable-struct word
>   (type
>ecc.))
> 
> (define-namespace-anchor a)
> (define ns (namespace-anchor->namespace a))
> 
> 
> 
> 
> If I compile app.rkt with "raco exe app.rkt" and "raco distribute appdir app"
> and I move the "appdir" directory to another system, when I run ./app it 
> crashes with this error:
> 
> default-load-handler: cannot open module file
>   module path: #
>   path: /home/rumpz/webapp/words.rkt
>   system error: No such file or directory; errno=2
>   context...:
>standard-module-name-resolver
>/usr/share/racket/collects/racket/private/serialize.rkt:654:8: loop
>/usr/share/racket/collects/racket/private/serialize.rkt:649:2: deserialize
>#%mzc:app: [running body]
> 
> 
> Even if I don't move from my system but just rename words.rkt, it still 
> crashes. From the examples and the documentation I assumed that raco 
> automatically included required modules, but it looks like it's just looking 
> for the .rkt file (and even with the exact path that it has on the original 
> system). What am I doing wrong?
> 
> Also, a secondary problem with modules that may be related: I've tried to 
> make 
> a copy of the "webapp" directory, called webapp2. When I launch app from the 
> new directory, it loads a list of "word" structures from a file I saved them 
> in previously, and try to access them with a "word" field (like "word-type") 
> it crashes with:
> 
> word-type: contract violation;
>  given value instantiates a different structure type with the same name
>   expected: word?
>   given: #
> 
> It's like it marked down somewhere that those structs refer to the definition 
> of "word" in webapp/words.rkt, and not the one in webapp2/words.rkt
> 
> -- 
> 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.

-- 
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] Re: Problems with modules and with raco

2016-08-13 Thread rumpz
> This sounds to me like it is using the old bytecode files, since the original 
> files haven't changed. Does removing the compiled/ directory fix this issue?

Just tried it, and it doesnt. 

> What exactly are you doing with the namespace-anchor? Usually, 
> `dynamic-require`

Later in the program I must call eval with the ns arg. Can this be in anyway 
the reason why raco decides not to include words.rkt into the executable?

-- 
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] Re: Problems with modules and with raco

2016-08-13 Thread Dupéron Georges
Le vendredi 12 août 2016 14:53:35 UTC+2, rumpz a écrit :
> It's like it marked down somewhere that those structs refer to the definition 
> of "word" in webapp/words.rkt, and not the one in webapp2/words.rkt

This sounds to me like it is using the old bytecode files, since the original 
files haven't changed. Does removing the compiled/ directory fix this issue?

Le vendredi 12 août 2016 14:53:35 UTC+2, rumpz a écrit :
> (define-namespace-anchor a)
> (define ns (namespace-anchor->namespace a))
> 
> …
> 
> If I compile app.rkt with "raco exe app.rkt" and "raco distribute appdir app"
> and I move the "appdir" directory to another system, when I run ./app it 
> crashes with this error:
> 
> default-load-handler: cannot open module file
>   module path: #

What exactly are you doing with the namespace-anchor? Usually, 
`dynamic-require` and friends play poorly with compilation (since they require 
modules at run-time, the compiler can't easily know statically what files to 
include etc.).

-- 
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.


Re: [racket-users] Mixin questions

2016-08-13 Thread Stephen De Gabrielle
Excellent write-write up !
On Fri, 12 Aug 2016 at 13:40, Matthias Felleisen 
wrote:

>
> You may want to scan this little write-up on first-class classes and
> mixins:
>
>
> http://www.ccs.neu.edu/home/matthias/Thoughts/Programming_with_Class_in_Racket.html
>
> I intended to push into the docs at some point, but we dropped the ball on
> it.
>
>
>
>
> > On Aug 12, 2016, at 8:13 AM, Normal Loone 
> wrote:
> >
> > How do I call the methodes of each mixin? When I tried something like
> (define/public ...) the other mixins could not access these.
> >
> >
> > Am Donnerstag, 11. August 2016 20:19:02 UTC+2 schrieb Robby Findler:
> >> Although, with these two particular interfaces, there is no single
> >> class that implements both. You would instead have two separate mixins
> >> that would communicate by calling each others methods.
> >>
> >> Robby
> >
> > --
> > 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.
>
> --
> 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.
>
-- 
Kind regards,
Stephen
--
Bigger than Scheme, cooler than Clojure & more fun than CL.(n=1)
--

-- 
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.