Re: Problem with generic
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
- From: Russell Hind <no@xxxxx>
- Date: Tue, 08 May 2007 10:25:19 +0100
Torben Laursen wrote:
NumType d = 0.0; //The problem is this line. This will not compile with the
NumType d = default(NumType);
But you'll probably have trouble with the Val + d line too. I don't
believe there is a way to say that the generic type is numeric and
therefore has basic mathematical operators defined for it.
I think this is just a limitation of the current implementation of generics.
Cheers
Russell
.
Relevant Pages
- Re: The New Roadmap
... know anything about both environments when writing portable code, ... That chewed up memory remains chewed ... especially with the differences between Generics and C++ ... Another great 'demo' technology that stores up long term trouble if you ... (borland.public.delphi.non-technical) - Re: A question related to type casting
... But an intelligent, experienced programmer such as yourself should have no trouble taking a stupid example like that and extrapolating to the real-world, to see that you might get into trouble where the code that initializes the reference to null is not actually the same code that later tries to do something with it. ... Likewise, in the real-world, the code that creates the generic type may wind up forced due to backward compatibility issues, or third-party coder issues, or whatever, to pass its type-safe generic instance to code that uses it as a raw type. ... Like it or not, Java generics do have this lack of type-safety, and no amount of calling the code "weird" is going to change that. ... (comp.lang.java.programmer) - Re: A question related to type casting
... reified generics? ... But an intelligent, experienced programmer such as yourself should have no trouble taking a stupid example like that and extrapolating to the real-world, to see that you might get into trouble where the code that initializes the reference to null is not actually the same code that later tries to do something with it. ... (comp.lang.java.programmer) - Re: Generics headache
... generics would cause trouble. ... I recommend getting rid of your ... For me, that's what I chiefly learned from the "solutions" at BCIT, just suppress those warnings and completely side step generics altogether. ... (comp.lang.java.programmer) - Re: Using abstract generic
... I totally agree with Paul. ... Limitation: In general, generics/parameters of composite type (arrays and ... ARCHITECTURE arch OF top IS ... (comp.lang.vhdl) |
|