A gentle critque..

Ben Cooley Ben_member at pathlink.com
Tue May 16 17:13:46 PDT 2006


In article <e4cvf6$pfi$1 at digitaldaemon.com>, dennis luehring says...
>
>> // For simple template instantiation.  Creates a wrapper type in the cpp file
>> for this type.
>> cpptype VectorInt { std::vector<int> } MyVectorInt;
>
>have you any idea of how templates are generated and "instanciated"
>what should the compiler do at this step? (please the describe the 
>low-level part a little bit more detailed)

What are you talking about?  I have no intention of intantiating any templates
at all.  Templated classes are defered to the external cpp wrapper file:

To make it a bit clearer.. templates are instantiated in this way in the wrapper
Cpp code file.

class __VectorInt : public std::vector<int> {};

D uses __VectorInt, which was the point of providing the cpptype {} keyword in
the first place.  The code within the braces is not parsed by D, but placed in
an external cpp file which is compiled by a Cpp compiler into a standard Cpp
class that D CAN use.

>> // For instantiating constants
>> cppconst int NULL { NULL };

This is to permit the assiging of Cpp macros to D constants.  If the constants
are simple, the value of the constant is directly assigned, if not, the constant
expression is converted into an "extern int" reference, and the constant
variable is placed in the Cpp file to be compiled by a Cpp compiler.

// Cpp file definition for a complex macro constant
int __COMPLEX_MACRO_CONSTANT = COMPLEX_MACRO_CONSTANT;

Likewise, a complex functional macro can be placed in the Cpp file and wrapped
with a standard c function:

// In D if you the following...
int i = cppmacro(int,int) MIN(100, 200);

// Would cause a call to this function defined in the generated Cpp file below
extern "C" {
int __MIN(int a, int b)
{
return MIN(a,b);
}
}

>> // Creating a cpp class
>> MyClass c = new MyClass("A class\0");
>> // Calling a method on a cpp class
>> c.Method("String Argument\0");
>
>calling methods and instanciat classes through strings?
>this is joke, or? (use the COM interface)

I don't know.. is this a joke?  Let me ask you, do you find yourself personally
offended by these ideas?

>> // Handling an exception
>> cpp {
>> try {
>> c->ThrowException(%%str);
>> }
>> catch (std::string ex)
>> {
>> %%ret = ex;
>> }
>> }
>
>is this your idea of an clean integration? (what does clean mean in your 
>world)

Compared to what?  A multi-year project to convert the C Windows API to D so
that Windows software can finally be written?

I would suggest if you don't like it, then don't feel that you have to use it.

>ciao dennis
>
>btw: how many years do you code c/c++?

21 years.  I've actually used to own a copy of Zortech.  

How about you?







More information about the Digitalmars-d mailing list