The D programming language (of interest here; there actually have been several distinct significant D languages [http://en.wikipedia.org/wiki/D_programming_language_%28disambiguation%29] during the history of programming) is a new language designed as an evolution of [C]/[C++]. The language specification is currently at http://www.digitalmars.com/d/index.html Also of potential interest are the Wikipedia page [http://en.wikipedia.org/wiki/D_%28programming_language%29] and Wiki4D site [http://www.prowiki.org/wiki4d/wiki.cgi?FrontPage]. To see how D compares to other languages, check out http://www.digitalmars.com/d/comparison.html . ---- We can call [Tcl] from D fairly simply. In fact, it looks a ''lot'' like C++ in most places. The main issue is to generate an import symbol file for the Tcl API (which can be done by using the genStubs script file). Under [Microsoft Windows] I had to convert the standard [ActiveTcl] tcl83.lib to an OMF format library. To do this we convert to COFF format using Microsoft's LINK program and then Digital Mars' COFF2OMF utility link /lib /convert tcl83.lib coff2omd tcl83.lib To illustrate, here is an initial stab. Build this using dmd simple.d tcl83.lib (Using Windows) or dmd simple.d -L-ltcl (Using UNIX) ---- // simple.d - Copyright (C) 2003 Pat Thoyts // // Demonstrate linking to Tcl from the D programming language. // See http://www.digitalmars.com/d/index.html for information // about ``D'' // // $Id: 6261,v 1.28 2006-11-20 19:00:16 jcw Exp $ import std.stream; import std.string; import std.compiler; // ---------------------------------------------------------------------- // Define the bits we need for interfacing to Tcl API // extern (C) { alias void* ClientData; alias void (*Tcl_FreeProc)(char* blockPtr); alias void (*Tcl_CmdDeleteProc)(ClientData clientData); alias int (*Tcl_CmdProc)(ClientData clientData, Tcl_Interp* interp, int argc, char* argv[]); alias void* Tcl_Command; struct Tcl_Interp { char* result; Tcl_FreeProc blockPtr; int errorLine; } enum { TCL_OK = 0, TCL_ERROR = 1, TCL_RETURN = 2, TCL_BREAK = 3, TCL_CONTINUE = 4, } const Tcl_FreeProc TCL_VOLATILE = cast(Tcl_FreeProc)1; const Tcl_FreeProc TCL_STATIC = case(Tcl_FreeProc)0; const Tcl_FreeProc TCL_DYNAMIC = case(Tcl_FreeProc)3; Tcl_Interp* Tcl_CreateInterp(); Tcl_Command Tcl_CreateCommand(Tcl_Interp* interp, char* cmdName, Tcl_CmdProc proc, ClientData clientData, Tcl_CmdDeleteProc deleteProc); int Tcl_Eval (Tcl_Interp* interp, char* string); int Tcl_EvalFile (Tcl_Interp* interp, char* fileName); char* Tcl_GetStringResult(Tcl_Interp* interp); void Tcl_SetResult (Tcl_Interp* interp, char* str, Tcl_FreeProc freeProc); } // ---------------------------------------------------------------------- int main(char[][] args) { Tcl_Interp* interp = Tcl_CreateInterp(); Tcl_CreateCommand(interp, "ddemo", &DDemoCmd, null, null); int r; if( args.length < 2 ) { r = Tcl_Eval(interp, "puts \"Tcl version: [info tcl]\"; ddemo"); } else { r = Tcl_EvalFile(interp, args[1]); } printf(Tcl_GetStringResult(interp)); return r; } // Add a new command to the Tcl interpreter. // In this case: return some information about the D compiler. extern (C): int DDemoCmd(ClientData clientData, Tcl_Interp *interp, int argc, char* argv[]) { MemoryStream stm = new MemoryStream; stm.printf(std.compiler.name); stm.printf(" %d.%d", std.compiler.version_major, std.compiler.version_minor); Tcl_SetResult(interp, toStringz(stm.toString()), TCL_STATIC); return TCL_OK; } // ---------------------------------------------------------------------- // // Local variables: // mode: c // compile-command: "dmd simple.d tcl83.lib" // cygwin: "gdc simple.d -ltcl" // End: ---- [RLH] That seems like a good language. I wonder why it isn't used more? [MSW] From a quick glance at it, probably because there's no open source compiler and thus the thing only runs on a very limited set of (OS x CPU/arch). There's http://www.opend.org and it seems dead for soon half a decade... [RLH] Is this integration with GCC what you are talking about it not having [http://home.earthlink.net/~dvdfrdmn/d/]? But the limited OS support is probably a reason. [MSW] Ok, haven't seen that one. Still being a kind of "simple" successor to C, it should run in more places. Kind of like same reason why people don't use Cyclone([http://www.eecs.harvard.edu/~greg/cyclone/]) etc I guess... [SYStems] I would say it's not used more because of competition, D is trying to compete a pretty saturated market. * For the open source croud, it will compete with C, C++, Java, possibly C# (mono and stuff) * For the commercial croud, it's mainly Java and C# and possibly C/C++ * For somekind of croud, it's Haskell, OCaml, Scheme etc ... * For the looking for fun new languages to learn croud it's JavaScript (because of AJAX), Ruby, Perl 6 and Tcl 8.5 OO new features ;) Those in my opinion are the market segments where D may compete and as I suggest they are saturated ---- As of October 2006, D is on the verge of being listed with [Languages with a Tk binding] [http://lists.puremagic.com/pipermail/digitalmars-d/2006-October/008776.html]. [RLH] That isn't how I read that thread. [LWV] After reading through the thread a bit, I see http://www.algonet.se/~afb/d/TK.zip is a beginning of a binding between D and Tk. Some of the issues are people wanting a D GUI that is designed with D philosophies, and later in the thread, concern about the fact that Tk requires X11 headers in some cases. I do not get the feeling that the D community itself is embracing Tk. Instead, there appears to be a number of people thinking about the possibility, with a larger number looking at alternatives. nedbrek - I've updated the code for a later D compiler (cygming special, gdc 0.24, using dmd 1.020). ---- [[ [Category Language] ]]