Re: .NET 2.0 to be launched on Nov 8




"Marco van de Voort" <marcov@xxxxxxxx> wrote in message
news:slrndbvedd.2i7e.marcov@xxxxxxxxxxxxxxxxx
> On 2005-06-23, Mike Swaim <mswaim@xxxxxxxxxxxxxxxxxx> wrote:
>> Marco van de Voort wrote:
>>
>>> - the user defined specialization and non-type params are a clear
>>> difference. - The non-type missing is not that spectacular, since
>>> the JIT could optimize it away, and it is more about optimization
>>> than speed.
>>
>> I think that this could be a conceptual difference. On one of the 64
>> bit MSDN blogs, one of the developers noted that generic collections
>> are much more efficient that 1.1 collections when handling ints,
>> because generics don't require boxing.
>
> But then they must be template based, since generics require interfaces,
> and
> unboxed types don't have those?

Maybe you need to implement interfaces to make a class a generic
container...
But the items you put inside that container do not have to implement an
interface.

This for example works:

class method ConsoleApp.Main;
Var
FTestList: List<Integer>;
TempInt: Integer;
begin
FTestList := new List<Integer>; //<-- creates a strongtyped Integer
container
FTestList.add(3);
FTestList.add(8);
TempInt := FTestList.Item[0] + FTestList.Item[1];
Console.WriteLine(TempInt.ToString); //<-- prints 11
Console.ReadLine;
end;

Best Regards,

Jeroen Vandezande


.



Relevant Pages

  • Re: light weight types
    ... The implementer of Container has no idea what type it is, it's just some type, any type. ... Since we don't know what it is, all we can guarantee is that it is an Object of some type (all non-primitive types are a subclass of Object, and generics don't use primitive types), so wherever `T' is found in the implementation, you can mentally replace it with `Object' for the same effect. ... You can also specify a /lower/ bound on the type, by specifying `super' instead of `extends'. ... Remember that a container stores it type: you can store any B into a Container, so being able to cast from Containerto Containermeans you can put a B into the ...
    (comp.lang.java.programmer)
  • Re: Delphi 2007 Language Feature: Generics
    ... | i.e. if Micha knows that a certain level of understanding of generics ... | generics also has the knowledge of the alternatives. ... derived from a base container item class. ... storage manager with any class of contained item. ...
    (borland.public.delphi.non-technical)
  • Re: How come Ada isnt more popular?
    ... container varies, the element does not. ... The user should be able to describe string type in language terms ... but there are no generics instantiated. ... Implementation inheritance without values ...
    (comp.lang.ada)
  • Re: Generics for Delphi
    ... savings that generics are established and proven to deliver. ... Why and how does a 'base class' be 'generics based'? ... TList is an anything-goes general container based on arrays. ... a substittute for higher-form structures (trees, and lists etc.) ...
    (borland.public.delphi.non-technical)
  • Re: C++ template tutorial/review : comments welcomed
    ... I agree that the statement about 'unified object model' and 'template ... that of C++ template class, but I have not come seen any papers about it. ... > multiple types into a container, you need to keep track of what type they ... Introducing generics in the CLR ...
    (comp.lang.cpp)