November 02, 2005
Sean Kelly wrote:
> Ivan Senji wrote:
> 
>> Sean Kelly wrote:
>>
>>> Ivan Senji wrote:
>>>
>>>>
>>>> Makes you wonder how great it would be if DMD fron-end was written in D.
>>>> It would be many times easier to understand, maintain, change, debug...
>>>
>>>
>>> It probably wouldn't be too hard to port, given the design.
>>>
>> I thought that the problem with porting would be interfacing to back-end wich is C++.
> 
> 
> That doesn't affect how hard the code would be to port, only its usefulness for integration with a C++ back-end.  I suspect that a D version of the front-end still might be useful for anyone hoping to write an IDE for D in D, etc.  Beyond that... perhaps someone feel like writing an intermediate code generator in D? ;-)
> 

Well i did write a code generator for D but never did finish it really, it was more of a D->extendedD translator but i didn't hook it up to a good lexer, so it was limited and it was grammar based so it was suffering from my inability to write a good D grammar. But it was fun to write and play with some syntax extensions for D.

One of my favorite ones (would be nice to have it in D) was (part taken from C#2.0):

int[] numbers, roots;
numbers.length = 10;

(each[int index] numbers) = index*2; //numbers[i] = i*2;
numbers.{writefln(it);}; //print all numbers

numbers.{roots ~= sqrt(it);}
//wich is also equal to
(each[int index] roots) = sqrt(numbers[index]);

> 
> Sean
November 03, 2005
>> Ivan Senji wrote:
>> That doesn't affect how hard the code would be to port, only its
>> usefulness for integration with a C++ back-end.  I suspect that a D
>> version of the front-end still might be useful for anyone hoping to
>> write an IDE for D in D, etc.  Beyond that... perhaps someone feel like
>> writing an intermediate code generator in D? ;-)

Peri Hankey as written a D to D translator as a proof of concept for his
analytical grammar machine [http://www.dsource.org/projects/languagemachine/].
The whole thing may seem very counter intuitive at first sight but it is really
a powerfull way to manipulate languages.
I have played with it to change the front-end grammar into something close to
C++ so as to get the back-end generate the appropriate D code. So far it works
nicely for the subset it can recognize.

One can tune this front( or back )-end to implement new features that will be translated into current D code. It could help to taste the look and feel of ideas prior to have them directly implemented in the compiler.



1 2
Next ›   Last »