Article View: comp.lang.c++
Article #998Re: Polymorphism (Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthesis for proper ...
From: Ross Finlayson
Date: Mon, 23 Nov 2026 00:17
Date: Mon, 23 Nov 2026 00:17
78 lines
5566 bytes
5566 bytes
On 11/22/2026 12:12 PM, Tristan Wibberley wrote: > On 19/11/2026 22:36, Ross Finlayson wrote: > >> polymorphic types, for example any of various accounts after vtables yet >> anyways otherwise according to a block of functions in C, so, >> function-overloading, > > I suppose that concept name would be interpreted for C as it is for C++ > due to the close relationship between the two (especially with your > mention of vtables which has strong connotations of what people call > "polymorphic types" vis-a-vis C++). > > However, that's not the only referent and there's a formal CS/mathsy one > that admits no runtime variation. The procedure who's argument type is a > so-called "polymorphic type" could be seen to be a polymorphic procedure > but that seems to me to be more properly what a procedure template > describes. > > How would readers of the groups characterise C++ so-called "runtime > polymorphism" and that which C programmers would and have often done > with vtables (GObject, for example), formally? > > Hello. Tristan, this was sort of being bandied-about in the "Inversion-of-control and dependency-injection in C", about accounts like there's how vtables do it, there's how usually enough it's just a context-pointer of function-pointers, which is much alike if less involved than the composition of vtables, then there's how "Go" and "Rust" do it, which is a bit less involved, there are "tagged unions" or "tagged structs" and "kinded unions" for variants the type (the variant type, eg, since COM or where people learn about these things), about co-variant return types, and function overloading, in C, to attain to the features that C++ of course already famously supports in the language, in a particularly opinionated way. There are a variety and number of ways to make for "polymorphism" as after "encapsulation", yet, "polymorphim" refers specifically to "polymorphism of types", vis-a-vis, a "polymorphic type", basically about what's considered the needful for C is the auto keyword, since C already has types. Then, the _Generic construct, which is in both C and C++, and has various accounts which can be made where it's on par with templates, though of course with much less general flexibility or support, there's that the type of whatever "auto" is in the lvalue can result carrying the "controlling-expression" in the _Generic expression to the type-matching to using the value, vis-a-vis "holder" or "variant" which has got no otherwise type itself, except insofar as that's a placeholder of "vanishing/phantom" types, that yet agreeably the tagged-union or kinded-union has members that can make for distinct types of the tags under controlling-expression, then about this overloading/underloading sort of account about fixed-size array types in C (i.e., that are line, page, and huge-aligned memory buffers, or, short, 32, long, or max name char array. This targeting C11/C++11, then there's "__auto__" in GCC/Clang which is alike C23's "auto", the lvalue of which can be the controlling-expression in a _Generic construct resulting maintaining the type on through about parameterizing the type, then about "polymorphism in types" beyond "polymorphic types", the controlling-expression in the _Generic construct can be as of according to a union type after "offsetof" a given field named eg "t" for tagged or "k" for kinded, these being about the few moving parts in C through which "type" definition or values resulting expressions on identifiers by duck-typing exist, about getting a typed representation at compile-time, vis-a-vis, run-time polymorphism after variant types, where the goal of "polymorphism in types" is compile-time polymorphism. Thanks for writing, good luck with that.
Technical Details
Message-ID:
<1ECdneMw6tyAG572nZ2dnZfqnPGdnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<11cj4a0$23796$1@dont-email.me> <11djohu$s03n$5@dont-email.me> <niudnUINZp08GGD3nZ2dnZfqn_SdnZ2d@giganews.com> <11dla8a$1p00u$2@kst.eternal-september.org> <11dnb8m$hv1$1@reader2.panix.com> <88mcnftsxdWY52L3nZ2dnZfqn_ednZ2d@giganews.com> <11dviam$18n4p$2@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!local-1.nntp.ord.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 23 Nov 2026 00:17:33 +0000 Subject: Re: Polymorphism (Re: [meta] O tempora, o mores! (was Re: does an expression in a logical statement need parenthesis for proper evaluation?)) Newsgroups: comp.lang.c++,comp.lang.c References: <11cj4a0$23796$1@dont-email.me> <11djohu$s03n$5@dont-email.me> <niudnUINZp08GGD3nZ2dnZfqn_SdnZ2d@giganews.com> <11dla8a$1p00u$2@kst.eternal-september.org> <11dnb8m$hv1$1@reader2.panix.com> <88mcnftsxdWY52L3nZ2dnZfqn_ednZ2d@giganews.com> <11dviam$18n4p$2@dont-email.me> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Sun, 22 Nov 2026 16:17:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <11dviam$18n4p$2@dont-email.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <1ECdneMw6tyAG572nZ2dnZfqnPGdnZ2d@giganews.com> Lines: 78 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-2syjPZcPapNdXLb589G4CMgkb4sgl+mgy7iCpd54we+NcPrMZiVq/6op0va1sa6F3RfczmgaZ5Fn7bx!Jbvrrht/vVPgV9ouogmMsuUc57E7cnH+qW+F9sTRgAW7IJKVNaLyFgnGDAjiXbPWxEijTR41ptrt X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40