www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Maybe another way to do compile time rewrites

reply "aaaaa" <unomerite gmail.com> writes:
Currently what happens is you do

dmd program1.d

and program1.d uses mixin and compile time reflections to 
internally rewrite itself to be effectively program2.d so

dmd program1.d

and

dmd program2.d

are the same.

However another possible way might be

rdmd program3.d > program2.d
dmd program2.d

That is, program3.d would (at runtime) generate program2.d which 
you can then compile. This has the advantage of being possibly 
faster and simpler, because you don't have to do everything at 
compile time. Recent talks have lamented at the limited tools 
available for compile time debugging and if you generate the code 
at runtime, you have access to all the runtime facilities for 
debugging code. This also removes the restriction of not being 
able to do system calls during compile time because you can do 
whatever you want during the runtime of program3.d

I have no idea how much more complex this would be and am just 
thinking out loud. Anyway, thanks everyone for developing and 
maintaining D!
Jun 20 2014
next sibling parent "Tofu Ninja" <emmons0 purdue.edu> writes:
On Saturday, 21 June 2014 at 04:34:50 UTC, aaaaa wrote:
 Currently what happens is you do

 dmd program1.d

 and program1.d uses mixin and compile time reflections to 
 internally rewrite itself to be effectively program2.d so

 dmd program1.d

 and

 dmd program2.d

 are the same.

 However another possible way might be

 rdmd program3.d > program2.d
 dmd program2.d

 That is, program3.d would (at runtime) generate program2.d 
 which you can then compile. This has the advantage of being 
 possibly faster and simpler, because you don't have to do 
 everything at compile time. Recent talks have lamented at the 
 limited tools available for compile time debugging and if you 
 generate the code at runtime, you have access to all the 
 runtime facilities for debugging code. This also removes the 
 restriction of not being able to do system calls during compile 
 time because you can do whatever you want during the runtime of 
 program3.d

 I have no idea how much more complex this would be and am just 
 thinking out loud. Anyway, thanks everyone for developing and 
 maintaining D!

If that was as effective as doing it at compile time, then any language could do it and we would have never needed/wanted all the compile time features that we have now.
Jun 20 2014
prev sibling next sibling parent Ary Borenszweig <ary esperanto.org.ar> writes:
On 6/21/14, 1:34 AM, aaaaa wrote:
 Currently what happens is you do

 dmd program1.d

 and program1.d uses mixin and compile time reflections to internally
 rewrite itself to be effectively program2.d so

 dmd program1.d

 and

 dmd program2.d

 are the same.

 However another possible way might be

 rdmd program3.d > program2.d
 dmd program2.d

 That is, program3.d would (at runtime) generate program2.d which you can
 then compile. This has the advantage of being possibly faster and
 simpler, because you don't have to do everything at compile time. Recent
 talks have lamented at the limited tools available for compile time
 debugging and if you generate the code at runtime, you have access to
 all the runtime facilities for debugging code. This also removes the
 restriction of not being able to do system calls during compile time
 because you can do whatever you want during the runtime of program3.d

 I have no idea how much more complex this would be and am just thinking
 out loud. Anyway, thanks everyone for developing and maintaining D!

It's not complex at all, and it's a great idea (and it seems more and more people are concluding what you just concluded). See this: http://forum.dlang.org/thread/lnq5m7$2jiq$1 digitalmars.com
Jun 21 2014
prev sibling parent "aaaaa" <unomerite gmail.com> writes:
Oh dear! I should have spent more time googling to see if there 
was already a similar thread made. Thanks for the link and sorry 
for cluttering the forums!

 It's not complex at all, and it's a great idea (and it seems 
 more and more people are concluding what you just concluded). 
 See this:

 http://forum.dlang.org/thread/lnq5m7$2jiq$1 digitalmars.com

Jun 22 2014