🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #715

Re: variadic min and max, (any some and none, cat and more)

#715
From: fir
Date: Fri, 23 Oct 2026 13:24
74 lines
2777 bytes
fir pisze:
> fir pisze:
>> David Brown pisze:
>>> Variadic functions have no way of counting their arguments, or 
>>> identifying their types.
>>
>>
>> this is silly becouse it cos t one register to use so its totally not 
>> a problem
>>
>>
>> the case with various type arguments is much harder but the one with
>> "all ints" etc is quite easy
>>
>>
>> simpl as i said the user need the arg[] and arg_max avaliable
>>
>>
>> foo(int ...v)
>> {
>>   for(int i=0; i<sizeof(v)/sizeof(int); i++)
>> {
>>
>> }
>>
>> }
>>
> 
> 
> so as its show in this all one type case you dont need  any varargs macros
> 
> foo (int n, ...) {}
> 
> 
> in fact you dont need nothing may just acces via n[i] above all you need
> it to pass in register the max_n value (or size of args block)
> 
> 
> 
> 
> 
> 
>> i dont know maybe just same syntax can be used
>>
>> foo(int[] v)
>> {
>>
>> }
>>
>> so you can put foo(tab) or foo(2,3,4,2,32,3,23,2) at will
>> thou this version would pass via pointer and is someone need to pass 
>> by stack probably would need to use f(int ...)  version
>>
> 




note it even can somewhat work in present c


void foo(int n,...)
{
   int sum = 0;
     for(int i=0; ; i++)
	{
        if( (&n)[i]== 0) break;
	sum+=(&n)[i];
	}

}

but this assumes args are all put on stack
Technical Details
Message-ID: <11bfn5q$1qvtp$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <11bes8b$1gncr$1@dont-email.me> <11bf84v$1jkb5$1@dont-email.me> <11bfko4$1q1en$1@dont-email.me> <11bflk6$1qchd$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: fir <profesor.fir@gmail.com>
Newsgroups: comp.lang.c
Subject: Re: variadic min and max, (any some and none, cat and more)
Date: Fri, 23 Oct 2026 15:24:09 +0200
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <11bfn5q$1qvtp$1@dont-email.me>
References: <11bes8b$1gncr$1@dont-email.me> <11bf84v$1jkb5$1@dont-email.me>
 <11bfko4$1q1en$1@dont-email.me> <11bflk6$1qchd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 23 Oct 2026 13:24:10 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1933241"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+vBlstxZ3p3wsJV8ih2kOId7XUiDy+ytU="; posting-host="43cad3fa7698c2e9be359f2072ea7249"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101
 Firefox/140.0 SeaMonkey/2.53.24
Cancel-Lock: sha1:9cjKEqLxAlEZI992vqgR/Um25ko= sha256:mO+C5AKe3Hm1+JbG3ursbzcg1U8EodCzxyijTxvmA1Y=
	sha1:iFJKtQ35mT5vfrDXOdfJtE5nykI= sha256:c0dBXhDJbTnpPCRbqdoL78HwEuNIBdtm9HKUyrHqsFY=
In-Reply-To: <11bflk6$1qchd$1@dont-email.me>