|
|
Label: ♦english
♦miscellaneous
fu
created at Friday, 2010-05-21, 06:47:28
fu
modified at Friday, 2010-05-21, 06:49:39
0 Replies, 1540 Hits
A quine program is a program that prints out the source codes of itself. To be more fun, the source codes should not be read from the source file, nor should it be stored in some kind of global variable from which to be accessed. An interesting quine program should reconstruct its source codes programatically in some way. A list of quine programs in other languages can be found one RosettaCode .
A simple quine program in Dao can be produced easily by porting the C implementation in C to Dao. But the more interesting way is to write a quine using Dao macros:
syntax{Quine $EXP}as{io.writef('syntax{Quine $EXP}as{%s}Quine %s',\'$EXP\',\'$EXP\')}Quine io.writef('syntax{Quine $EXP}as{%s}Quine %s',\'$EXP\',\'$EXP\')
It works with the development version of Dao available from the mercurial repository of Dao on google code . The idea of this quine program is to use macro to transform the following new syntax:
Quine io.writef('syntax{Quine $EXP}as{%s}Quine %s',\'$EXP\',\'$EXP\')
into an io expression with the expression itself being "glued" into a string by quoting the macro variable in the target syntax,
\'$EXP\'
This seems to be the simplest quine program that can be written using Dao macro.Source URL:
http://www.daovm.net/space/dao/thread/235
Comments
|
fu: ... I forgot to say something about the plan for the whole new year in my previous reply. Well, besides w ... (Jan.19,01:40) fu: ... Happy new dragon year (which will start from this sunday)! Actually, it was a busy month (I wish th ... (Jan.18,22:46) ybabel: What's the plan for the new year ? Hello 'vry budy :- ) happy new year (when is the new year for you Fu ?) I saw you come back and comm ... (Jan.18,18:59) |