Deutsch   English   Français   Italiano  
<vj263c$396ln$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!news.misty.com!weretis.net!feeder9.news.weretis.net!news.quux.org!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 19:02:05 +0000
Organization: A noiseless patient Spider
Lines: 71
Message-ID: <vj263c$396ln$1@dont-email.me>
References: <vi54e9$3ie0o$1@dont-email.me>
 <87mshhsrr0.fsf@nosuchdomain.example.com> <vidd2a$18k9j$1@dont-email.me>
 <8734j9sj0f.fsf@nosuchdomain.example.com> <vidnp3$1ovvm$2@paganini.bofh.team>
 <vihpjh$2hgg1$1@dont-email.me> <vihrh1$2hk5l$1@dont-email.me>
 <vii0jp$2jkd9$1@dont-email.me> <viifv8$2opi7$1@dont-email.me>
 <vik28b$390eg$1@dont-email.me> <vik8tc$3ang9$1@dont-email.me>
 <vikjff$3dgvc$1@dont-email.me> <viku00$3gamg$1@dont-email.me>
 <vil0qc$3fqqa$3@dont-email.me> <vil82t$3ie9o$2@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> <vj1r8n$35lal$1@dont-email.me>
 <vj1uge$36ugq$1@dont-email.me> <vj22ce$37g4b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 07 Dec 2024 20:02:04 +0100 (CET)
Injection-Info: dont-email.me; posting-host="92f4e16e4a21192eb5e2d0ba1a6ec304";
	logging-data="3447479"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18rochStN3Wye3gO7YReAsx"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:heccbqW1dF/aASwyXQ2jEjl8jp8=
Content-Language: en-GB
In-Reply-To: <vj22ce$37g4b$1@dont-email.me>
Bytes: 4613

On 07/12/2024 17:58, David Brown wrote:
> On 07/12/2024 17:52, Bart wrote:

>>     f ( ) ;
>>     f ( x , y , z ) ;
>>     ++ p . x ;
>>     q = ( void ) p ;
>>     label :
>>     f ( x , y , z ) ;
>>     a [ i + 1 ] ;
>>
> 
> That is just differently bad from "f(x,y,z);" and "q=(void*)p;".  Too 
> much space is bad spacing,

You specifically praised Forth for requiring spaces between tokens, 
which is exactly what this code has.

>> I know this won't cut any ice, as nothing I can possibly write will 
>> ever make the slightest bit of difference, but in C you write stuff 
>> like this:
> 
> No, in C /I/ don't write anything of the sort - nor do most C 
> programmers.  And I don't believe you write functions with 8 parameters 
> in your language either.  At the very least, these would be highly unusual.

This is the real example it was based on (here using pass-by-reference):

   proc fastidct8(int &a1, &a2, &a3, &a4, &a5, &a6, &a7, &a8) =

That itself was based on some original C which passed an array.

But because the values in the caller were not always consecutive (they 
were a column of a table), they needed copying into an array first, the 
function called, then copied back to the array since the function 
changes them.

Passing individual argument looked more efficient and tidier.

I'm sure it happens in C that several consecutive parameters have the 
same type, but there is no way to express that without repeating the 
type. Another real example:

   static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)

At least least this doesn't use a type like 'int32_t' otherwise it would 
be even longer, likely to overflow the line, and would obscure the names 
of the parameters. Just seeing how many there are becomes harder.

But even this would look far better as:

  static void *stbi__malloc_mad4(int a, b, c, d, add)

(You can keep the 'int add' to emphasise that the first 4 are meant to 
share the same type, and it's not just coincidence.)

Don't forget the separate declaration, which repeats the parameters, 
that an exported function might need, as shown here:

   extern int bn_add (Bignum c, Bignum a, Bignum b);      # in .h file

   int bn_add (Bignum c, Bignum a, Bignum b) {            # in .c file

'Bignum' is written 6 times. This was ported from this version in my syntax:

   export proc bn_addu(bignum dest, a, b) =

Here, 'bignum' is written only once. (The 'export' is needed if this 
build into an independent binary, such as a DLL, so that it is exported.)