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
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?]))
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
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
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
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?))
>
>
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
7 matches
Mail list logo