Deutsch English Français Italiano |
<vj04v9$2lq17$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: question about linker Date: Sat, 7 Dec 2024 00:30:34 +0000 Organization: A noiseless patient Spider Lines: 77 Message-ID: <vj04v9$2lq17$1@dont-email.me> References: <vi54e9$3ie0o$1@dont-email.me> <vila9j$3j4dg$1@dont-email.me> <vin4su$49a6$1@dont-email.me> <vin95m$5da6$1@dont-email.me> <vinh3h$7ppb$1@dont-email.me> <vinjf8$8jur$1@dont-email.me> <vip5rf$p44n$1@dont-email.me> <viprao$umjj$1@dont-email.me> <viqfk9$13esp$1@dont-email.me> <viqhmn$131h8$3@dont-email.me> <visbmp$1ks59$1@dont-email.me> <visgs7$1mgdb$1@dont-email.me> <viv5ve$2dqir$1@dont-email.me> <vivggi$2gkth$1@dont-email.me> <slrnvl6j8a.rlm.ike@iceland.freeshell.org> <8WK4P.16316$xPr6.10730@fx10.iad> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 07 Dec 2024 01:30:33 +0100 (CET) Injection-Info: dont-email.me; posting-host="92f4e16e4a21192eb5e2d0ba1a6ec304"; logging-data="2811943"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/tEfuFh8CK0hGT7kEqX1U" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:NIh5vMlngoyr3p02QAw7gSbKQjs= Content-Language: en-GB In-Reply-To: <8WK4P.16316$xPr6.10730@fx10.iad> Bytes: 3435 On 06/12/2024 22:30, Scott Lurndal wrote: > Ike Naar <ike@sdf.org> writes: >> On 2024-12-06, Bart <bc@freeuk.com> wrote: >>> My language: >>> >>> println =a,=b # 13 characters, 0 shifted >>> >>> (And that space is optional!) In C (assume the existence of stdio.h): >>> >>> printf("A=%lld B=%f\n",a,b); # ~28 characters, 8 shifted >>> >>> Enough said. >> >> Looks like a cherry-picked example. >> How would this (slightly modified) C statement be notated in your language: >> >> printf("a:%lld b:%g\n",a,b); >> >> ? > > Or > > printf("a:%2$8.8lld b:%1$10.2g",b,a); In this case I'd just write it like this: printf("a:%2$8.8lld b:%1$10.2g",b,a) ie. calling printf via an FFI. It's marginally shorter than C since I don't need the semicolon. However, your attempt to catch me out on something I might not support has backfired, since it doesn't work even in C. This program: #include <stdio.h> int main(void) { long long a = 123456789876543210; double b=1.0/3; printf("a:%2$8.8lld b:%1$10.2g",b,a); } compiled with gcc 14.1 on Windows, produces: a:%2$8.8lld b:%1$10.2g On WSL and gcc 9.x it works, sort of. (Matching the label in the format string with the $ value and the argument looks confusing.) I'd typically do this stuff like this: const fmta = "8.8", fmtb = "10.2" fprint "a:# b:#", a:fmta, b:fmtb Here I don't need to care what the exact types of a and b are. I mean, what goes in place of ? here: printf("%?", a+b*c); Assume only that a, b, c are numeric types, which might be opaque types exported by some header. Here's another issue: #include <stdio.h> int main(void) { int i=0; printf("%d %d %d", ++i, ++i, ++i); } 3 compilers give me output of 1,2,3; 3,2,1; and 3,3,3. If I do 'print ++i, ++i, ++i', it gives me 1,2,3 always. (Because this print is not a function call.)