Deutsch English Français Italiano |
<87bk4ime5r.fsf@bsb.me.uk> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!2.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse <ben@bsb.me.uk> Newsgroups: comp.lang.c Subject: Re: Writing own source disk Date: Mon, 03 Jun 2024 12:58:08 +0100 Organization: A noiseless patient Spider Lines: 57 Message-ID: <87bk4ime5r.fsf@bsb.me.uk> References: <v3hmha$3banl$1@dont-email.me> <87sexvm1lr.fsf@bsb.me.uk> <v3iu4n$3i607$1@dont-email.me> <87mso2mky5.fsf@bsb.me.uk> <v3k49t$3rdhi$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Mon, 03 Jun 2024 13:58:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e02f48bed505247df41ef3632285a916"; logging-data="4083937"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VaNCAZJuz0ebaQ41tyEeVCR9lbW/hB0I=" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:WQHKLk91kgHgNeNMKDAJWpb5cmM= sha1:zANMvpe0Q3T/TDQ3o+cwaSmjb1g= X-BSB-Auth: 1.222c43b4337a357460fe.20240603125808BST.87bk4ime5r.fsf@bsb.me.uk Bytes: 3105 bart <bc@freeuk.com> writes: > On 03/06/2024 10:31, Ben Bacarisse wrote: >> bart <bc@freeuk.com> writes: >> >>> 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? >> The program isn't running at compile time. >> >>> A compiler necessarily has to have the source code of the program as input, >>> so what are the limitations? >> The compiler can do what it likes! >> >>> A C program can use #include; does that extend >>> to directives like #embed, or is that considered cheating? >> There's nothing wrong with using either, but a C quine that uses #embed >> relies on knowing the name of the file in which it is stored. > > I assume you can use __FILE__ with #embed? (I can do that with my version > of it). > > Then it doesn't need to know the actual name of the file. I don't know if that is guaranteed by the standard as I've not really looked at C23, but if is it, that would be a way to write a (rather boring) quine in C23. >> It is a >> "fixed point of the execution environment", but it's probably the least >> interesting C quine possible -- much like >> 1 >> is a quine in languages that evaluate and print an expression. > > Not really. What part are you objecting to? That the above (a C quine using #embed) in not a fixed point of the execution environment? That it's not an uninteresting quine? Or that it's not "much like" self-evaluating expression quines? You said "not really" in reply to a moderately complex paragraph. > I've just added this line: > > puts(strinclude(__FILE__)); I think I'm missing your point. That does input at run-time (if my guess about strinclude is correct). -- Ben.