[racket] contracts questions

2014-08-19 Thread Kevin Forchione
Hi guys, In an attempt to tighten up my code I started using the raise--error feature and then began looking at contracts. I like the concept and think it would lead to cleaner looking code But I have two questions: Why does list? allow a vector in the following contract? Also, how do I ind

Re: [racket] bug? bit-vector equal problem

2014-08-19 Thread Greg Hendershott
I submitted a PR with a suggested fix: https://github.com/plt/racket/pull/756 > Looking at bit-vector.rkt, it seems the problem might be the "TODO" > comment here: > > (serializable-struct bit-vector (words size) > > #:methods gen:equal+hash > [(define (equal-proc x y recursive-equal?)

Re: [racket] bug? bit-vector equal problem

2014-08-19 Thread Sam Tobin-Hochstadt
On Tue, Aug 19, 2014 at 10:44 PM, Greg Hendershott wrote: > > But, you say, you're using equal? Although I'm not familiar with > gen:equal+hash, it must be that equal? checks for and uses that. Yep: http://docs.racket-lang.org/reference/booleans.html?q=equal%3F#%28def._%28%28quote._~23~25kernel%

Re: [racket] bug? bit-vector equal problem

2014-08-19 Thread Greg Hendershott
I can repro it on 6.1.0.3. Looking at bit-vector.rkt, it seems the problem might be the "TODO" comment here: (serializable-struct bit-vector (words size) #:methods gen:equal+hash [(define (equal-proc x y recursive-equal?) (let ([vx (bit-vector-words x)] [vy (bit-vector-

[racket] bug? bit-vector equal problem

2014-08-19 Thread Mark Wallace
It seems that "equal?" misbehave on bit-vectors when the size is less then 9. Below is a small test case that show this bug? maybe. Can you guys help to test whether it's only happening on my machine? #lang racket (require data/bit-vector) (define bv1 (make-bit-vector 8 #t)) (define bv2 (make

Re: [racket] Typed classes: how to send to a value with union type

2014-08-19 Thread Asumu Takikawa
On 2014-08-19 14:48:22 -0400, Alexander D. Knauth wrote: > This works fine for me in version 6.1.0.5: > #lang typed/racket > (require typed/racket/snip) > (define snip (new snip%)) > (define admin (send snip get-admin)) > (define editor (and admin (send admin get-editor))) > (when editor > (send

Re: [racket] Typed classes: how to send to a value with union type

2014-08-19 Thread Alexander D. Knauth
This works fine for me in version 6.1.0.5: #lang typed/racket (require typed/racket/snip) (define snip (new snip%)) (define admin (send snip get-admin)) (define editor (and admin (send admin get-editor))) (when editor (send editor set-caret-owner #f)) On Aug 19, 2014, at 1:32 PM, Neil Toronto w

[racket] Typed classes: how to send to a value with union type

2014-08-19 Thread Neil Toronto
I'm making a snip in Typed Racket. I have essentially this: (define admin (send this get-admin)) (define editor (and admin (send admin get-editor))) (when editor (send editor set-caret-owner #f)) I get this error: Type Checker: send: type mismatch expected: an object given:

Re: [racket] Persistent struct API

2014-08-19 Thread Roman Klochkov
Serialize is good for one-shot import/export. By persistence I mean possibility to get objects from persistent storage by reference on-demand. For example I have facebook-like site: (persistent-struct user (login password photo ...)) (persistent-struct message (user text seen-by)) If i read c

Re: [racket] Persistent struct API

2014-08-19 Thread Sam Tobin-Hochstadt
First, for persistence, can you use either prefab structs or the serialize library? If you can't, what I'd do is implement a generic called `persist` using `racket/generic`, and then have all the structs you wanted to be persistent implement that generic. Sam On Tue, Aug 19, 2014 at 10:45 AM, Ro

[racket] Persistent struct API

2014-08-19 Thread Roman Klochkov
So you mean, that struct should be only struct, not like Common Lisp CLOS or C++ classes, that are "anything with fields". Then I need an advice. I want to make persistent structs. There are several options: 1) Build "`struct?' with #:reader and #:writer options". Then I have to make a struct

Re: [racket] struct generics and mutual dependencies

2014-08-19 Thread Jon Zeppieri
Could you elaborate, maybe provide an example? I'm not sure what you have in mind. -Jon On Tue, Aug 19, 2014 at 8:40 AM, Roman Klochkov wrote: > Recommended way for mutual dependencies is to use units: > > http://docs.racket-lang.org/guide/units.html > > You may define struct accessors as unit

Re: [racket] big-bang bug when creating racket distribution executable?

2014-08-19 Thread Matthias Felleisen
I have fixed the bug, thanks to a thorough code review with Robby. The next release of DrRacket will create executables for big-bang (and universe) programs whose window remains open after stop-when (or equivalent action) halt the execution. If you are eager to test this, you may wish to try

Re: [racket] base64 decoding

2014-08-19 Thread Gustavo Massaccesi
I used base64 a few years ago, but only for short string, so I didn't do anything fancy. My problem was that there are millions of base64 variants, and I just needed one that is different from the standard. Standard: AZaz09+/ Filename compatible: AZaz09-_ for crypt/bcrypt: ./AZaz09 for regular exp

Re: [racket] Struct & match magick

2014-08-19 Thread Sam Tobin-Hochstadt
On Tue, Aug 19, 2014 at 8:32 AM, Roman Klochkov wrote: > #lang racket > (require (for-syntax racket racket/struct-info)) > (struct foo (a b)) > (set! foo-a (let ([old foo-a]) > (λ (x) (displayln x) (old x > (define t (foo 1 2)) > > (displayln "Before change") > (match

Re: [racket] struct generics and mutual dependencies

2014-08-19 Thread Roman Klochkov
Recommended way for mutual dependencies is to use units: http://docs.racket-lang.org/guide/units.html You may define struct accessors as unit exports/imports and then link them Mon, 18 Aug 2014 23:44:11 -0400 от Jon Zeppieri : >Say I want to do basically the following, except with larger, more

[racket] Struct & match magick

2014-08-19 Thread Roman Klochkov
#lang racket (require (for-syntax racket racket/struct-info)) (struct foo (a b)) (set! foo-a (let ([old foo-a])                           (λ (x) (displayln x) (old x (define t (foo 1 2)) (displayln "Before change") (match t [(foo a b) a]) (let-syntax ([foo (extract-struct-info (syntax-local-

[racket] base64 decoding

2014-08-19 Thread Neil Van Dyke
Has anyone written a faster Base64 decode than in the "net/base64" module? ("base64-decode-stream" is suffering when tens of MB are run through it. Perhaps due in part to whatever overhead the input port has. The code looks pretty good. I'd probably have to try using block reads to reduce ca