Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c++ Subject: Re: C++ named requirements as concepts Date: Mon, 30 Sep 2024 10:18:38 -0700 Organization: A noiseless patient Spider Lines: 44 Message-ID: <86frph12mp.fsf@linuxsc.com> References: <86h6a15tuv.fsf@linuxsc.com> <20240929144913.000051e4@yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Date: Mon, 30 Sep 2024 19:18:39 +0200 (CEST) Injection-Info: dont-email.me; posting-host="e153cd915235505af8c5be8b67e222a3"; logging-data="2445808"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GbY+XUUnqw0Eu3aEIIDClCXUsUlC1FC8=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:FiKvh5CcT2bSByLoS2uEKtWCGjA= sha1:MoWQ0JKYaYT96up2HK/9GmMyZWk= Xref: csiph.com comp.lang.c++:120481 Muttley@DastartdlyHQ.org writes: > On Mon, 30 Sep 2024 15:21:22 +0200 > David Brown boring babbled: > >> Certainly that is an established kind of polymorphism, and pretty >> much the only hit when googling "value polymorphism" is "return >> value polymorphism". It is found in Ada, Haskell, and Rust (I >> think). You can also do it in C++, at least to some extent, by >> making types with conversion operators to different types. (It can >> be used in expression templates, for example.) >> >> But that does not at all fit with the examples he gave in his >> "specialist" language, which was just pattern matching. It fits >> better with the link he gave, though that was more like C++ >> template variables. >> >> I think Tim's conclusion that Muttley is confused is more likely. > > Please explain what you find so complicated about a polymorphic > function call being based on the VALUE of one or more parameters > passed to it rather than the type of parameter? Imagine in C++ if > you could do: > > void func(int i = 1) { cout << "One\n"; } > void func(int i = 2) { cout << "Two\n"; } > void func(string s = "hello") { cout << "Hello!\n"; } > void func(int i) { cout << "Int default\n"; } > void func(string s) { cout << "String default\n"; } > > int main() > { > for(int i=0;i < 5;++i) func(i); > func("hello"); > func("world"); > } > > I'm sure even a thickheads like you and Rensch can figure how that > would run now it has your familiar comfy C++ syntax. Until you describe what you mean in terms of an existing, public language, such as Haskell, and without any imaginary extensions, and with an example that can be compiled as is and run successfully, there is no reason to pay attention to anything you say.