Incorrect contract for `color-prefs:get-current-color-scheme-name` prevents use
Example call with error below.
The reason this error crept in might be because the term “color-scheme-name” is used in two ways: to refer to an entire color scheme, but also to refer to the key for an entry within a color scheme. For color-prefs:get-current-color-scheme-name the sense is the former but the contract is for the latter. A similar error, although only in documentation, is for (color-prefs:set-current-color-scheme name) which claims the behaviour depends on (color-prefs:known-color-scheme-name? name). This ambiguity confused me for some time, and comes up elsewhere. For example, color-prefs:get-color-scheme-names sounds like it would get all possible values that color-prefs:get-current-color-scheme-name could produce, but is for the other sense of “color-scheme-name”.
There also seems to be some implicit deprecation of color-prefs:set-default/color-scheme and color-prefs:register-color-preference, in favour of color-prefs:add-color-scheme-entry, which the docs haven't kept track of. The docs for color-prefs:register-color-preference say that it uses color-prefs:set-default/color-scheme, but the implementation does not. Similarly, the docs for color-prefs:white-on-black and color-prefs:black-on-white refer to “colors registered by color-prefs:register-color-preference”, but that's too specific.
There's exactly one use of color-prefs:set-default/color-scheme in the racket source, and no uses of color-prefs:register-color-preference except that it's suggested for use in the docs that tell you how to “Design Your Own Color Schemes” ( @secref["color-scheme" #:doc '(lib "scribblings/drracket/drracket.scrbl") ), which perhaps should refer to color-prefs:add-color-scheme-entry.
#lang racket
(require framework)
(color-prefs:get-current-color-scheme-name)
; color-prefs:get-current-color-scheme-name: broke its own contract
; promised: color-scheme-style-name?
; produced: 'classic
; in: the range of
; (-> color-scheme-style-name?)
; contract from:
; <pkgs>/gui-lib/framework/main.rkt
; blaming: <pkgs>/gui-lib/framework/main.rkt
; (assuming the contract is correct)
; at: <pkgs>/gui-lib/framework/main.rkt:2058.2
Yeah, this is a bit of a mess, isn't it! I've tried to make some improvements.