[Closed] Keyword Dim - Several variables of the same type

In VB, we can declare several variables of the same type in this way:

Dim test1, value2, result as Integer

Or, multiple variables of different types like this:

Dim a, b, c As single, x, y as Double

In Mercury, there could also be this way of declaring multiple variables all of the same type:

Dim as Integer test1, value2, result

Although there is already a syntax for declaring several variables of the same type, I find this syntax very interesting. In freebasic, this syntax exist.

@fabiuz

I don’t see why we should add

Dim As Integer test1, test2, test3

when

 Dim test1, test2, test3  As Integer

already works.
It is not less code, just another place for the As Integer, that is also more C# style (type first) than VB style (name first).

1 Like

OK!!
I agree with your opinion.
And also after I sent this posts, I was thinking it doesn’t add anything new to the language.
And also after reading your arguments it makes sense what you say.

2 Likes

I Closed this issue.

Actually
Dim test1, value2, result as Integer
works in vb, but
Dim test1, value2, result as Integer = 5
does not, because multiple variables can’t initialised at the same time to the same value.
It would be an interesting feature, me thinks.

Can you open a new request topic for this - as this one has been closed?