Re: [racket-dev] submodule in macro
There seems to be a problem with `expand' and `quote'd module names. You can work around the problem by using `(submod . tmp-module-name)'. At Mon, 28 Jan 2013 03:30:21 -0500, Stephen Chang wrote: Actually, moving the rename to the require doesnt work either. But now there's a different error. Welcome to DrRacket, version 5.3.2.2 [3m]. Language: racket [custom]. . . ..\..\plt\collects\racket\require-transform.rkt:266:2: syntax-local-module-exports: unknown module module name: #resolved-module-path:'tmp-module-name On Sat, Jan 26, 2013 at 6:55 AM, Matthew Flatt mfl...@cs.utah.edu wrote: At Sat, 26 Jan 2013 01:12:04 -0500, Stephen Chang wrote: Is this a supported use of submodules? #lang racket (define-syntax (def-wrapped stx) (syntax-case stx () [(_ (f arg ...) body ...) #'(begin (module tmp-module-name racket (define (f-tmp arg ...) (displayln wrapper) body ...) (provide (rename-out [f-tmp f]))) (require (quote tmp-module-name)))])) (def-wrapped (f x) (+ x 1)) (f 100) Welcome to DrRacket, version 5.3.1.3 [3m]. Language: racket [custom]. . f: unbound identifier in module in: f Your `require' is macro-introduced, so it only binds uses that are also macro-introduced. Try renaming on import, since the rename target is an identifier supplied to the macro: #lang racket (define-syntax (def-wrapped stx) (syntax-case stx () [(_ (f arg ...) body ...) #'(begin (module tmp-module-name racket (define (f-tmp arg ...) (displayln wrapper) body ...) (provide f-tmp)) (require (rename-in (quote tmp-module-name) [f-tmp f])))])) (def-wrapped (f x) (+ x 1)) (f 100) _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] submodule in macro
At Sat, 26 Jan 2013 10:36:52 -0500, Matthias Felleisen wrote: [[ I don't really understand the answer. I mean I understand the technicality but not the spirit. ]] The 'f' comes from the macro input in both cases. Hence the rename-out could be seen as the actual name required. Exports from a module are keyed on symbols, not identifiers. In contrast, exports from a `racket/package' package are keyed on identifiers: #lang racket (require racket/package) (define-syntax (def-wrapped stx) (syntax-case stx () [(_ (f arg ...) body ...) #'(begin (define-package tmp-package (f) (define (f-tmp arg ...) (displayln wrapper) body ...) (define*-syntaxes (f) (make-rename-transformer #'f-tmp))) (open-package tmp-package))])) (def-wrapped (f x) (+ x 1)) (f 100) On Jan 26, 2013, at 6:55 AM, Matthew Flatt wrote: At Sat, 26 Jan 2013 01:12:04 -0500, Stephen Chang wrote: Is this a supported use of submodules? #lang racket (define-syntax (def-wrapped stx) (syntax-case stx () [(_ (f arg ...) body ...) #'(begin (module tmp-module-name racket (define (f-tmp arg ...) (displayln wrapper) body ...) (provide (rename-out [f-tmp f]))) (require (quote tmp-module-name)))])) (def-wrapped (f x) (+ x 1)) (f 100) Welcome to DrRacket, version 5.3.1.3 [3m]. Language: racket [custom]. . f: unbound identifier in module in: f Your `require' is macro-introduced, so it only binds uses that are also macro-introduced. Try renaming on import, since the rename target is an identifier supplied to the macro: #lang racket (define-syntax (def-wrapped stx) (syntax-case stx () [(_ (f arg ...) body ...) #'(begin (module tmp-module-name racket (define (f-tmp arg ...) (displayln wrapper) body ...) (provide f-tmp)) (require (rename-in (quote tmp-module-name) [f-tmp f])))])) (def-wrapped (f x) (+ x 1)) (f 100) _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
[racket-dev] Racket learning page videos
I recently came across a presentation on the Racket way by Matthew Flatt ( http://www.infoq.com/presentations/Racket) and thought that it would be nice to be able to discover this and similar things more easily. I really like how all the publications are available on the Racket learning page. Would it be a good idea to also add links to videos such as this one? I also think Racket-con videos (or at least the link to the YouTube channel) would be good to have there. _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Racket learning page videos
On Tue, Jan 29, 2013 at 9:35 AM, Nick Shelley nickmshel...@gmail.com wrote: I recently came across a presentation on the Racket way by Matthew Flatt (http://www.infoq.com/presentations/Racket) and thought that it would be nice to be able to discover this and similar things more easily. I really like how all the publications are available on the Racket learning page. Would it be a good idea to also add links to videos such as this one? I also think Racket-con videos (or at least the link to the YouTube channel) would be good to have there. I like this idea. It does seem like this kind of page would be more dynamic than the static pages on the main web site. Maybe it could fit into the wiki at https://github.com/plt/racket/wiki, and then if the content crystalizes, then reorganized into the main site? _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Racket learning page videos
Maybe the main site could just point to the wiki for extra learning materials. On Tue, Jan 29, 2013 at 2:18 PM, Danny Yoo d...@hashcollision.org wrote: On Tue, Jan 29, 2013 at 9:35 AM, Nick Shelley nickmshel...@gmail.com wrote: I recently came across a presentation on the Racket way by Matthew Flatt (http://www.infoq.com/presentations/Racket) and thought that it would be nice to be able to discover this and similar things more easily. I really like how all the publications are available on the Racket learning page. Would it be a good idea to also add links to videos such as this one? I also think Racket-con videos (or at least the link to the YouTube channel) would be good to have there. I like this idea. It does seem like this kind of page would be more dynamic than the static pages on the main web site. Maybe it could fit into the wiki at https://github.com/plt/racket/wiki, and then if the content crystalizes, then reorganized into the main site? _ Racket Developers list: http://lists.racket-lang.org/dev
[racket-dev] union-find
I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] long double for racket
On Mon, Jan 28, 2013 at 8:18 PM, Matthew Flatt mfl...@cs.utah.edu wrote: At Sat, 29 Dec 2012 14:05:08 +0300, Michael Filonenko wrote: I have prepared a new version of the patch (attached). Thanks! A question on the design here: why not make extflonums part of the numeric tower? Also, when are extflonums *not* likely to be available? Only on non-x86 processors? Sam _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
On Tue, Jan 29, 2013 at 4:20 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: This is probably a silly question, but don't you also need some way to check if two sets have been unioned? Does your application not need that? You check to see if their canonical element is the same. Robby Sam On Tue, Jan 29, 2013 at 4:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
But I should probably provide that, since it can be done more reliably inside the library. Robby On Tue, Jan 29, 2013 at 6:46 PM, Robby Findler ro...@eecs.northwestern.eduwrote: On Tue, Jan 29, 2013 at 4:20 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: This is probably a silly question, but don't you also need some way to check if two sets have been unioned? Does your application not need that? You check to see if their canonical element is the same. Robby Sam On Tue, Jan 29, 2013 at 4:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
On Tue, Jan 29, 2013 at 4:23 PM, Danny Yoo d...@hashcollision.org wrote: On Tue, Jan 29, 2013 at 2:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. More code reviewing: As far as I can tell, the main difference is that in your instance, there's one less pointer per node. This is at the cost of a required runtime type check that can distinguish between boxes and uf-set instances. In the Wikipedia example, because each node has a separate parent pointer field that's guaranteed to point to a node, the lookup doesn't need as many runtime type-checking capabilities: it just needs memory equality to tell when to stop hunting upward. It would require profiling to determine which strategy is more costly. Oh, no, that's not the difference. I'll change the code to avoid the extra test. The difference I see is that union requires a find in the wikipedia version. I don't understand that, but it might have something to do with the idea that all objects are somehow automatically singleton sets (maybe? But that doesn't quite make sense to me either.) Robby _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
But wouldn't that equate two un-unioned invocations of (uf-new 1)? On Tue, Jan 29, 2013 at 7:47 PM, Robby Findler ro...@eecs.northwestern.edu wrote: But I should probably provide that, since it can be done more reliably inside the library. Robby On Tue, Jan 29, 2013 at 6:46 PM, Robby Findler ro...@eecs.northwestern.edu wrote: On Tue, Jan 29, 2013 at 4:20 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: This is probably a silly question, but don't you also need some way to check if two sets have been unioned? Does your application not need that? You check to see if their canonical element is the same. Robby Sam On Tue, Jan 29, 2013 at 4:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
Thanks. That's a bug. uf-set-canonical! changes the canonical element of the set (without affecting the identity of the set). Robby On Tue, Jan 29, 2013 at 4:13 PM, Danny Yoo d...@hashcollision.org wrote: On Tue, Jan 29, 2013 at 2:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. Code reviewing... I don't understand line 31 yet. http://git.racket-lang.org/plt/blob/33747ec9abc5f03d1b838aae11474351d5a6b534:/collects/data/union- find.rkt#l31 How can the rank decrease back to one? Isn't that supposed to be this instead? (set-uf-set-rank! a (add1 a-rank)) I'm assuming that uf-set-x is either going to be another uf-set, or a box. Is that right? I do not understand what uf-set-canonical! is for yet; the test case doesn't tell me too much. _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
I understood you to be asking for something like this: (check-equal? (uf-same-set? (uf-new 1) (uf-new 2)) #f) (check-equal? (uf-same-set? (uf-new 1) (uf-new 1)) #f) (check-equal? (let ([a (uf-new 1)] [b (uf-new 1)]) (uf-union! a b) (uf-same-set? a b)) #t) No? On Tue, Jan 29, 2013 at 6:51 PM, Sam Tobin-Hochstadt sa...@ccs.neu.eduwrote: But wouldn't that equate two un-unioned invocations of (uf-new 1)? On Tue, Jan 29, 2013 at 7:47 PM, Robby Findler ro...@eecs.northwestern.edu wrote: But I should probably provide that, since it can be done more reliably inside the library. Robby On Tue, Jan 29, 2013 at 6:46 PM, Robby Findler ro...@eecs.northwestern.edu wrote: On Tue, Jan 29, 2013 at 4:20 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: This is probably a silly question, but don't you also need some way to check if two sets have been unioned? Does your application not need that? You check to see if their canonical element is the same. Robby Sam On Tue, Jan 29, 2013 at 4:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] union-find
Yes, exactly. I meant that the strategy of just checking the canonical element would have the problem I described -- having an operation for that would fix it. Sam On Tue, Jan 29, 2013 at 7:57 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I understood you to be asking for something like this: (check-equal? (uf-same-set? (uf-new 1) (uf-new 2)) #f) (check-equal? (uf-same-set? (uf-new 1) (uf-new 1)) #f) (check-equal? (let ([a (uf-new 1)] [b (uf-new 1)]) (uf-union! a b) (uf-same-set? a b)) #t) No? On Tue, Jan 29, 2013 at 6:51 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: But wouldn't that equate two un-unioned invocations of (uf-new 1)? On Tue, Jan 29, 2013 at 7:47 PM, Robby Findler ro...@eecs.northwestern.edu wrote: But I should probably provide that, since it can be done more reliably inside the library. Robby On Tue, Jan 29, 2013 at 6:46 PM, Robby Findler ro...@eecs.northwestern.edu wrote: On Tue, Jan 29, 2013 at 4:20 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: This is probably a silly question, but don't you also need some way to check if two sets have been unioned? Does your application not need that? You check to see if their canonical element is the same. Robby Sam On Tue, Jan 29, 2013 at 4:51 PM, Robby Findler ro...@eecs.northwestern.edu wrote: I've just pushed an implementation of the union-find algorithm to the data/ collection. I didn't do it quite the way wikipedia recommends, but instead made the sets be little containers whose canonical element can be mutated. This suits my purposes well, but I wanted to ask if someone on the list knows why the wikipedia way is better. Also, I wasn't sure about the names, so I put uf- on the front of everything to discourage people from using this when they really want racket/set. Maybe there is a better way, tho? Robby _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] Racket learning page videos
I agree. Listing important videos on unlikely-to-go-away sites seems important. Robby On Tue, Jan 29, 2013 at 4:44 PM, Matthias Felleisen matth...@ccs.neu.eduwrote: 1. Pointing to the wiki from racket-lang.org is a good idea. 2. But I agree with the original proposal that we really may wish to list key videos at the main site directly. It is a service to our community. -- Matthias _ Racket Developers list: http://lists.racket-lang.org/dev _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] differences in error reporting
Update: it happens also for system supplied functions, for example (car 3) displays the same behavior. However, it happens always, when certain programs are in the editor, and never with others. I don't see a pattern. At this moment I cannot attach a file which causes this (am typing in a phone...) will send an example tomorrow. P. 2013/1/30, Robby Findler ro...@eecs.northwestern.edu: I don't see that with this program: #lang racket (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append n)) ((negative? n) (apply string-append NEGATIVVS 1)) (else NVLLA))) Welcome to DrRacket, version 5.3.2.3--2013-01-29(32529d89/d) [3m]. Language: racket; memory limit: 128 MB. (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 On Tue, Jan 29, 2013 at 4:33 PM, Pierpaolo Bernardi olopie...@gmail.comwrote: If I use raise-argument-error in my functions, like this: (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append (positive-integer-roman n))) ((negative? n) (apply string-append NEGATIVVS (positive-integer-roman (- n (else NVLLA))) I get errors like this: Welcome to DrRacket, version 5.3.2.2--2013-01-26(88404f3/a) [3m]. Language: racket [custom]. (integer-roman 3.3) integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . C:\Program Files\Racket-Full-5.3.2.2\collects\racket\private\more-scheme.rkt:263:2: integer-roman: contract violation expected: integer? given: 3.3 That is, from the second time on I get the extraneous prefix. Is this expected? P. _ Racket Developers list: http://lists.racket-lang.org/dev -- Inviato dal mio dispositivo mobile _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] differences in error reporting
Update 2: it does not depend on buffer content. I have 9 tab open in this DrRacket. In 5 of them happen the strange message, in 4 of them it doesn't happen. I tried closing one in which it happened and then reopening the same file in a new tab, and in the new tab it doesn't happen. 2013/1/30, Robby Findler ro...@eecs.northwestern.edu: I don't see that with this program: #lang racket (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append n)) ((negative? n) (apply string-append NEGATIVVS 1)) (else NVLLA))) Welcome to DrRacket, version 5.3.2.3--2013-01-29(32529d89/d) [3m]. Language: racket; memory limit: 128 MB. (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 On Tue, Jan 29, 2013 at 4:33 PM, Pierpaolo Bernardi olopie...@gmail.comwrote: If I use raise-argument-error in my functions, like this: (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append (positive-integer-roman n))) ((negative? n) (apply string-append NEGATIVVS (positive-integer-roman (- n (else NVLLA))) I get errors like this: Welcome to DrRacket, version 5.3.2.2--2013-01-26(88404f3/a) [3m]. Language: racket [custom]. (integer-roman 3.3) integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . C:\Program Files\Racket-Full-5.3.2.2\collects\racket\private\more-scheme.rkt:263:2: integer-roman: contract violation expected: integer? given: 3.3 That is, from the second time on I get the extraneous prefix. Is this expected? P. _ Racket Developers list: http://lists.racket-lang.org/dev -- Inviato dal mio dispositivo mobile _ Racket Developers list: http://lists.racket-lang.org/dev
Re: [racket-dev] differences in error reporting
AHA! You got it! It happens in the tabs which have 'No debugging...' checked, and doesn't happen otherwise. 2013/1/30, Robby Findler ro...@eecs.northwestern.edu: What is the custom part of the language settings you have on? Robby On Tue, Jan 29, 2013 at 7:47 PM, Pierpaolo Bernardi olopie...@gmail.comwrote: Update 2: it does not depend on buffer content. I have 9 tab open in this DrRacket. In 5 of them happen the strange message, in 4 of them it doesn't happen. I tried closing one in which it happened and then reopening the same file in a new tab, and in the new tab it doesn't happen. 2013/1/30, Robby Findler ro...@eecs.northwestern.edu: I don't see that with this program: #lang racket (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append n)) ((negative? n) (apply string-append NEGATIVVS 1)) (else NVLLA))) Welcome to DrRacket, version 5.3.2.3--2013-01-29(32529d89/d) [3m]. Language: racket; memory limit: 128 MB. (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . integer-roman: contract violation expected: integer? given: 3.3 On Tue, Jan 29, 2013 at 4:33 PM, Pierpaolo Bernardi olopie...@gmail.comwrote: If I use raise-argument-error in my functions, like this: (define (integer-roman n) (cond ((not (integer? n)) (raise-argument-error 'integer-roman integer? n)) ((positive? n) (apply string-append (positive-integer-roman n))) ((negative? n) (apply string-append NEGATIVVS (positive-integer-roman (- n (else NVLLA))) I get errors like this: Welcome to DrRacket, version 5.3.2.2--2013-01-26(88404f3/a) [3m]. Language: racket [custom]. (integer-roman 3.3) integer-roman: contract violation expected: integer? given: 3.3 (integer-roman 3.3) . . C:\Program Files\Racket-Full-5.3.2.2\collects\racket\private\more-scheme.rkt:263:2: integer-roman: contract violation expected: integer? given: 3.3 That is, from the second time on I get the extraneous prefix. Is this expected? P. _ Racket Developers list: http://lists.racket-lang.org/dev -- Inviato dal mio dispositivo mobile -- Inviato dal mio dispositivo mobile _ Racket Developers list: http://lists.racket-lang.org/dev