473,486 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Error in Gyro?

hi

Still struggeling with Gyro... :)

how can this be correct?

T t = null;
gives a compile error because the compiler thinks T is a
value type.

while the test:
Type type = typeof(T);
Console.WriteLine(type.IsValueType);
gives false..

I suppose it has to do with what is known at compile time
and what is known at runtime, but why does the compiler
just asume that T is a value type if it dosn't know?

And how do I get it to understand that T is a reference
type at compile time?

code:
------------------------------
using System;

class TestClass<T>
{
public void testStuff()
{
Type type = typeof(T);
Console.WriteLine(type.IsValueType);

T t = null;
}
}

class Apple {}

class Control
{
public static void Main()
{
TestClass<Apple> t = new TestClass<Apple>();
t.testStuff();
}
}
-------------------------------

Nov 15 '05 #1
4 1279
wrong newsgroup!
you need to use the betanews groups for vNext questions.
Sorry!
-Dino

"Ole Andre Karlson" <ol****@ifi.uio.no> wrote in message
news:1b****************************@phx.gbl...
hi

Still struggeling with Gyro... :)

how can this be correct?

T t = null;
gives a compile error because the compiler thinks T is a
value type.

while the test:
Type type = typeof(T);
Console.WriteLine(type.IsValueType);
gives false..

I suppose it has to do with what is known at compile time
and what is known at runtime, but why does the compiler
just asume that T is a value type if it dosn't know?

And how do I get it to understand that T is a reference
type at compile time?

code:
------------------------------
using System;

class TestClass<T>
{
public void testStuff()
{
Type type = typeof(T);
Console.WriteLine(type.IsValueType);

T t = null;
}
}

class Apple {}

class Control
{
public static void Main()
{
TestClass<Apple> t = new TestClass<Apple>();
t.testStuff();
}
}
-------------------------------

Nov 15 '05 #2
Ahh.. sorry the PLDI paper on Gyro only mentioned this
group...

stupid followup question:
where do I find the betanews groups?

Ole
-----Original Message-----
wrong newsgroup!
you need to use the betanews groups for vNext questions.
Sorry!
-Dino

"Ole Andre Karlson" <ol****@ifi.uio.no> wrote in message
news:1b****************************@phx.gbl...
hi

Still struggeling with Gyro... :)

how can this be correct?

T t = null;
gives a compile error because the compiler thinks T is a
value type.

while the test:
Type type = typeof(T);
Console.WriteLine(type.IsValueType);
gives false..

I suppose it has to do with what is known at compile time and what is known at runtime, but why does the compiler
just asume that T is a value type if it dosn't know?

And how do I get it to understand that T is a reference
type at compile time?

code:
------------------------------
using System;

class TestClass<T>
{
public void testStuff()
{
Type type = typeof(T);
Console.WriteLine(type.IsValueType);

T t = null;
}
}

class Apple {}

class Control
{
public static void Main()
{
TestClass<Apple> t = new TestClass<Apple>();
t.testStuff();
}
}
-------------------------------

.

Nov 15 '05 #3
Ole,

I think Dino mistakenly thought you were an early tester of the next
version of the CLR (which also includes generics support). You can
definitely use this group to discuss Gyro.

The answer to your question can be found in docs\generics\csharp.html
in the Gyro distribution. Under the heading "'Default' values for type
parameters" it says
"No implicit conversion exists from the null type to a type parameter
V. This is because V may be instantiated as a value type, and 'null'
does not have the same, intuitive meaning that may be expected for
those types.

However, the expression V.default will be guaranteed to produce a
'default' value for the type corresponding to V. This can be
considered an explicit, unboxing conversion from the 'null' type to a
type parameter.

Note: this is not yet implemented."
So, when implemented, you'd be able to write

T t = T.default;

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #4
Ole,

I think Dino mistakenly thought you were an early tester of the next
version of the CLR (which also includes generics support). You can
definitely use this group to discuss Gyro.

The answer to your question can be found in docs\generics\csharp.html
in the Gyro distribution. Under the heading "'Default' values for type
parameters" it says
"No implicit conversion exists from the null type to a type parameter
V. This is because V may be instantiated as a value type, and 'null'
does not have the same, intuitive meaning that may be expected for
those types.

However, the expression V.default will be guaranteed to produce a
'default' value for the type corresponding to V. This can be
considered an explicit, unboxing conversion from the 'null' type to a
type parameter.

Note: this is not yet implemented."
So, when implemented, you'd be able to write

T t = T.default;

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #5

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

Similar topics

2
4358
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
16210
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
1
8391
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
1
6380
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
5
5681
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
13
6569
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
4976
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
19391
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
2897
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
6964
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
7123
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,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.