FB Quine

Post your FreeBASIC source, examples, tips and tricks here. Please don’t post code without including an explanation.
gothon
Posts: 225
Joined: Apr 11, 2011 22:22

Re: FB Quine

Post by gothon »

counting_pine wrote:I managed to lose another byte*2 before the #X using implicit string literal concatenation:

Code: Select all

#Define P(X)?X:?"P("#X ")"
P("#Define P(X)?X:?""P(""#X "")""")
Nice, I didn't know you could do implicit string concatenation.
counting_pine wrote:Note: A space (or ampersand) is necessary after #X otherwise the following quote gets sucked into the string literal of #X, as seen here:

Code: Select all

#define p(x) print "abc"#x"ghi"
p(def) ''expanded to: print "abc"$"def""ghi"
That probably shouldn't happen..?
Remember that the preprocessor is just a source code manipulation engine, it does not understand the code it generates. The compiler (which does understand it) passes over the code only after the preprocessor mangles it up. So while the preprocessor is parsing its own input correctly, the output it generates is somewhat unexpected in this case thanks to the way quotations work inside strings.

The only reason the same thing doesn't happen to the left side is because stringize adds the $, which I suppose it adds to explicitly prevent escape sequence expansion, even though it doesn't really need to.
Lachie Dazdarian
Posts: 2338
Joined: May 31, 2005 9:59
Location: Croatia
Contact:

Re: FB Quine

Post by Lachie Dazdarian »

Code: Select all


I win!
gothon
Posts: 225
Joined: Apr 11, 2011 22:22

Re: FB Quine

Post by gothon »

Lachie Dazdarian wrote:

Code: Select all


I win!
Yes and this program also prints out the stated rules too, amazing!
counting_pine
Site Admin
Posts: 6323
Joined: Jul 05, 2005 17:32
Location: Manchester, Lancs

Re: FB Quine

Post by counting_pine »

gothon wrote:Remember that the preprocessor is just a source code manipulation engine, it does not understand the code it generates. The compiler (which does understand it) passes over the code only after the preprocessor mangles it up. So while the preprocessor is parsing its own input correctly, the output it generates is somewhat unexpected in this case thanks to the way quotations work inside strings.
But ideally if the macro sees two separate tokens, then so should the preprocessed text (unless ## is used).

I guess it may be easy enough to fix by making the preprocessor append a space to stringized literals..
TESLACOIL
Posts: 1769
Joined: Jun 20, 2010 16:04
Location: UK
Contact:

Re: FB Quine

Post by TESLACOIL »

u sad sad sad m&m's lol.....but you are out done


Here is the path of multi recursive quine

Ruby → Python → Perl → Lua → OCaml → Haskell → C → Java → Brainfluck → Whitespace → Unlambda

the two arrows after 'BrainFallout' are an indication of the depths of sadness one programmer descended to

About 3/4 the way one this page it gets a mention
http://en.wikipedia.org/wiki/Quine_%28computing%29



Some people just code, other just cant stop, lol

canfreebasic haz more yummies likeyesterday tomorrow as in more lollycode

Code: Select all

HAI
 CAN HAS STDIO?
 PLZ OPEN FILE "LOLCATS.TXT"?
     AWSUM THX
         VISIBLE FILE
     O NOES
         INVISIBLE "ERROR!"
 KTHXBYE
at lazt a a sandwidge i can real ate's too much
Post Reply