www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Quines

reply BCS <BCS pathlink.com> writes:
 run time

void main(){printf(a~\140~a~\140";");}char[]a=`void 
main(){printf(a~\140~a~\140";");}char[]a=`;

 compile time   =op

const char[]a=`const char[]a=`;const char[]b=`;const char[]`;const 
char[]c=`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);
Jul 01 2006
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
BCS wrote:
  run time
 
 void main(){printf(a~\140~a~\140";");}char[]a=`void 
 main(){printf(a~\140~a~\140";");}char[]a=`;
http://smjg.port5.com/wwwep/quines/d.html Somewhere I've got one similar to the last of these but using writef.
  compile time   =op
 
 const char[]a=`const char[]a=`;const char[]b=`;const char[]`;const 
 char[]c=`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b
"c=\140"~c~\140~c); 
Writing code to do stuff at compile time like this is an interesting idea. I've seen the C preprocessor used for this: http://www.99-bottles-of-beer.net/language-c-c++-preprocessor-115.html Stewart.
Jul 10 2006
parent reply Lutger <Lutger_member pathlink.com> writes:
Cool. 
Try compiling http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
from Don Clugston's meta library. No need for a preprocessor...

In article <e8to1l$180u$1 digitaldaemon.com>, Stewart Gordon says...
BCS wrote:
  run time
 
 void main(){printf(a~\140~a~\140";");}char[]a=`void 
 main(){printf(a~\140~a~\140";");}char[]a=`;
http://smjg.port5.com/wwwep/quines/d.html Somewhere I've got one similar to the last of these but using writef.
  compile time   =op
 
 const char[]a=`const char[]a=`;const char[]b=`;const char[]`;const 
 char[]c=`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b
"c=\140"~c~\140~c); 
Writing code to do stuff at compile time like this is an interesting idea. I've seen the C preprocessor used for this: http://www.99-bottles-of-beer.net/language-c-c++-preprocessor-115.html Stewart.
Jul 10 2006
next sibling parent kris <foo bar.com> writes:
Lutger wrote:
 Cool. 
 Try compiling http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
 from Don Clugston's meta library. No need for a preprocessor...
 
 In article <e8to1l$180u$1 digitaldaemon.com>, Stewart Gordon says...
 
BCS wrote:

 run time

void main(){printf(a~\140~a~\140";");}char[]a=`void 
main(){printf(a~\140~a~\140";");}char[]a=`;
http://smjg.port5.com/wwwep/quines/d.html Somewhere I've got one similar to the last of these but using writef.
 compile time   =op

const char[]a=`const char[]a=`;const char[]b=`;const char[]`;const 
char[]c=`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b
"c=\140"~c~\140~c); 
Writing code to do stuff at compile time like this is an interesting idea. I've seen the C preprocessor used for this: http://www.99-bottles-of-beer.net/language-c-c++-preprocessor-115.html Stewart.
LOL - Don is The Man :D
Jul 10 2006
prev sibling parent reply Don Clugston <dac nospam.com.au> writes:
Lutger wrote:
 Cool. 
 Try compiling http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
 from Don Clugston's meta library. No need for a preprocessor...
You just inspired me to update it to DMD 0.162. It's very simple now, all the workarounds are gone. It's probably worth submitting to 99-bottles-of-beer.net now. And yes, D templates seem to be even more powerful than the combination of C preprocessor + C++ templates. -Don.
 
 In article <e8to1l$180u$1 digitaldaemon.com>, Stewart Gordon says...
 BCS wrote:
  run time

 void main(){printf(a~\140~a~\140";");}char[]a=`void 
 main(){printf(a~\140~a~\140";");}char[]a=`;
http://smjg.port5.com/wwwep/quines/d.html Somewhere I've got one similar to the last of these but using writef.
  compile time   =op

 const char[]a=`const char[]a=`;const char[]b=`;const char[]`;const 
 char[]c=`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b~"c=\140"~c~\140~c);`;pragma(msg,a~\140~a~\140~b~"b=\140"~b~\140~b
"c=\140"~c~\140~c); 
Writing code to do stuff at compile time like this is an interesting idea. I've seen the C preprocessor used for this: http://www.99-bottles-of-beer.net/language-c-c++-preprocessor-115.html Stewart.
Jul 11 2006
parent reply Don Clugston <dac nospam.com.au> writes:
Don Clugston wrote:
 Lutger wrote:
 Cool. Try compiling 
 http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
 from Don Clugston's meta library. No need for a preprocessor...
You just inspired me to update it to DMD 0.162. It's very simple now, all the workarounds are gone. It's probably worth submitting to 99-bottles-of-beer.net now. And yes, D templates seem to be even more powerful than the combination of C preprocessor + C++ templates. -Don.
I just submitted it.
Jul 11 2006
next sibling parent Dave <Dave_member pathlink.com> writes:
Don Clugston wrote:
 Don Clugston wrote:
 Lutger wrote:
 Cool. Try compiling 
 http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
 from Don Clugston's meta library. No need for a preprocessor...
You just inspired me to update it to DMD 0.162. It's very simple now, all the workarounds are gone. It's probably worth submitting to 99-bottles-of-beer.net now. And yes, D templates seem to be even more powerful than the combination of C preprocessor + C++ templates. -Don.
I just submitted it.
Very cool!
Jul 11 2006
prev sibling parent Lutger <Lutger_member pathlink.com> writes:
In article <e9107c$84j$1 digitaldaemon.com>, Don Clugston says...
Don Clugston wrote:
 Lutger wrote:
 Cool. Try compiling 
 http://www.dsource.org/projects/ddl/browser/trunk/meta/demo/beer.d
 from Don Clugston's meta library. No need for a preprocessor...
You just inspired me to update it to DMD 0.162. It's very simple now, all the workarounds are gone. It's probably worth submitting to 99-bottles-of-beer.net now. And yes, D templates seem to be even more powerful than the combination of C preprocessor + C++ templates. -Don.
I just submitted it.
Awesome. Although if I look at the top 3 of the site I'm not sure if it would speak for D to end up there, that is some painful code!
Jul 11 2006