🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2090

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

#2090
From: Dan Cross
Date: Wed, 02 Dec 2026 17:01
56 lines
3308 bytes
In article <11eoj9r$2o8nc$1@dont-email.me>,
David Brown  <david.brown@hesbynett.no> wrote:
>On 01/12/2026 22:09, bartc wrote:
>> [snip]
>> In any case it requires a much stricter, and hierarchical, type system,
>> such as you might find in Ada, and may be possible in C++.
>
>It does not require hierarchical types (there are no type hierarchies
>and inheritance needed), but it does require users to be able to make
>their own types and define overloaded operators on them between
>different types, and their own conversion functions, to be user-friendly.
>
>C can provide the strong and strict types (using structs), but not the
>overloads.  So in C, you can end up with :
>
>	Acceleration a = Acceleration_C(9.81);
>	Time t = read_clock();
>	Distance d = mult(mult(0.5, a), mult(t, t));
>
>("mult" here would be a _Generic macro.)
>
>while in C++ you can have :
>
>	Acceleration a { 9.81 };	// or auto a = 9.81_m_p_ss
>	Time t = read_clock();
>	Distance d = 0.5 * a * t * t;
>
>So this /can/ be done in C, but it is much more cumbersome to define,
>less scalable (you will want to generate the _Generic macros in some
>way, rather than writing them by hand!) and the result is ugly.
>
>Most importantly, however, you need the language to support defining
>these types and operators yourself.  Adding support for lengths and
>times might be okay in the language itself, but imagine trying to add
>/all/ SI units to the compiler.  And even then, someone will come along
>that wants to measure speed in feet per nanosecond.  (Award yourself a
>pat on the back if you know who that might be!)
>
>
>> I mentioned Frink (https://frinklang.org/) which supports thousands of
>> physical units. That is so comprehensive that I decided it would be
>> pointless to emulate a tiny fraction of it within my own PL.
>>
>> That's fine; my Casio works perfectly will with unitless numbers. So can
>> a PL!
>
>Sure.  But sometimes it can work better with units - it can eliminate a
>class of programming errors, and programmers need all the help they can get.

Indeed.  F# did an interesting thing here, with their "Units of
Measure" stuff.

https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/units-of-measure

	- Dan C.
Technical Details
Message-ID: <11episd$8fn$1@reader2.panix.com>
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
References: <11bes8b$1gncr$1@dont-email.me> <11enagh$24n1m$2@dont-email.me> <11end36$26j38$1@dont-email.me> <11eoj9r$2o8nc$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!weretis.net!feeder9.news.weretis.net!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail
From: cross@spitfire.i.gajendra.net (Dan Cross)
Newsgroups: comp.lang.c
Subject: Re: variadic min and max, (any some and none, cat and more)
Date: Wed, 2 Dec 2026 17:01:01 -0000 (UTC)
Organization: PANIX Public Access Internet and UNIX, NYC
Message-ID: <11episd$8fn$1@reader2.panix.com>
References: <11bes8b$1gncr$1@dont-email.me> <11enagh$24n1m$2@dont-email.me> <11end36$26j38$1@dont-email.me> <11eoj9r$2o8nc$1@dont-email.me>
Injection-Date: Wed, 2 Dec 2026 17:01:01 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80";
	logging-data="8695"; mail-complaints-to="abuse@panix.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: cross@spitfire.i.gajendra.net (Dan Cross)