3 ms·
What is unclear to me is how the final program manages to represent the entire code (thus the entire language loop). Wouldn't doing that make the source code re
by terabytest 13y ago
What is unclear to me is how the final program manages to represent the entire code (thus the entire language loop). Wouldn't doing that make the source code recursive and infinite? Or am I missing something important?
- SilasX 13y agoNo more recursive or infinite than any other self-replicator that has intermediate "bodies". EDIT: To clarify, there's actually a wrapper script on top of it all that tells the first script to execute, storing its output in file 2, then execute file 2 with language 2, then execute file 3 with language 3, and so on.
- recuter 13y agohttps://github.com/mame/quine-relay/blob/master/src/code-gen.rb https://github.com/mame/quine-relay/blob/master/src/code-gen... This is a neat project but somehow the implementation is a lot less mind bending than the definition. Which is rather the opposite of what I experienced when I first heard of a Quine and figured out how to write one (http://en.wikipedia.org/wiki/Quine_(computing) http://en.wikipedia.org/wiki/Quine_(computing), Turbo Pascal in my case, heh). This smacks of something else, perhaps art.
- woobles 13y agoLook at that Wikipedia article under "Multiquines"
- baddox 13y agoWe already have lots of single-language quines, which are programs that output exactly their own source code when evaluated. In other words, there's a text C and a function F such that F(C) == C (i.e. C is a fixed point of F), where F is a single programming language evaluator and C is a source code file. In this case, however, the function F happens to be the composition of a bunch of individual functions. So F is equivalent to Rexx ∘ R ∘ Python ∘ Prolog, but with many more functions composed than I am willing to type right now. This doesn't change the nature of what we're searching for, which is simply a fixed point of a given function. Realistically, of course, it makes it more difficult and impressive for someone to actually accomplish, but mathematically/computationally speaking it's the same thing.
- shawnz 13y agoIf you look at the ruby source file[1], you'll see that the first thing it does is take all of its source and put it in a variable $s. Then it evaluates the source code in that variable, with that source having access to itself as a string. All of the intermediate representations could easily contain this string in its entirety (and they likely do). Hopefully you can see now how it's not so impossible (but still ridiculously awesome!) [1] https://github.com/mame/quine-relay/blob/master/QR.rb https://github.com/mame/quine-relay/blob/master/QR.rb
- thedigitalengel 13y agoRepresenting self is actually not that difficult or mind-bending; you just need a representation that is isomorphic to the program source. For instance, you could store the ASCII symbols in an integer array: int array = { ... } // holds the source code, // except its own representation int array_index; // The index in the source code // (where the actual integers in // array interpreted as source appear) for i = 0 to array_index: print (array[i] as an ASCII character) for i = 0 to array_length: print (array[i] as integer ++ ", ") for i = array_index + 1 to array_length: print (array[i] as an ASCII character) The core idea is that you can interpret `array` in two ways, as an array of integers or an array of ascii characters representing the program source. The only difficult part is adjusting array_index. With a little effort, this can be scaled to a chain of languages.