Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-10136

Lift the restriction on using 'var' variables

Details

    • Wish
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 9.0
    • 9.0
    • None
    • None
    • New

    Description

      Can we lift the restriction on using 'var' on the main branch? I know it's a double-edged sword and sometimes it leads to unreadable code, especially when you invoke a method, for example:

      var foo = myMethodThatDoesSomething();
      

      but in many, many, many cases the var keyword shortens the code and the type is obvious from the context. This happens in loops, try-with-resources and local variables.

      for (var it = array.iterator(); it.hasNext();) { ... }
      try (var foo = new MyFoo()) { ... }
      

      I'd say - let's allow vars (and other language features) and use common sense. If something is not clear in the context, type the variable. If something is obvious, use shortcuts.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dweiss Dawid Weiss
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h