Deutsch English Français Italiano |
<uvbhph$2do64$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: David Brown <david.brown@hesbynett.no> Newsgroups: comp.lang.c Subject: Re: Recursion, Yo Date: Fri, 12 Apr 2024 16:51:28 +0200 Organization: A noiseless patient Spider Lines: 69 Message-ID: <uvbhph$2do64$1@dont-email.me> References: <uut24f$2icpb$1@dont-email.me> <uutqd2$bhl0$1@i2pn2.org> <uv2u2a$41j5$1@dont-email.me> <87edbestmg.fsf@bsb.me.uk> <uv4r9e$mdd3$1@dont-email.me> <uv5e3l$q885$1@dont-email.me> <uv5gfd$qum1$1@dont-email.me> <uv5lgl$s6uj$1@dont-email.me> <uv61f6$v1jm$1@dont-email.me> <uv68ok$11080$1@dont-email.me> <uv7a8n$18qf8$3@dont-email.me> <uv867l$1j8l6$1@dont-email.me> <_zSRN.161297$m4d.144795@fx43.iad> <20240411075825.30@kylheku.com> <r8TRN.114606$Wbff.54968@fx37.iad> <uva6ep$24ji7$1@dont-email.me> <uvah1j$26gtr$1@dont-email.me> <uvanua$27qn8$1@dont-email.me> <uvbbed$2cdhc$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 12 Apr 2024 16:51:29 +0200 (CEST) Injection-Info: dont-email.me; posting-host="085f1be00dfebd806a614550c40cad96"; logging-data="2547908"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hS4Ng9t7Q/BxCH26iws8tv/yzlfOk/uk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cancel-Lock: sha1:axU02Fz9Z3gTmEMaBFkFGS3oTNA= In-Reply-To: <uvbbed$2cdhc$1@dont-email.me> Content-Language: en-GB Bytes: 3783 On 12/04/2024 15:03, Janis Papanagnou wrote: > On 12.04.2024 09:30, David Brown wrote: >> >> I prefer the consistency of function calls using parenthesis. The >> consistent alternative, found in some other languages, is that they >> never need parenthesis - "foo a b" calls "foo" with parameters "a" and "b". > > Mind that this is just one "consistency" aspect. True. > > Another one is that you can write (e.g. in Algol 68 or many other > higher level languages) the equivalent of - again a simple example - > > int x = 2 * pi * r > > without necessity to know whether pi is a constant, the result of a > function (calculation), the result of a function implicitly called > just once on demand, or whatever else. Conceptually as a programming > language user you want the value. > But is that a good thing? For some programming, especially with higher-level languages, then it is fine. For other types of programming, you want to know if functions are called in order to have a better idea of the flow of control and the efficiency of the code, plus perhaps thread safety. > I don't say one or the other is "better", just that consistence is > not an absolute property. Fair enough, and I agree that this is not a matter that has a single correct answer. It is not uncommon that being consistent in one way necessitates being inconsistent in another way. Just for fun, this is a way to let you define a function-like object "pi" in C++ that is called automatically, without parentheses : #include <numbers> template <auto f> class Auto_executor { public : using T = decltype(f()); operator T () { return f(); } }; static Auto_executor<[](){ return std::numbers::pi; }> pi; double circumferance(double r) { return 2 * pi * r; } I am not giving an opinion as to whether or not this is a good idea (and obviously it is completely redundant in the case of a compile-time constant). Some people might think C++ is great because it lets you use tricks like this, some people might think C++ is terrible because it lets you use tricks like this :-)