Deutsch English Français Italiano |
<v3jg38$3o8nk$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Malcolm McLean <malcolm.arthur.mclean@gmail.com> Newsgroups: comp.lang.c Subject: Re: Writing own source disk Date: Mon, 3 Jun 2024 05:16:40 +0100 Organization: A noiseless patient Spider Lines: 49 Message-ID: <v3jg38$3o8nk$1@dont-email.me> References: <v3hmha$3banl$1@dont-email.me> <87sexvm1lr.fsf@bsb.me.uk> <v3iu4n$3i607$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 03 Jun 2024 06:16:41 +0200 (CEST) Injection-Info: dont-email.me; posting-host="2ee56f0ee86b12ded72c789d9c294f2d"; logging-data="3941108"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/r7Jml2wJbDKcalI1axsogbYSLSKH6WvM=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:+4wh9uKwJbIW2iTb+p25RvDYDTc= Content-Language: en-GB In-Reply-To: <v3iu4n$3i607$1@dont-email.me> Bytes: 2777 On 03/06/2024 00:10, bart wrote: > On 02/06/2024 23:17, Ben Bacarisse wrote: >> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes: >> >>> Writing a prgram which writes its own source to standard output is a >>> standard programming problem. It's called a quine. >> >> A quine must also not process any input. > > No input at compile-time or runtime? > > A compiler necessarily has to have the source code of the program as > input, so what are the limitations? A C program can use #include; does > that extend to directives like #embed, or is that considered cheating? > > Exactly. It's a quine. You run the progrm, and it produces its own source, as a FileSystem .xml file. Convert to a regular diretory, and compile, and you You will get a program wich spits out exactly the same FileSystem xml file. So a quine. It's here. https://github.com/MalcolmMcLean/babyxrc/tree/master/Examples/BabyXFS You need the entire repository if you want a play. Youb need the babyxfs_ tools to manipulate the FileSystem xml files. And you need Baby X RC to pack up the Xml file into a compilEAble C file, conventionally called source.c (When you comile for the first time, make sure you have the real source.c and not the place holder). However if you you want to compile the programs, they are quines, but only on the second generation. source.c is the first generation. (And of course the program must not have a file called source.c that is not a place holder for converting to xml to produce the real source.c, or the real source.c when you convert to the first generation). -- Check out Basic Algorithms and my other books: https://www.lulu.com/spotlight/bgy1mm