You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Dawid Weiss (Jira)" <ji...@apache.org> on 2021/09/30 07:45:00 UTC
[jira] [Created] (LUCENE-10136) Lift the restriction on using 'var'
variables
Dawid Weiss created LUCENE-10136:
------------------------------------
Summary: Lift the restriction on using 'var' variables
Key: LUCENE-10136
URL: https://issues.apache.org/jira/browse/LUCENE-10136
Project: Lucene - Core
Issue Type: Wish
Affects Versions: main (9.0)
Reporter: Dawid Weiss
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:
{code}
var foo = myMethodThatDoesSomething();
{code}
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.
{code}
for (var it = array.iterator(); it.hasNext();) { ... }
try (var foo = new MyFoo()) { ... }
{code}
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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org