Partager via


Req8: Use [ ] for arrays

[This post is part of a series, "wish-list for future versions of VB"]

 

IDEA: Use [ ] for arrays. This suggestion came from Bill McCarthy. He writes that it's hard to tell the difference between array-indexing and other uses of parentheses. We could allow [] for arrays, or have some other visual differentiation in the IDE. For consistency reasons we'd also have to do it for property parameters. (Also that would remove the user-confusion about how property args are always passed ByVal even though declared ByRef).

 

Evaluation from VB team: This would be better done by an IDE plugin, rather than by changing the syntax of the language. Now that VS2010 has moved the IDE to WPF, a lot more of these kinds of plugins are possible, and they'll become drastically easier once our "compiler-as-a-service" features progress.

Comments

  • Anonymous
    February 13, 2010
    The comment has been removed

  • Anonymous
    February 14, 2010
    First I must say that I'm against this feature. [] are not on Czech keyboard ;-). But imagine this Function GetArray() As Integer() Function GetArray(param As Integer) As Integer() Dim x = GetArray(5) 'What does this do? [] Can avoid some confusion.

  • Anonymous
    February 15, 2010
    As with separate assignment and equality operators, this would undoubtedly make code clearer, but again is probably not worth implementing considering the confusion it would lead to (assuming both syntaxes would have to be supported indefinitely).

  • Anonymous
    February 24, 2010
    I don't find it confusing or hard to tell the difference.  I think () is perfectly adequate.  

  • Anonymous
    March 08, 2010
    Dave R: I like VB and I'd very much like to use [] for indexing. In my opinion, () is overused already, with it being used for changing the evaluation order of expressions, generics, indexing and function calls. At least generics have the Of keyword to differntiate them. If you came across Aaa(0).Bbb(1).Ccc(2)(3), you can't tell from a glance which ones are array/property accesses or function calls.

  • Anonymous
    January 11, 2011
    NO NO NO NO NO NO NO Stick to () and don't get confused from C#!!!