racket / racket/gui

Incorrect contract for `color-prefs:get-current-color-scheme-name` prevents use

Open
#179 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Racket
Stars
68
Forks
82
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at /gui-lib/framework/main.rkt:2058.2 and inspect the contract for color-prefs:get-current-color-scheme-name alongside the related color-prefs procedures. Review the “Design Your Own Color Schemes” documentation and references to color-prefs:set-default/color-scheme and color-prefs:register-color-preference. Done means the contract and documentation consistently describe the intended color-scheme naming and registration APIs.

Written by the indexing model from the issue text.

Assessment

Domain
desktop-dev, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.