Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Kaz Kylheku <643-408-1753@kylheku.com> Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Fri, 31 May 2024 15:34:29 -0000 (UTC) Organization: A noiseless patient Spider Lines: 53 Message-ID: <20240531081143.419@kylheku.com> References: <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com> <87msoh5uh6.fsf@nosuchdomain.example.com> <87y18047jk.fsf@nosuchdomain.example.com> <87msoe1xxo.fsf@nosuchdomain.example.com> <87ikz11osy.fsf@nosuchdomain.example.com> <20240530170836.00005fa0@yahoo.com> <20240530180345.00003d9f@yahoo.com> Injection-Date: Fri, 31 May 2024 17:34:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="be4518a799bc3fa2f27a0cf115882681"; logging-data="2411673"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++TQf2Dznk6im/43+gI3YnO9Z7fPaJ714=" User-Agent: slrn/pre1.0.4-9 (Linux) Cancel-Lock: sha1:JjIVy6Rx7vYquKDROhKuU1Bw/ZE= Bytes: 3237 On 2024-05-31, bart wrote: > Here's how builtin embedding worked using a feature of my older C compiler: > > #include > #include > > char hello[] = strinclude("hello.c"); > > int main(void) { > printf("hello =\n%s\n", hello); > printf("strlen(hello) = %zu\n", strlen(hello)); > printf("sizeof(hello) = %zu\n", sizeof(hello)); > } Lisp: $ cat strincl.tl (defmacro strinclude (path) (put-line `including @path`) (file-get-string path)) (defun test() (strinclude "/etc/hostname")) When we run it interpreted we see from the debug put-line that /etc/hostname is included at macro-expansion time before we run the test function: $ txr -i strincl.tl including /etc/hostname This TTY may be recorded for privacy-violating and evidence-gathering purposes. 1> (test) "sun-go\n" Now compile the file: the file is pulled it at compile time. Twice. :) A double expansion took place due to certain complexities of compiling. $ txr --compile=strincl.tl including /etc/hostname including /etc/hostname Now when we load the compiled file, the diagnostic trace "including /etc/hostname" no longer appears: the string is part of the test function as a literal: $ txr -i strincl TXR is enteric coated to release over 24 hours of lasting relief. 1> (test) "sun-go\n" -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca