• Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: Release 1.7
    • Labels:
    • Approval:
    • Patch:
      Code and Test


      See for design.

      The implementation details contain several major parts:

      1) LispReader changes to implement new conditional read syntax and features.

      In RT:

      • suppress-read - new dynamic var
      • readString() - new arity that takes opts

      In LispReader:

      • read(...) entry point - added new variants that take opts. The opts-only form will decode :eof into the correct values for eofIsError and eofValue. Internal forms take both opts and pendingForms (list).
      • All reader invoke dispatch methods now take both opts and pendingForms which get drug around the call stack.
      • Defined all option keys and well-known allowed values - OPT_EOF, OPT_FEATURES, OPT_READ_COND, EOFTHROW, PLATFORM_KEY, PLATFORM_FEATURES, COND_ALLOW, COND_PRESERVE.
      • read(...) entry point will ensure installation of {:features #{:clj}}, appropriately merging others or none. There is no path that will pass :features inside Clojure but users can call LispReader with it directly.
      • readDelimitedList() was refactored so it can share logic with readCondDelimited().
      • Luke can provide more detail on the guts of reader conditional reading if needed.

      New ReaderConditional and TaggedLiteral types.

      In clojure.core:

      • tagged-literal?, tagged-literal, reader-conditional?, reader-conditional - new functions to support the preserved data form of these
      • new print-method impls for TaggedLiteral and ReaderConditional
      • read - added new arity that takes opts and explain opts in docstring
      • read-string - added new arity that takes opts (placement matches edn/read-string and is designed for partial application)

      2) cljc file changes.
      In Compiler:

      • OPTS_COND_ALLOWED - keep around a map {:read-cond :allow} to invoke reader when reading .cljc files.
      • readerOpts() - new private function to determine reader options to use based on file name (.clj vs .cljc)
      • load() - use readerOpts() and invoke LispReader with them
      • compile() - use readerOpts() and invoke LispReader with them

      In RT:

      • load(...) - check first for .clj file, then for .cljc file when looking by ns

      In clojure.main - update code to allow for .clj and .cljc files
      In clojure.repl - update code to allow for .clj and .cljc files

      3) Tests + infrastructure updates.

      • Move test/clojure/test_clojure/reader.clj to test/clojure/test_clojure/reader.cljc so that we can test reader conditionals.
      • Bump version of test.generative to get newer version that depends on newer tools.namespace which is able to find .cljc files as source files. The test script at src/script/run_test.clj uses this to find Clojure test files and without the bump, it will not find the new reader.cljc test ns. Note: if you use the ant build, you need to re-run for this to take effect.
      • src/script/run_test.clj - as part of the version bump, move from deprecated namespace to new namespace
      • Added lots of tests in reader.cljc

      Patch: clj-1424-12.patch

      Screened by:

      Related: CLJS-27 Closed , TRDR-14 Closed


        1. clj-1424-10.diff
          88 kB
        2. clj-1424-11.patch
          88 kB
        3. clj-1424-12.patch
          89 kB
        4. CLJ-1424-2.diff
          10 kB
        5. clj-1424-3.diff
          11 kB
        6. clj-1424-4.diff
          26 kB
        7. clj-1424-5.diff
          30 kB
        8. clj-1424-6.diff
          29 kB
        9. clj-1424-7.diff
          40 kB
        10. clj-1424-8.diff
          103 kB
        11. clj-1424-9.diff
          41 kB
        12. clojure-feature-expressions.diff
          9 kB



            • Assignee:
              gshayban Ghadi Shayban
            • Votes:
              1 Vote for this issue
              8 Start watching this issue


              • Created: