Am 21.05.2011 11:26, schrieb Matthew Ong:
Hi D Developer/Walter Bright,

Coming from a VM environment.

Should D be able to do binary sharing when the same template is being
used for different data type.

In java using template, the same LinkedList binary is shared for both
String class type and also Integer class type.

LinkedList<String> list=new LinkedList<String>();
LinkedList<Integer> list=new LinkedList<Integer>();

// Can also apply for Account/Order/PO...
LinkedList<Account> list=new LinkedList<Account>();

But there is a single LinkedList Class File(single binary).


This is because Javas generics are gone when the code is compiled, i.e. List<Integer> und List<String> is the same type.
I find them rather useless, you can't overload from Generics parameters:
  void foo(List<Integer> l) { ... }
  void foo(List<String> l) { ...  }
won't compile.
Totally different from D or C++ where a new type is created that is actually specific to the template parameter.

Perhaps that is possible via some sort of binary plumbing internal to
the compiler? I believe the wrapper is just to ensure the Object type
handling casting concern. I might be wrong.


In D you can have non class types as template parameters.
And even with class types your code could handle different classes in a different way via "static if( is(T : MyType) ) { ... }" etc

Accoding to Jonathan Davis,

 >There is no linking involved in mixins. It's not shared.

This approach I believe allow the final output be smaller even and
pushes the D to be closer even to the dynamic ability of VM but without
the extra over head.

Can someone really say why this is a bad bad idea for memory with some
automated plumbing being done like in ActiveX/Com/DCOM.



Reply via email to