Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-03 Thread Christopher Lemmer Webber
Cool! Thanks for sharing :) -- 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. To view this discussion on the web visit

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-03 Thread David Storrs
For the record, a self-plug: #lang racket (require struct-plus-plus) (struct foo-guard (bar baz) #:guard (struct-guard/c any/c list?)) (struct/contract foo-contract ([bar any/c] [baz list?])) (struct++ foo-spp ([bar any/c] [baz list?]))

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
Philip McGrath writes: > On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber < > cweb...@dustycloud.org> wrote: > >> Unfortunately I can't use #:methods with struct/contract so I'm stuck >> with the slow one if I want a contract on the struct? >> > > For another option (though you may

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
Ah, I didn't know one could just write a function for the guard... but that makes a lot of sense! Sam Tobin-Hochstadt writes: > The issue is that `struct-guard/c` is slow. If you just write a > function as a guard it's faster than `struct/contract`. > > Sam > > On Wed, Sep 2, 2020 at 3:41 PM

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Philip McGrath
On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber < cweb...@dustycloud.org> wrote: > Unfortunately I can't use #:methods with struct/contract so I'm stuck > with the slow one if I want a contract on the struct? > For another option (though you may already know this), I'd advocate for

Re: [racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Sam Tobin-Hochstadt
The issue is that `struct-guard/c` is slow. If you just write a function as a guard it's faster than `struct/contract`. Sam On Wed, Sep 2, 2020 at 3:41 PM Christopher Lemmer Webber wrote: > > I tested the following: > > (struct foo (bar baz) > #:guard (struct-guard/c any/c list?)) > >

[racket-users] Why is struct/contract so much faster than a guard?

2020-09-02 Thread Christopher Lemmer Webber
I tested the following: (struct foo (bar baz) #:guard (struct-guard/c any/c list?)) and: (struct/contract foo ([bar any/c] [baz list?])) With the first: test> (time (for ([i 100]) (foo 'yeah '(buddy cpu time: 2601 real time: 2599