Deutsch English Français Italiano |
<v4l7k1$3m349$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: bart <bc@freeuk.com> Newsgroups: comp.lang.c Subject: Re: C23 thoughts and opinions Date: Sun, 16 Jun 2024 00:20:34 +0100 Organization: A noiseless patient Spider Lines: 50 Message-ID: <v4l7k1$3m349$1@dont-email.me> References: <v2l828$18v7f$1@dont-email.me> <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com> <v2lji1$1bbcp$1@dont-email.me> <87msoh5uh6.fsf@nosuchdomain.example.com> <f08d2c9f-5c2e-495d-b0bd-3f71bd301432@gmail.com> <v2nbp4$1o9h6$1@dont-email.me> <v2ng4n$1p3o2$1@dont-email.me> <87y18047jk.fsf@nosuchdomain.example.com> <87msoe1xxo.fsf@nosuchdomain.example.com> <v2sh19$2rle2$2@dont-email.me> <87ikz11osy.fsf@nosuchdomain.example.com> <v2v59g$3cr0f$1@dont-email.me> <87plt8yxgn.fsf@nosuchdomain.example.com> <v31rj5$o20$1@dont-email.me> <87cyp6zsen.fsf@nosuchdomain.example.com> <v34gi3$j385$1@dont-email.me> <874jahznzt.fsf@nosuchdomain.example.com> <v36nf9$12bei$1@dont-email.me> <87v82b43h6.fsf@nosuchdomain.example.com> <v4igql$32qts$1@dont-email.me> <v4kib3$3icus$1@dont-email.me> <v4kpvc$3jrmr$1@dont-email.me> <v4l57m$3lqic$7@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 16 Jun 2024 01:20:33 +0200 (CEST) Injection-Info: dont-email.me; posting-host="48e70c5b8227fe18cdef471a005ffbe8"; logging-data="3869833"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nUJIAQj8W9gjLExOtxk9t" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:3X+O6vy9LiwA1f8Llr7R5/bwiU0= In-Reply-To: <v4l57m$3lqic$7@dont-email.me> Content-Language: en-GB Bytes: 3239 On 15/06/2024 23:39, Lawrence D'Oliveiro wrote: > On Sat, 15 Jun 2024 20:27:41 +0100, bart wrote: > >> The "+" is used for compile-time string/data-string concatenation.) > > Why didn’t you follow the C convention of implicit concatenation, just by > placing literals next to each other? Why is that better? I did actually have that, but it wasn't as useful. It could only work at the lexical level with actual string literals, for a start. As it is now I can do this: const x = "abc" const y = "def" const z = x + y # "abcdef" These are named constants with proper scope, which are only resolved in a later pass. It also applies to strings created by an embedded file: s := "(" + sinclude("help.txt") + ")" I can use parentheses and it will still work: const cond = ... print (cond | "abc" | "def") + "xyz" It will display 'abcxyz' or 'defxyz' depending on 'cond', which is known at compile-time. I could choose to implement "*" also ... (I've just spent 10 minutes doing that) .... so that I can do this, where having proper operators comes in useful: "A" + "B" * 5 ABBBBB ("A" + "B") * 5 ABABABABAB Here is a use-case: const cols = 80 println "-" * cols # output divider line This in a lower level language where strings are not first class types. How C does it is a hack that was fine for 1972.