OT: on IDEs and code writing on steroids

Daniel Keep daniel.keep.lists at gmail.com
Wed May 20 21:30:38 PDT 2009



Nick Sabalausky wrote:
> ...
> 
> Maybe this is naive, but what about an AST-level template/generic? Couldn't 
> that provide for the best of both worlds?
> 
> For instance, suppose (purely hypothetically) that the .NET assembly system 
> were changed to allow the source for a D/C++ style of source-level template 
> to be embedded into the assembly. Then they'd be able to do D/C++ style 
> source-level template/code-generation. Right? Now obviously the big problem 
> with that is it would only be usable in the same language it was originally 
> written in. So, instead of getting that cross-language support by going all 
> the way down to the IL bytecode level to implement generics (which, as you 
> said, would somehow prevent the flexibility that the D/C++ style enjoys) 
> suppose it only went down as far as a language-agnostic AST?
> 
> ...

What I've always thought might be an interesting experiment would be to
change templates in LDC so that instead of generating an AST, they
generate code that generates code.

So when you use A!(T), what happens is that at runtime the template is
"run" with T as an argument.  This generates a chunk of LLVM bitcode
which LLVM then assembles to machine code and links into the program.

This alleviates the problem with using source in that if you embed the
template's actual source, then you suddenly ALSO have to embed the
standard library's source and the source of any other libraries you
happened to compile with.

Oh, and the same version of the compiler.

  -- Daniel



More information about the Digitalmars-d mailing list