Clojure

Allow ** as a valid symbol name without triggering "not declared dynamic" warnings

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Completed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
  • Environment:
    All
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Currently declaring a symbol ** triggers a compiler warning:

user=> (defn ** [] nil)
Warning: ** not declared dynamic and thus is not dynamically rebindable, but its name suggests otherwise. Please either indicate ^:dynamic ** or change the name. (NO_SOURCE_PATH:1)
#'user/**

** is a useful symbol in many domains, e.g. as an exponent function or as a matrix multiplication operator.

Cause: This warning checks for a def of a symbol that starts and ends with *.

Solution: Change check for name length >2 to skip this particular case.

Patch: clj-1233-with-test-v2.diff

Screened by: Alex Miller

  1. clj-1233-minimal.diff
    23/Jul/13 12:29 PM
    1 kB
    Mike Anderson
  2. clj-1233-with-test.diff
    29/Jul/13 12:32 PM
    2 kB
    Mike Anderson
  3. clj-1233-with-test-v2.txt
    05/Sep/13 6:24 PM
    2 kB
    Andy Fingerhut
  4. clj-1233-with-test-v2.diff
    22/Oct/13 9:15 AM
    2 kB
    Alex Miller

Activity

Hide
Mike Anderson added a comment -
Show
Mike Anderson added a comment - Link to discussion on Clojure-Dev https://groups.google.com/forum/#!topic/clojure-dev/OuTMsZQkxN4
Hide
Mike Anderson added a comment -

Minimal patch for the ** case only

Show
Mike Anderson added a comment - Minimal patch for the ** case only
Hide
Alex Miller added a comment -

Minimal patch would be slightly less minimal with a test.

Show
Alex Miller added a comment - Minimal patch would be slightly less minimal with a test.
Hide
Mike Anderson added a comment -

Hmmm... is there a standard/reliable method for testing the presence / non-presence of emitted warnings?

Show
Mike Anderson added a comment - Hmmm... is there a standard/reliable method for testing the presence / non-presence of emitted warnings?
Hide
Alex Miller added a comment -

There are some test helpers in Clojure's test/clojure/test_helper.clj for capturing error messages.

Show
Alex Miller added a comment - There are some test helpers in Clojure's test/clojure/test_helper.clj for capturing error messages.
Hide
Mike Anderson added a comment -

New patch with a test that includes using "with-err-print-writer" to detect the avoidance of the warning.

Show
Mike Anderson added a comment - New patch with a test that includes using "with-err-print-writer" to detect the avoidance of the warning.
Hide
Andy Fingerhut added a comment -

Patch clj-1233-with-test-v2.txt is identical to Mike Anderson's clj-1233-with-test.diff (preserving his authorship), except it avoids git warnings when applying by eliminating trailing whitespace in added lines.

Show
Andy Fingerhut added a comment - Patch clj-1233-with-test-v2.txt is identical to Mike Anderson's clj-1233-with-test.diff (preserving his authorship), except it avoids git warnings when applying by eliminating trailing whitespace in added lines.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: