473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Type inference

What do people here think about VB2008 having the ability to infer type?
e.g you can now say Dim i=5
which will create i as an integer

Personally I do not like it as it is not consistent and may be confusing for
other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295

It also leads to inconsistency - sometimes you have to declare the type and
sometimes you dont.

I will be using Option Infer Off

Guy
Nov 19 '07 #1
12 1954
"guy" <gu*@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer

Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295

It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.

I will be using Option Infer Off
I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)
Armin

Nov 19 '07 #2
What do people here think about VB2008 having the ability to infer
type?
I have to say I don't mind it.
e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
What's not consistent?

Extreme example - what is the type of x below?
dim x= 4294967295
Whatever numeric type is nessecary to store 4294967295.

I think it (Type inference) reduces noise on the page and I don't see that
we're loosing much by using it.

--
Rory
Nov 19 '07 #3
On Nov 19, 7:27 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"guy" <g...@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295
It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.
I will be using Option Infer Off

I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)

Armin
Type Inference is necessary to support LINQ. It's the same reason it
is being added to C#. So, while I see a big potential for abuse - I
hope that it will be used judiciously.

--
Tom Shelton
Nov 19 '07 #4
On Nov 19, 9:27 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"guy" <g...@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295
It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.
I will be using Option Infer Off

I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)

Armin
This worries me too, but as Tom pointed out it's necessary for LINQ.
It brings back painful memories of debugging inferred var types from
Javascript. Hopefully, since most people are already established in
the .NET world, it will not be used when it is not needed (i.e.
anywhere but LINQ).

I am curious, can you still declare an inferred variable with Option
Infer Off?

Something like:

Dim i as <Inferred>

That way we would retain the strongly typed error checking and still
have the LINQ functionality?

Thanks,

Seth Rowe
Nov 19 '07 #5
I am puzzled Tom, I am aware of various features being introduced to support
LINQ but I was not aware that this was one of them.

Guy

"Tom Shelton" wrote:
On Nov 19, 7:27 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"guy" <g...@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295
It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.
I will be using Option Infer Off
I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)

Armin

Type Inference is necessary to support LINQ. It's the same reason it
is being added to C#. So, while I see a big potential for abuse - I
hope that it will be used judiciously.

--
Tom Shelton
Nov 19 '07 #6
On Nov 19, 10:05 am, guy <g...@discussions.microsoft.comwrote:
I am puzzled Tom, I am aware of various features being introduced to support
LINQ but I was not aware that this was one of them.

Guy

"Tom Shelton" wrote:
On Nov 19, 7:27 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"guy" <g...@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295
It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.
I will be using Option Infer Off
I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)
Armin
Type Inference is necessary to support LINQ. It's the same reason it
is being added to C#. So, while I see a big potential for abuse - I
hope that it will be used judiciously.
--
Tom Shelton
Here's a link that might help you:

http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Thanks,

Seth Rowe
Nov 19 '07 #7
Oh yes, it is because of Anonymous classes.

Thansk Seth I remember now.

Guy

"rowe_newsgroups" wrote:
On Nov 19, 10:05 am, guy <g...@discussions.microsoft.comwrote:
I am puzzled Tom, I am aware of various features being introduced to support
LINQ but I was not aware that this was one of them.

Guy

"Tom Shelton" wrote:
On Nov 19, 7:27 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"guy" <g...@discussions.microsoft.comschrieb
What do people here think about VB2008 having the ability to infer
type? e.g you can now say Dim i=5
which will create i as an integer
Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.
Extreme example - what is the type of x below?
dim x= 4294967295
It also leads to inconsistency - sometimes you have to declare the
type and sometimes you dont.
I will be using Option Infer Off
I totally agree. Being aware of data types is much too basic and important
to deal with them superficially. (I wonder who asked for such a feature)
Armin
Type Inference is necessary to support LINQ. It's the same reason it
is being added to C#. So, while I see a big potential for abuse - I
hope that it will be used judiciously.
--
Tom Shelton

Here's a link that might help you:

http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Thanks,

Seth Rowe
Nov 19 '07 #8


"Rory Becker" wrote:
What do people here think about VB2008 having the ability to infer
type?

I have to say I don't mind it.
e.g you can now say Dim i=5
which will create i as an integer

Personally I do not like it as it is not consistent and may be
confusing for other devleopers to read.

What's not consistent?

Extreme example - what is the type of x below?
dim x= 4294967295

Whatever numeric type is nessecary to store 4294967295.
***exactly my point *** If you are looking at printed output do you want to
go and use Calculator to determine the datatype?
>
I think it (Type inference) reduces noise on the page and I don't see that
we're loosing much by using it.

--
Rory

Guy
Nov 19 '07 #9
>>Extreme example - what is the type of x below?
dim x= 4294967295
Whatever numeric type is nessecary to store 4294967295.
***exactly my point *** If you are looking at printed output do you
want to go and use Calculator to determine the datatype?
Ok sure and granted you did ask "what is the type of x". But I guess my point
is why do you need to know. Studio/.Net will work it our for you.

Now I'll also grant that there are times when you need to constrain the data
by a type because of some requirement based on say database column size.

but aren't there cases where you simply don't care as long as it works.

I hate personally don't like the idea of dynamic types where x might be an
integer in one moment and then act like a strign the next. But this isn't
that. It's just allowing the IDE/.Net to work out what is neccesary in a
given case.

--
Rory
Nov 19 '07 #10
"Rory Becker" <Ro********@newsgroup.nospamschrieb
>
Extreme example - what is the type of x below?
dim x= 4294967295
Whatever numeric type is nessecary to store 4294967295.
>
***exactly my point *** If you are looking at printed output do
you want to go and use Calculator to determine the datatype?

Ok sure and granted you did ask "what is the type of x". But I guess
my point is why do you need to know. Studio/.Net will work it our
for you.
*You* must know the type. How can you handle something if you don't know
what it is?
Now I'll also grant that there are times when you need to constrain
the data by a type because of some requirement based on say database
column size.

but aren't there cases where you simply don't care as long as it
works.
No. While programming, "don't care" is never good.

dim x = integer.maxvalue
x += 1

"Why doesn't it work? x is a 'numeric value'." That's what happens if you
don't care.

I hate personally don't like the idea of dynamic types where x might
be an integer in one moment and then act like a strign the next. But
this isn't that. It's just allowing the IDE/.Net to work out what is
neccesary in a given case.
In my understanding, reserving memory is one thing, filling it afterwards is
the other one. Therefore, it is impossible to do the 1st by doing the 2nd.
The line gives the impression that the assignment implicitly reserves the
memory. That's simply wrong.
Armin

Nov 19 '07 #11
What the hell

I don't think I've ever heard, err read, you swear before. Not sure
why that struck me funny...

:-)

Thanks,

Seth Rowe

Nov 19 '07 #12


"Rory Becker" wrote:
>
>Extreme example - what is the type of x below?
dim x= 4294967295
Whatever numeric type is nessecary to store 4294967295.
***exactly my point *** If you are looking at printed output do you
want to go and use Calculator to determine the datatype?

Ok sure and granted you did ask "what is the type of x". But I guess my point
is why do you need to know. Studio/.Net will work it our for you.

Now I'll also grant that there are times when you need to constrain the data
by a type because of some requirement based on say database column size.

but aren't there cases where you simply don't care as long as it works.
because if you do dim i=3 expecting a byte (you will get an integer) and
stick it in an array it will consume four times the ram that you had expected

Guy
I hate personally don't like the idea of dynamic types where x might be an
integer in one moment and then act like a strign the next. But this isn't
that. It's just allowing the IDE/.Net to work out what is neccesary in a
given case.

--
Rory
Nov 20 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: A.M | last post by:
Hi, Is there any inelisence IDE (like visual studio) for python? Thanks, Alan
0
by: Brett C. | last post by:
My thesis, "Localized Type Inference of Atomic Types in Python", was successfully defended today for my MS in Computer Science at the California Polytechnic State University, San Luis Obispo. With...
39
by: Noticedtrends | last post by:
Can inference search-engines narrow-down the number of often irrelevant results, by using specific keywords; for the purpose of discerning emerging social & business trends? For example, if...
1
by: Ken Cox [Microsoft MVP] | last post by:
Hi, I'm using a dataset to read data from an XML file. I don't control the XML. The XML has no schema and therefore is treated like a string. My data consumer wants the column type to be a...
4
by: Harold Howe | last post by:
I am running into a situation where the compiler complains that it cannot infer the type parameters of a generic method when one of the function arguments is an anonymous method. Here is a...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: Nie longhai | last post by:
I have a generic method in a class as follow: T Get<T>(string key) { ..... return Convert.ChangeType(v, typeof(T)) } when I use it in my code:
2
by: Chris Dunaway | last post by:
When using linq queries, is it *required* to use type inference? I was reviewing some linq samples and came across this one: public void Linq5() { string digits = { "zero", "one", "two",...
2
by: Maurizio Colucci | last post by:
Hi, I have a function so defined function foo (byval l as List(of IMyInterface)) as bar I have a List(of C), where C implements IMyInterface. I want to pass the list as input to foo, like
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.