3 1485
"Pierre Y." <pi****@je.suis .le.vosgien.du. net> wrote in message
news:mn******** ************@je .suis.le.vosgie n.du.net... Hi,
I've just read that article :
http://msdn.microsoft.com/library/en...p_generics.asp
I'm asking something. Why are generics constraints not been implemented using Attributes instead of "where..." syntax ?
AFAIK, attributes are pretty much ignored by the compiler (other than
emitting them as metadata), whereas constraints are very definately an
instruction to the compiler. We could theoretically put inheritance
instructions in attributes:
[InheritsFrom(ty peof(System.Mar shalByRefObject ))]
public class MyClass {...}
but it wouldn't look as clean, and it would break the code/metadata
difference.
Sean Hederman avait soumis l'idée : "Pierre Y." <pi****@je.suis .le.vosgien.du. net> wrote in message news:mn******** ************@je .suis.le.vosgie n.du.net... Hi,
I've just read that article :
http://msdn.microsoft.com/library/en...p_generics.asp
I'm asking something. Why are generics constraints not been implemented using Attributes instead of "where..." syntax ?
AFAIK, attributes are pretty much ignored by the compiler (other than emitting them as metadata), whereas constraints are very definately an instruction to the compiler. We could theoretically put inheritance instructions in attributes: [InheritsFrom(ty peof(System.Mar shalByRefObject ))] public class MyClass {...}
but it wouldn't look as clean, and it would break the code/metadata difference.
Thank you. I think I have understand in the above paper that generics
are supported by IL/CLR. At runtime, JIT compiler produces native code
and performs type and constraints checks.
So generics types and constraints are metadatas too ?
Correct me If I'm wrong please.
Regards,
Pierre Y.
--
Message généré par MesNews
> Thank you. I think I have understand in the above paper that generics are supported by IL/CLR. At runtime, JIT compiler produces native code and performs type and constraints checks.
So generics types and constraints are metadatas too ?
Yes, constraints are stored as metadata, if you want to be techincal,
everything else about a method(its return type, its parameters, etc) are
metadata as well. Its the metadata that makes .NET really interesting.
There are very few attributes that affect compilation... and they rarely
change how code is interpreted(Con ditional skips method calls, DllImport may
cause a different instruction to be generated, I can't recall of the top of
my head).
While constraints are recorded in metadata, they still change the way the
code within the method is understood, and thus are code, not metadata. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bernardo Heynemann |
last post by:
How can I use Generics?
How can I use C# 2.0?
I already have VS.NET 2003 Enterprise Edition and still can´t use
generics...
I´m trying to make a generic collection myCollection<vartype> and still no
can do...
Any info would be great!
|
by: Mr.Tickle |
last post by:
So whats the deal here regarding Generics in the 2004 release and templates
currently in C++?
|
by: Luc Vaillant |
last post by:
I need to initialise a typed parameter depending of its type in a generic
class.
I have tried to use the C++ template form as follow, but it doesn't work.
It seems to be a limitation of generics vs C++ templates.
Does anyone knows a workaround to do this ? Thx :
public class C<T>
{
private T myValue;
|
by: Michael S |
last post by:
Why do people spend so much time writing complex generic types?
for fun?
to learn?
for use?
I think of generics like I do about operator overloading.
Great to have as a language-feature, as it defines the language more
completely. Great to use.
|
by: anders.forsgren |
last post by:
This is a common problem with generics, but I hope someone has found
the best way of solving it.
I have these classes: "Fruit" which is a baseclass, and "Apple" which
is derived. Further I have an "AppleBasket" which is a class that
contains a collection of apples. So, some code:
class Fruit{
}
| |
by: herpers |
last post by:
Hello,
I probably don't see the obvious, but maybe you can help me out of this
mess.
The following is my problem:
I created two classes NormDistribution and DiscDistribution. Both
classes provide an implemation of the operator +.
Now I want to write another generic class Plan<DType>, which can
|
by: sloan |
last post by:
I'm not the sharpest knife in the drawer, but not a dummy either.
I'm looking for a good book which goes over Generics in great detail.
and to have as a reference book on my shelf.
Personal Experience Only, Please.
...
|
by: Vladimir Shiryaev |
last post by:
Hello!
Exception handling in generics seems to be a bit inconsistent to me.
Imagine, I have "MyOwnException" class derived from "ApplicationException".
I also have two classes "ThrowInConstructor" and "ThrowInFoo". First one
throws "MyOwnException" in constructor, second one in "Foo()" method. There
is a "GenericCatch" generics class able to accept "ThrowInConstructor" and
"ThrowInFoo" as type parameter "<T>". There are two methods in...
|
by: SpotNet |
last post by:
Hello NewsGroup,
Reading up on Generics in the .NET Framework 2.0 using C# 2005 (SP1), I have
a question on the application of Generics. Knowingly, Generic classes are
contained in the System.Collections.Generic namespace. Literature I have
read on this ties generics in with collections, hence articulate their
examples as such. That's fine, I understand what is being said.
My question is more towards the application and implementation...
|
by: rkausch |
last post by:
Hello everyone,
I'm writing because I'm frustrated with the implementation of C#'s
generics, and need a workaround. I come from a Java background, and
am currently writing a portion of an application that needs
implementations in both Java and C#. I have the Java side done, and
it works fantastic, and the C# side is nearly there. The problem I'm
running into has to do with the differences in implementations of
Generics between the two...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |