From 9e8971ba95093d0bd96693af726d07593d6bbefd Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 1 May 2015 19:06:23 -0400 Subject: [PATCH] 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 --- pkgs/racket-doc/scribblings/reference/sets.scrbl | 11 +++++------ racket/collects/racket/private/set.rkt | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/racket-doc/scribblings/reference/sets.scrbl b/pkgs/racket-doc/scribblings/reference/sets.scrbl index e027d4448e..2ee6d5e3e4 100644 --- a/pkgs/racket-doc/scribblings/reference/sets.scrbl +++ b/pkgs/racket-doc/scribblings/reference/sets.scrbl @@ -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-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. @@ -381,7 +382,7 @@ Produces a new, mutable set of the same type and with the same elements as @racket[st]. 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 contracts. -Supported for any @racket[st] that @impl{implements} @racket[set-remove] and @supp{supports} -@racket[set->stream]. - +Has no fallback. } @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} @racket[set->stream]. diff --git a/racket/collects/racket/private/set.rkt b/racket/collects/racket/private/set.rkt index 8364fc4276..7b291fd77d 100644 --- a/racket/collects/racket/private/set.rkt +++ b/racket/collects/racket/private/set.rkt @@ -226,7 +226,7 @@ (define (fallback-copy s) (cond [(set-implements? s 'set-copy-clear 'set-add!) - (define s2 (set-clear s)) + (define s2 (set-copy-clear s)) (for ([x (*in-set s)]) (set-add! s2 x)) s2]