A gentle critque..

Ben Cooley Ben_member at pathlink.com
Mon May 15 20:20:20 PDT 2006


In article <e4baj5$aut$1 at digitaldaemon.com>, Walter Bright says...
>
>BCS wrote:
>> What do ya think new D users would think about a converter that does 
>> 100% correct convention of a sub set (+10%) of C (and maybe cpp) code? 
>> Say just global function prototypes, structs typdefs (c style) and 
>> anything else that would be easy to get right. Some of the stuff (in C, 
>> the most common stuff) translates directly, and shouldn't be that bad to 
>> translate.
>
>There is always something in each header that is not translatable :-(

Could the language be extended to allow the non-translatable elements to simply
be used "as is" by wrapping them with intrinsics as needed?

In other words:

import std.cpp;
import msvc.cpp;

include "mylib.h"


..
..
..

// Intrinsic cpp new class function
my_cpp_class = NewCppClass("MyClass", 100, "Parameter");

// Intrinsic cpp macro value
const int MY_MACRO = CMacroValue("MY_MACRO");

// Intrinsic template instantiation
my_cpp_template = NewTemplateClass("std::vector", "MyClass");

etc.

The advantage of this is that, though it may not be pretty.. it's simple and it
doesn't require you to wrap what could literally be thousands of headers.  It
also means that your links to the original code will not break unless the api
breaks.

If you want, you can build your wrapper using intrinsics instead of having to
rewrite a header.  But more importantly you can just use what you need, and
directly call c functions and instantiate, call, and delete c classes and
templates or access C or Cpp macros.





More information about the Digitalmars-d mailing list