Three Unlikely Successful Features of D

Kapps opantm2+spam at gmail.com
Wed Mar 21 14:01:09 PDT 2012


On Wednesday, 21 March 2012 at 17:20:28 UTC, Walter Bright wrote:
> On 3/21/2012 7:23 AM, Adam D. Ruppe wrote:
>> But, is import unlikely success, or is this just a
>> leftover feeling from my massive bias in the early
>> days? I have to say it is my bias, since everyone
>> else uses import and they all know it is good.
>
> I knew import would be good :-)
>
> It's because I've used languages before with an import, and as 
> a compiler guy, I knew what a kludge #include is. The 
> preprocessor in C/C++ is a crutch to make up for deficiencies 
> in the language.

On the topic of import, mixin imports are something that I 
believe will eventually become a great deal more popular than 
they are today. First, there's the advantage of being able to use 
a language/syntax more appropriate for the task at hand. For 
example, for things that output html you could just import mixin 
a raw html file. But the real advantage is that you can still do 
compile-time processing on this. Plug in an xml parser, or 
something like pegged, and you can now extend Html and generate D 
code for it. For example, if you have something like 
runat="server" on an element, just like in ASP.net you could 
create a serverside element for this and manipulate it. Because 
you know exactly which parts are static and which are dynamic, 
you could (at compile time) create buffers containing the static 
portions to prevent having to copy things many times. Unlike 
other languages, there would be no performance hit to doing this 
because it's all done at compile time. This is just one example. 
Another one would be automatically creating bindings for a 
scripting language, or even automatically creating bindings for a 
C header file.


More information about the Digitalmars-d mailing list