Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Malcolm McLean Newsgroups: comp.lang.c Subject: Re: Writing own source disk Date: Tue, 4 Jun 2024 19:45:07 +0100 Organization: A noiseless patient Spider Lines: 64 Message-ID: References: <87sexvm1lr.fsf@bsb.me.uk> <875xuqmdjn.fsf@bsb.me.uk> <87y17kkerb.fsf@bsb.me.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 04 Jun 2024 20:45:07 +0200 (CEST) Injection-Info: dont-email.me; posting-host="85bbfd75fcad1a475e75a7f0bece81d2"; logging-data="580932"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Y22/rFFPLP912nFiYdeY0DMyDR25BdtI=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:X+qvDi/8ANsPVb/ystB6GpfMHEw= In-Reply-To: <87y17kkerb.fsf@bsb.me.uk> Content-Language: en-GB Bytes: 4162 On 04/06/2024 14:40, Ben Bacarisse wrote: > Malcolm McLean writes: > >> On 03/06/2024 13:11, Ben Bacarisse wrote: >>> Malcolm McLean writes: >>> >>>> On 02/06/2024 23:17, Ben Bacarisse wrote: >>>>> Malcolm McLean 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. >>>>> >>>>>> And I have achieved a >>>>>> quine. But a serious quine. Not contrived special purpose code, but serious >>>>>> codde which can be used to package up source for real. >>>>> You XML-producing program may be very useful, but it's not really a >>>>> quine, serious or otherwise. >>>>> >>>>>> And it's completely >>>>>> portable ANSI C. So of course it can't write output to disk - that is >>>>>> impossible to achive portably. Instead it writes its own source to standard >>>>>> output using a simle XML format called FileSystem, which represents the >>>>>> source tree. >>>>> That sounds as if the program reads input (but it's not explicitly >>>>> stated) as well as not producing the program text but some XML >>>>> representation of the program text. That would make it not a quine for >>>>> two reasons. >>>>> How do you process a source tree in completely portable ANSI C? >>> >>>> The FileSystem XML fie is embedded with the program. It is a genuine >>>> quine. Compile it and see. >>> No need; I'll take your word for it. >>> >>>> It's also a very superior quine, and it spits out images and binaries. >>> If it's a quine (and I don't doubt you) then is spits out its own source >>> code. That can, of course, include source code encodings of images. >>> I'm not sure why you consider that superior, but that is, after all, a >>> rather subjective assessment. >>> >> It's not therortically interesting from a computer science perspective. >> You can encode images as source. >> >> But from a practical point of view, yes my quine is massively >> powerful. Most graphical programs do have images as source. And they just >> get zipped up into the FileSystem XML file. So any binary data can be >> included. Easily, Using exactly the same system. > > I'm not getting it. Why do I want a quine in connection to a graphical > program? I want a way to include everything in the distribution, but > we've had that for ages. Why is having a program that outputs something > you already have (by defintion!) of any use? > Because you've got the binary, but not the source. And whilst it is a quine, of course it is only a quine when you pass it the -quine option. Otherwise it is Space Invaders. But if you nedd to recompile the program for a new target, -quine spits out the source. BabyXFS quines are serious quines, they have a real purpose. -- Check out Basic Algorithms and my other books: https://www.lulu.com/spotlight/bgy1mm