{} again

H

Herfried K. Wagner [MVP]

* "Armin Zingler said:
No, also error if a parameterized ctor is definied because f is declared as
an array.

Sorry, I missed that...
New Form 'create new form
New Form(10) 'create new form + call param. ctor
New Form(10){} 'create new form + call param. ctor + assign empty array

In the last line: Why should it call the ctor? The code below will
cause a compile time error because an array cannot be assigned to a
non-array variable:

\\\
Dim f As X
f = New X(10) {}
..
..
..
Public Class X
Public Sub New(ByVal i As Integer)
...
End Sub
End Class
///
 
C

Cor

Hi Jay,
Which is where I prefer to point out it is valid, try to explain how it
works.

That was the text I was starting with, stuffed it, and then left it out, do
not know why.

The rest we also agree.

Cor
 
C

Cor

Herfried,
This depends on the skills of the reader.
When you write a program, afterwards it is hard enought for a reader with a
lot of skills to understand it, specialy when it is a program from 10 years
old with an unused language, so if it does not hurt your program, try to
make it readable for the one with few skills.

Just a thought from someone who has bad expierences with this from others.
(And I am not the only one)

Cor
 
H

Herfried K. Wagner [MVP]

* "Cor said:
When you write a program, afterwards it is hard enought for a reader with a
lot of skills to understand it, specialy when it is a program from 10 years
old with an unused language, so if it does not hurt your program, try to
make it readable for the one with few skills.

Then we should avoid using arrays, loops, recursion, ...

SCNR
Just a thought from someone who has bad expierences with this from others.
(And I am not the only one)

Just a thought too.
 
J

Jay B. Harlow [MVP - Outlook]

Armin, Cor, Herfried & others,
<rant>I have a bigger problem with the "off by one" syntax in VB.NET
arrays.

I'll be much happier with the new System.Collections.Generic.List(Of T)
class in Whidbey, then the sometimes strange syntax of VB.NET arrays or the
boxing effect of an ArrayList.

http://longhorn.msdn.microsoft.com/lhsdk/ref/ns/system.collections.generic/c/list/list.aspx

The List(Of T) class effectively combines the type safety of an Array with
the flexibility of an ArrayList. Which means we can have an List(Of Integer)
and get the speed & efficiency of an array of Integer, yet we can still call
List(Of Integer).Add(Integer) to expand the collection by adding an integer
on the end!

If you happen to have Whidbey I would suggest you check out the generic
collections! in the System.Collections.Generic namespace.

Note: the (Of T) syntax is a type parameter, it indicates the actual type
that the List holds, so when I say List(Of Integer) I have a list of
integers, while with List(Of String) I have a list of strings. Yep something
new and different, but this is very good!

Jay
 
C

Cor

Then we should avoid using arrays, loops, recursion, ...
I am glad you start to understand it, especialy endless ones.

:)))))))))))))))))))))))))))))

This was my EOT.
 
C

Chris Dunaway

The "new" way of declaring arrays is IMO not the best one:

\\\
Dim afrm As MyForm()
///

*really ugly*

I agree with you Herfried. The parentheses should be on the array variable
like this:

Dim afrm() As MyForm

That is more intuitive to me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top