D and the world

Alix Pexton _a_l_i_x_._p_e_x_t_o_n_ at _g_m_a_i_l_._c_o_m_
Mon Apr 30 00:26:40 PDT 2007


0ffh wrote:
> Alix Pexton wrote:
>> Mike Parker wrote:

> Sorry, but no good. First of all, you make bugfixes/updates more 
> uncomfortable
> and modding an impossibility.

I'm not at all clear what you mean by this. This can be said of any poorly thought out piece of code, which my suggestion may well be. I have no experience of programming compilers/interpreters, but I do know that both begin with lexing the source, even if that is the only common part of the 2 implementations, allowing the code to be shared between the 2 means that the language that is being processed would, on that pass at least, be the same for both.

If on is able to craft a path of compatability between the 2 on further passes of the compilation, means that there is only one implementation, and I can't think if any argument that contradicts the idea that maintaining one piece of code is easier that maintaining 2 pieces of code that have to perform the same task.

If, and I know it is a big if, you can write a series of pure (CTFE-able) functions that parse your script and process it as far as possible, then have 2 separate backends that take that output and at compile time fininsh processing it to native code (which we have seen done by Don with his mathematical template-foo). At runtime ou ycan then execute the same pure functions to reach the itimediate stage, and complete the processing with whatever functions you like to make the bytecode to be run in your application.



> BTW, you don't need D for what you suggested.

I'd be interested in looking at any other language that that compiles to native code, and can used the same functions at compile time and run time to process a DSL. I've not come accross any others yet.

> In this case it does not matter at all if you make a source-to-source 
> transform
> using D's metaprogramming capabilities or in any other way.

I admit that I did not make this point at all well in my previous post. I wasn't trying to suggest DSL-to-D translation, if that is what you mean by "source-to-source", only that in D you have the option to use the same code at run-time and compile-time, so, if in implementing an engine that needs to be able to load logic dynamically during development, you can with careful implementaion, use the same code to import and compile those same scripts into the executeable when making a release build.

A...



More information about the Digitalmars-d mailing list