- auto return type - 6 Updates
- Just some code - 4 Updates
- auto return type - 1 Update
jameskuyper@alumni.caltech.edu: Jun 28 08:49PM -0700 On Thursday, June 28, 2018 at 10:20:40 AM UTC-4, Chris Vine wrote: > > keywords may break older programs that use them as names elsewhere. > A pure function means something completely different. That would be a > very poor choice of words, quite apart from needing a new keyword. We're talking about C++ here. The C++ standard defines what the term "pure virtual function" means in the context of C++ (10.4p2). Like many other pieces of C++ jargon, you can't interpret it correctly by interpreting it word for word according to the generally accepted meanings of those words - the only way to correctly understand what the phrase means in a C++ context is to read what the C++ standard says about such functions. That definition does not correspond to "a pure function in the mathematical sense which is also virtual". This is not a particularly odd occurrence in C++ - consider the term "null pointer constant" (NPC). You might be forgiven for thinking it should mean "a constant expression with pointer type and a null value" - but the reality is that many constant expressions fail to qualify as integer literals, and therefore fail to qualify as NPCs. Furthermore, while an NPC implicitly converts to pointer types in many contexts, in themselves they are prohibited from having pointer type. You're free to refer to other possible meanings of the phrase "pure virtual function", but in a C++ context you should always identify the fact that you're not using the meaning for that term which is provided by the C++ standard. To criticize someone for using the term in a C++ context with precisely the meaning described by the C++ standard for that term, is to reject the whole point of having a standard. |
boltar@cylonHQ.com: Jun 29 09:02AM On Thu, 28 Jun 2018 16:58:47 +0100 >> Either you're being pedantic for the sake of it or you're just another >> aspie unable to follow normal discussion. >If I were, that would be a totally inappropriate remark to make. Ad I couldn't care less and I think you are. >hominem remarks of that kind would just be an indication that you have >lost the argument. So you seem not only to be lacking understanding I haven't lost anything, you're just being defensive because you know you don't have a leg to stand on as someone else has pointed out very eloquently. I'll just settle for calling you an idiot. |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Jun 29 11:36AM +0100 On Thu, 28 Jun 2018 20:49:27 -0700 (PDT) > phrase means in a C++ context is to read what the C++ standard says > about such functions. That definition does not correspond to "a pure > function in the mathematical sense which is also virtual". My point was not that in C++ the expression "pure virtual function" means a pure function which is also virtual. I know that in C++ "pure virtual function" refers to a virtual function without implementation. 'pure' is not at present a keyword in C++. My point was that if C++ is going to have a 'pure' keyword, then the keyword ought to be used to denote a pure function in the computer science sense, and not used to denote a C++ pure virtual function (in other words, it shouldn't be used just to provide an alternative to writing '= 0'). Out of interest, is this a view you actually disagree with? On whether to have 'pure' as a keyword, that raises other issues. D has one, rust has decided not to because rust's type system deals with the issue in other ways. I would take the lead from compiler writers and ask them whether the keyword would provide optimization opportunities that would otherwise be difficult to apply. |
jameskuyper@alumni.caltech.edu: Jun 29 03:47AM -0700 On Friday, June 29, 2018 at 6:37:08 AM UTC-4, Chris Vine wrote: > On Thu, 28 Jun 2018 20:49:27 -0700 (PDT) > jameskuyper@alumni.caltech.edu wrote: ... > denote a C++ pure virtual function (in other words, it shouldn't be > used just to provide an alternative to writing '= 0'). Out of > interest, is this a view you actually disagree with? Yes - since the C++ standard defines the meaning of "pure virtual function", then I think would be entirely appropriate for it to be modified to use "pure" as a keyword for the purpose of making a virtual function be a pure virtual function. I think that using "pure" with any other meaning would be MORE confusing. Convince the committee that it shouldn't have used the term "pure" for this purpose, and they can change the standard to use some other terminology, without breaking any existing code. Unless and until you succeed in convincing them, them it would be reasonable for them to define a "pure" keyword with that meaning; and reasonable to criticize their decision to use "=0" instead. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jun 29 10:33PM +0200 > succeed in convincing them, them it would be reasonable for them to > define a "pure" keyword with that meaning; and reasonable to criticize > their decision to use "=0" instead. The `=0` goes way back. It's Bjarne's work exclusively. The committee is not to blame, they couldn't do a thing about it. He wrote in evolution & design that it was meant to indicate no function body. That clashes a bit with modern C++ (possibly also the pre-standard ARM, but my copy is not accessible to me now) where a pure virtual can have a function body, just not in the declaration in the class. Which is a strange inconsistency in the standard. Anyway... Cheers!, - Alf |
Vir Campestris <vir.campestris@invalid.invalid>: Jun 29 09:33PM +0100 > succeed in convincing them, them it would be reasonable for them to > define a "pure" keyword with that meaning; and reasonable to criticize > their decision to use "=0" instead. OK, so I'm not a mathematician - but I'm not aware of the use of pure in maths. Chemistry, yes... However if the intent is to replace virtual foo function() = 0; then shouldn't the syntax be pure foo function(); You don't need to say it's virtual. It's implied - it cannot not be virtual. Andy |
David Brown <david.brown@hesbynett.no>: Jun 28 10:10PM +0200 On 28/06/18 16:53, Alf P. Steinbach wrote: > their eyes glaze over? > I hadn't ever dreamed that current programmers have such difficulties. > But I'm learning. And maybe we can nail this more precisely. ;-) I think you'll have a lot of difficulty trying to get a precise point here - this is not a binary issue. The "maximum" example is easy, your original code is hard, and in between there is a sliding scale. It takes experience and a good understanding of other programmers to be able to tell if code is /too/ hard - and it will depend massively on the details of the code, the type of problem you are solving, and of course the programmers who are looking at the code. There is no black and white answer here - sorry. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jun 29 06:08AM +0200 On 28.06.2018 20:03, Bart wrote: > The same argument applies to the comma operator; you use it when you > really need to evaluate one expression inside another, and not just to > be able to write: In this case one really needs to evaluate one expression inside another. The control structure expresses exactly the intent. > else > With_stream_detection{}._); > app::run(); Here cleanup is performed before `app::run()`, which means it will never get executed with faux text. > : With_stream_detection{}._), > app::run(); > but it's not as good as just writing it properly. So it seems that /formatting/ is crucial. Thanks. Cheers!, - Alf |
woodbrian77@gmail.com: Jun 28 09:44PM -0700 On Wednesday, June 27, 2018 at 3:54:28 PM UTC-5, Alf P. Steinbach wrote: > and `goto` a common cleanup. > We use it because it's easier to understand and analyze, to prove > correctness of, due to the simple guarantees. Agreed, but iirc Nicolai Josuttis told of a problem he ran into with RAII. He had a lock but didn't give it a name. So the scope of the lock started and ended on the same line. If he can be tripped up by RAII and temporaries this way, it's not always easy breezy. Brian Ebenezer Enterprises - In G-d we trust. https://github.com/Ebenezer-group/onwards |
David Brown <david.brown@hesbynett.no>: Jun 29 09:12AM +0200 On 29/06/18 06:08, Alf P. Steinbach wrote: >> app::run(); >> but it's not as good as just writing it properly. > So it seems that /formatting/ is crucial. Thanks. I would not go as far as to say the change in formatting makes the code good, but it certainly makes it a lot clearer. It also gives spots for adding comments if that helps. (I do not advocate comments as an alternative to writing clear code - but sometimes code has to be complicated, and comments can then help.) Even something as simple as changing the spacing can greatly improve the readability of code. |
ram@zedat.fu-berlin.de (Stefan Ram): Jun 29 05:21AM >a pure function in the mathematical sense I am not aware of "pure function" being a common mathematical term. >while an NPC implicitly converts to pointer types in many contexts, in >themselves they are prohibited from having pointer type. What'll you tell me next? That a vector of bool is neither a container nor does it contain bools? But, yeah, main.cpp #include <iostream> #include <ostream> #include <type_traits> template< typename T > void describe( T const ) { ::std::cout << ::std::is_pointer< T >::value << '\n'; } int main() { describe( nullptr ); } transcript 0 |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment