[racket-dev] tiny doc bug?
http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html Towards the bottom of this page there is the following error: (datum-order (make-fish 'alewife) (make-fish 'sockeye)) make-fish: undefined; cannot reference undefined identifier Is this intentional? Thanks, Dave _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] splicing-syntax-parameterize and syntax-parameter-value
Interesting problem. I almost gave up, but I think I've sorted it out --- repair pushed. At Thu, 29 Nov 2012 18:20:18 -0500 (EST), J. Ian Johnson wrote: Simpler example: (require racket/splicing racket/stxparam) (define-syntax-parameter f #f) (define x 0) ;; 0 (syntax-parameterize ([f (make-rename-transformer #'x)]) (splicing-syntax-parameterize ([f (syntax-parameter-value #'f)]) f)) ;; 0 (splicing-syntax-parameterize ([f (make-rename-transformer #'x)]) (syntax-parameterize ([f (syntax-parameter-value #'f)]) f)) ;; error (splicing-syntax-parameterize ([f (make-rename-transformer #'x)]) (splicing-syntax-parameterize ([f (syntax-parameter-value #'f)]) f)) stdin::334: f: bad syntax in: f context...: /home/ianj/racket/collects/racket/splicing.rkt:224:0 /home/ianj/racket/collects/racket/splicing.rkt:177:0 /home/ianj/racket/collects/racket/splicing.rkt:224:0 /home/ianj/racket/collects/racket/splicing.rkt:177:0 /home/ianj/racket/collects/racket/private/misc.rkt:87:7 -Ian - Original Message - From: J. Ian Johnson i...@ccs.neu.edu To: dev dev@racket-lang.org Sent: Thursday, November 29, 2012 4:01:09 PM GMT -05:00 US/Canada Eastern Subject: [racket-dev] splicing-syntax-parameterize and syntax-parameter-value (require racket/stxparam racket/splicing) (define-syntax-parameter f #f) (splicing-syntax-parameterize ([f #t]) (begin-for-syntax (printf ~a~% (syntax-parameter-value #'f))) (void)) This prints #f. If I instead add a macro indirection (define-syntax (blah stx) (syntax-case stx () [(_ f) (printf ~a~% (syntax-parameter-value #'f)) #'(void)])) Then (splicing-syntax-parameterize ([f #t]) (blah f) (void)) prints #t This is messing up some of my syntax parameters that build their definitions from the existing value in the parameter. Why does the first program have this behavior? This feels bug-like to me. -Ian _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Planet 2 Beta Release
On Fri, Nov 30, 2012 at 7:09 PM, Matthew Flatt mfl...@cs.utah.edu wrote: Version-specific installation - Not to speak too much on Jay's behalf, but I think he isn't convinced that the new default is right. If `--shared' is the default, then a `raco pkg update' could be enough to get all your installed packages working with a new version. If installation is instead version-specific, then you have to reinstall every package that you use whenever you upgrade. I think that if installation is all-version by default, then users who are going to end up with bad configurations that they have trouble repairing. A better way to deal with upgrades would be something like `raco pkg migrate'. If we decide that version-specific is the right default to keep, and if some would still like a more convenient way to manage all-version packages, we could add an environment variable that makes `--shared' the default. Something that bothers me a lot of P1 is that when I install an upgrade, I lose all my packages. This means that the documentation search suddenly starts returning different things, so I forget about which packages I had installed at all. I only discover this when I go to write something and have a long install and download process. Or, when I run a script I wrote a long time ago and it doesn't return instantly, but spawns an install. I'm much less worried about Racket versions breaking installed packages than Matthew. I don't think it is that common for core changes to break things and when it does happen, P2 is designed to easily allow you to upgrade all your packages to the latest versions, something that was very inconvenient with P1. I.e. you can do raco pkg update --all, which isn't possible with P1. Jay -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay The glory of God is Intelligence - DC 93 _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] tiny doc bug?
On 12/01/2012 04:23 AM, David Vanderson wrote: http://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html Towards the bottom of this page there is the following error: (datum-order (make-fish 'alewife) (make-fish 'sockeye)) make-fish: undefined; cannot reference undefined identifier Is this intentional? No, it's a bug. I've pushed a fix. Thanks, Ryan _ Racket Developers list: http://lists.racket-lang.org/dev
[racket-dev] Testing whether a procedure gets collected
I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
How about using a weak box instead? Robby On Sat, Dec 1, 2012 at 11:45 AM, Neil Toronto neil.toro...@gmail.com wrote: I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Planet 2 Beta Release
Yesterday, Matthew Flatt wrote: I've been working with Jay on a few more changes: Specifying metadata --- METADATA.rktd is being replaced with info.rkt, which is written in the `setup/infotab' language as usual. Define `deps' for dependencies, like this: #lang setup/infotab (define deps (list _package-source ...)) For a short transition period (maybe a week?), `raco pkg' will continue to recognize METADATA.rktd. Version-specific installation - Package installation is now both user-specific and version-specific by default. The options are * installation-specific * user-specific and version-specific (the new default) * user-specific and all-version (the old default) Use the `--shared' or `-s' flag to get the old all-version behavior. Any previously installed user-specific packages that you have are still in `--shared' mode. Not to speak too much on Jay's behalf, but I think he isn't convinced that the new default is right. If `--shared' is the default, then a `raco pkg update' could be enough to get all your installed packages working with a new version. If installation is instead version-specific, then you have to reinstall every package that you use whenever you upgrade. I think that if installation is all-version by default, then users who are going to end up with bad configurations that they have trouble repairing. A better way to deal with upgrades would be something like `raco pkg migrate'. Just to see if I get the trade-offs right: all-version installs have the advantage of not re-installing things, and the disadvantage of breaking often (for some value of often)? If so, then something that I think is getting popular is keeping a (global) list of all explicitly installed packages, and then the version-specific installs get much easier to deal with because it's easy to crawl over the explicit names and re-install name. Having this only for explicit names meams that I don't need to reinstall old stuff that was installed only for some other package. (But perhaps this is what you talk about with that `migrate' command. If so, then this is just a verbose +1.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Planet 2 Beta Release
Yes, what you describe is what we imagine migrate will do. Jay On Sat, Dec 1, 2012 at 4:10 PM, Eli Barzilay e...@barzilay.org wrote: Yesterday, Matthew Flatt wrote: I've been working with Jay on a few more changes: Specifying metadata --- METADATA.rktd is being replaced with info.rkt, which is written in the `setup/infotab' language as usual. Define `deps' for dependencies, like this: #lang setup/infotab (define deps (list _package-source ...)) For a short transition period (maybe a week?), `raco pkg' will continue to recognize METADATA.rktd. Version-specific installation - Package installation is now both user-specific and version-specific by default. The options are * installation-specific * user-specific and version-specific (the new default) * user-specific and all-version (the old default) Use the `--shared' or `-s' flag to get the old all-version behavior. Any previously installed user-specific packages that you have are still in `--shared' mode. Not to speak too much on Jay's behalf, but I think he isn't convinced that the new default is right. If `--shared' is the default, then a `raco pkg update' could be enough to get all your installed packages working with a new version. If installation is instead version-specific, then you have to reinstall every package that you use whenever you upgrade. I think that if installation is all-version by default, then users who are going to end up with bad configurations that they have trouble repairing. A better way to deal with upgrades would be something like `raco pkg migrate'. Just to see if I get the trade-offs right: all-version installs have the advantage of not re-installing things, and the disadvantage of breaking often (for some value of often)? If so, then something that I think is getting popular is keeping a (global) list of all explicitly installed packages, and then the version-specific installs get much easier to deal with because it's easy to crawl over the explicit names and re-install name. Having this only for explicit names meams that I don't need to reinstall old stuff that was installed only for some other package. (But perhaps this is what you talk about with that `migrate' command. If so, then this is just a verbose +1.) -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: http://barzilay.org/ Maze is Life! _ Racket Developers list: http://lists.racket-lang.org/dev -- Jay McCarthy j...@cs.byu.edu Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay The glory of God is Intelligence - DC 93 _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
Honestly, because I was too rushed to try them before I had to leave this morning. :D However, now that I have the chance, I've found that Typed Racket doesn't support them. I can't add support using `required/typed', because `Weak-Box' would have to be a polymorphic type. Also, they don't seem to let go of procedure values. This one's value doesn't ever turn to #f no matter how many times I collect garbage: (define bx (make-weak-box (λ (_) 0))) Thinking it might be because that lambda doesn't create a closure, I tried this: (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) But this `bx' doesn't let go of its value, either. I can't help but think I'm missing something really stupid, though. Neil ⊥ On 12/01/2012 10:58 AM, Robby Findler wrote: How about using a weak box instead? Robby On Sat, Dec 1, 2012 at 11:45 AM, Neil Toronto neil.toro...@gmail.com wrote: I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
This prints #f for me. #lang racket (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) (collect-garbage) (weak-box-value bx) And I guess that non-closure procedures are held onto by the modules they are inside. This program prints #f for me, and it seems to confirm that hypothesis. #lang racket (define bx (parameterize ([current-namespace (make-base-namespace)]) (eval '(module m racket (define bx (make-weak-box (λ (_) 1))) (provide bx))) (eval '(require 'm)) (eval 'bx))) (collect-garbage) (weak-box-value bx) Robby On Sat, Dec 1, 2012 at 7:30 PM, Neil Toronto neil.toro...@gmail.com wrote: Honestly, because I was too rushed to try them before I had to leave this morning. :D However, now that I have the chance, I've found that Typed Racket doesn't support them. I can't add support using `required/typed', because `Weak-Box' would have to be a polymorphic type. Also, they don't seem to let go of procedure values. This one's value doesn't ever turn to #f no matter how many times I collect garbage: (define bx (make-weak-box (λ (_) 0))) Thinking it might be because that lambda doesn't create a closure, I tried this: (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) But this `bx' doesn't let go of its value, either. I can't help but think I'm missing something really stupid, though. Neil ⊥ On 12/01/2012 10:58 AM, Robby Findler wrote: How about using a weak box instead? Robby On Sat, Dec 1, 2012 at 11:45 AM, Neil Toronto neil.toro...@gmail.com wrote: I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
Ah. It prints #f for me when I have debugging info turned on in DrRacket; otherwise I get #procedure. Must be inlining keeping it around or something. The problem with either finalizers or weak boxes is that neither provides enough guarantees. Finalizers are never guaranteed to be run. A weak box may not be the only reference to a procedure value, depending on what optimizations are done. I'm trying to test something that's normally not supposed to be observable. For now, I've got a finalizer on an array procedure that's created at the beginning of the 1000-line test module, and I test that the finalizer was run at the end. I've also got a (collect-garbage) and a (sleep 0) in there. It works... for now, on my machine. Maybe a weak box containing a random closure would work. Hmm... On 12/01/2012 06:46 PM, Robby Findler wrote: This prints #f for me. #lang racket (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) (collect-garbage) (weak-box-value bx) And I guess that non-closure procedures are held onto by the modules they are inside. This program prints #f for me, and it seems to confirm that hypothesis. #lang racket (define bx (parameterize ([current-namespace (make-base-namespace)]) (eval '(module m racket (define bx (make-weak-box (λ (_) 1))) (provide bx))) (eval '(require 'm)) (eval 'bx))) (collect-garbage) (weak-box-value bx) Robby On Sat, Dec 1, 2012 at 7:30 PM, Neil Toronto neil.toro...@gmail.com wrote: Honestly, because I was too rushed to try them before I had to leave this morning. :D However, now that I have the chance, I've found that Typed Racket doesn't support them. I can't add support using `required/typed', because `Weak-Box' would have to be a polymorphic type. Also, they don't seem to let go of procedure values. This one's value doesn't ever turn to #f no matter how many times I collect garbage: (define bx (make-weak-box (λ (_) 0))) Thinking it might be because that lambda doesn't create a closure, I tried this: (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) But this `bx' doesn't let go of its value, either. I can't help but think I'm missing something really stupid, though. Neil ⊥ On 12/01/2012 10:58 AM, Robby Findler wrote: How about using a weak box instead? Robby On Sat, Dec 1, 2012 at 11:45 AM, Neil Toronto neil.toro...@gmail.com wrote: I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
On 12/01/2012 07:05 PM, Neil Toronto wrote: Ah. It prints #f for me when I have debugging info turned on in DrRacket; otherwise I get #procedure. Must be inlining keeping it around or something. The problem with either finalizers or weak boxes is that neither provides enough guarantees. Finalizers are never guaranteed to be run. A weak box may not be the only reference to a procedure value, depending on what optimizations are done. I'm trying to test something that's normally not supposed to be observable. [...] Maybe a weak box containing a random closure would work. Hmm... This seems to evaluate to #f under all circumstances: #lang racket (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing (random))) (collect-garbage) (weak-box-value bx) I can't think of a way the optimizer could defeat that. It *has* to create a closure... right? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Testing whether a procedure gets collected
I think the high-level answer is that you have to understand something about details that aren't currently specified but nevertheless are how things currently work and then make a test that will work when you make those additional assumptions (and then keep it running in drdr so you can tell when the assumptions get broken). In this case, I think that a weak box is going to work well to test the code you described at the beginning of this thread. That is, create the array; use some internal thing to extract the procedure from it. Put it into a weak-box; change the state; collect garbage, check the box. I think that won't fail unless you let that procedure be reachable from a finalizer or you somehow get it promoted to the master area (between places) .. or there is a bug. :) Robby On Sat, Dec 1, 2012 at 8:05 PM, Neil Toronto neil.toro...@gmail.com wrote: Ah. It prints #f for me when I have debugging info turned on in DrRacket; otherwise I get #procedure. Must be inlining keeping it around or something. The problem with either finalizers or weak boxes is that neither provides enough guarantees. Finalizers are never guaranteed to be run. A weak box may not be the only reference to a procedure value, depending on what optimizations are done. I'm trying to test something that's normally not supposed to be observable. For now, I've got a finalizer on an array procedure that's created at the beginning of the 1000-line test module, and I test that the finalizer was run at the end. I've also got a (collect-garbage) and a (sleep 0) in there. It works... for now, on my machine. Maybe a weak box containing a random closure would work. Hmm... On 12/01/2012 06:46 PM, Robby Findler wrote: This prints #f for me. #lang racket (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) (collect-garbage) (weak-box-value bx) And I guess that non-closure procedures are held onto by the modules they are inside. This program prints #f for me, and it seems to confirm that hypothesis. #lang racket (define bx (parameterize ([current-namespace (make-base-namespace)]) (eval '(module m racket (define bx (make-weak-box (λ (_) 1))) (provide bx))) (eval '(require 'm)) (eval 'bx))) (collect-garbage) (weak-box-value bx) Robby On Sat, Dec 1, 2012 at 7:30 PM, Neil Toronto neil.toro...@gmail.com wrote: Honestly, because I was too rushed to try them before I had to leave this morning. :D However, now that I have the chance, I've found that Typed Racket doesn't support them. I can't add support using `required/typed', because `Weak-Box' would have to be a polymorphic type. Also, they don't seem to let go of procedure values. This one's value doesn't ever turn to #f no matter how many times I collect garbage: (define bx (make-weak-box (λ (_) 0))) Thinking it might be because that lambda doesn't create a closure, I tried this: (define (make-box-thing v) (make-weak-box (λ (_) v))) (define bx (make-box-thing 4)) But this `bx' doesn't let go of its value, either. I can't help but think I'm missing something really stupid, though. Neil ⊥ On 12/01/2012 10:58 AM, Robby Findler wrote: How about using a weak box instead? Robby On Sat, Dec 1, 2012 at 11:45 AM, Neil Toronto neil.toro...@gmail.com wrote: I'm getting ready to push a change to math/array that fixes a memory leak. I've devised a test that I think will determine whether an array's procedure gets collected after the array is made strict, but I don't know whether it works only by accident. Here it is: (define: collected? : (Boxof Boolean) (box #f)) (define arr (let ([proc (λ: ([js : Indexes]) 0)]) ; constant array (register-finalizer proc (λ (proc) (set-box! collected? #t))) (build-array #() proc))) (array-strict! arr) (collect-garbage) (sleep 0) ; give finalizers a chance to run? (check-true (unbox collected?)) This test passes for me now, but will fail if anyone else tries it. What worries me is that (sleep 0) is apparently required, meaning that finalizers aren't run immediately when garbage is collected. How can I ensure that the finalizer for `proc' gets run before I test the value of `collected?'? Neil ⊥ _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev