update gen:set defaults and docs

- set-copy-clear has no fallback - update docs to match impl
- set-copy fallback should use set-copy-clear not set-clear
This commit is contained in:
Stephen Chang 2015-05-01 19:06:23 -04:00
parent a2d06c2cd5
commit 9e8971ba95
2 changed files with 6 additions and 7 deletions

View File

@ -285,7 +285,8 @@ As an example, implementing the following methods would guarantee that all the m
@item{@racket[set-remove]} @item{@racket[set-remove]}
@item{@racket[set-remove!]} @item{@racket[set-remove!]}
@item{@racket[set-first]} @item{@racket[set-first]}
@item{@racket[set-empty?]}] @item{@racket[set-empty?]}
@item{@racket[set-copy-clear]}]
There may be other such subsets of methods that would guarantee at least a fallback for every method. There may be other such subsets of methods that would guarantee at least a fallback for every method.
@ -381,7 +382,7 @@ Produces a new, mutable set of the same type and with the same elements as
@racket[st]. @racket[st].
Supported for any @racket[st] that @supp{supports} @racket[set->stream] and Supported for any @racket[st] that @supp{supports} @racket[set->stream] and
either @impl{implements} @racket[set-copy-clear] and @racket[set-add!]. @impl{implements} @racket[set-copy-clear] and @racket[set-add!].
} }
@ -396,14 +397,12 @@ set, and so it preserves any contract on the given set. The
@racket[set-copy-clear] function produces a new set without any @racket[set-copy-clear] function produces a new set without any
contracts. contracts.
Supported for any @racket[st] that @impl{implements} @racket[set-remove] and @supp{supports} Has no fallback.
@racket[set->stream].
} }
@defproc[(set-clear [st generic-set?]) (and/c generic-set? set-empty?)]{ @defproc[(set-clear [st generic-set?]) (and/c generic-set? set-empty?)]{
Produces set by removing all elements of @racket[st]. Produces a set like @racket[st] but with all elements removed.
Supported for any @racket[st] that @impl{implements} @racket[set-remove] and @supp{supports} Supported for any @racket[st] that @impl{implements} @racket[set-remove] and @supp{supports}
@racket[set->stream]. @racket[set->stream].

View File

@ -226,7 +226,7 @@
(define (fallback-copy s) (define (fallback-copy s)
(cond (cond
[(set-implements? s 'set-copy-clear 'set-add!) [(set-implements? s 'set-copy-clear 'set-add!)
(define s2 (set-clear s)) (define s2 (set-copy-clear s))
(for ([x (*in-set s)]) (for ([x (*in-set s)])
(set-add! s2 x)) (set-add! s2 x))
s2] s2]