- "Use Stronger Types!" - 4 Updates
- cmsg cancel <nvlckf$n7m$2@dont-email.me> - 1 Update
- Best way to implement class printing - 1 Update
Tim Rentsch <txr@alumni.caltech.edu>: Nov 12 05:22AM -0800 > On 11/4/2016 10:10 AM, woodbrian77@gmail.com wrote: [...] >> unsigned for quantities: >> https://www.youtube.com/watch?v=wvtFGa6XJDU > I do not like unsigned. Just seems unnatural to me. Actually just the opposite: the natural numbers are the positive integers (and also, according to ISO[1], zero). It is the signed integer types, which include negative integers, that are unnatural. :) [1] https://en.wikipedia.org/wiki/ISO_31-11#Sets |
"Öö Tiib" <ootiib@hot.ee>: Nov 12 11:35AM -0800 On Saturday, 12 November 2016 15:22:36 UTC+2, Tim Rentsch wrote: > positive integers (and also, according to ISO[1], zero). > It is the signed integer types, which include negative > integers, that are unnatural. :) Subtraction of natural number from natural number results with integer number. In C++ subtraction of 'unsigned' from 'unsigned' results with yet another 'unsigned' by modular arithmetic. Therefore 'unsigned' of C++ is not natural number but unnatural number and one has to write a wrapper around it to reach something resembling a natural number. |
Jerry Stuckle <jstucklex@attglobal.net>: Nov 12 05:11PM -0500 On 11/12/2016 8:22 AM, Tim Rentsch wrote: > It is the signed integer types, which include negative > integers, that are unnatural. :) > [1] https://en.wikipedia.org/wiki/ISO_31-11#Sets You have a full five gallon pail of water. You empty it. How many more gallons do you have in the pail now? -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
Paavo Helde <myfirstname@osa.pri.ee>: Nov 13 01:00AM +0200 On 12.11.2016 15:22, Tim Rentsch wrote: > It is the signed integer types, which include negative > integers, that are unnatural. :) > [1] https://en.wikipedia.org/wiki/ISO_31-11#Sets I see your smiley, but comparison with natural numbers is not actually appropriate. Unsigned integers might be natural, but their incarnation in C and C++ with wrapping over to some arbitrary large value is anything else than natural. Ditto the other way: how is it natural in any way that incrementing an unsigned integer will yield zero at some point? For signed integers wrap-over is UB and everybody is fine with that. My take is that wrap-over for unsigned types is not UB just in order to support sloppy programming which produces negative numbers as intermediate results. In other words, the wrap-over nonsense has brought in to alleviate the inherent defect in the design of unsigned integers - discontinuity at zero. If there were no unsigned numbers, such a hack would not be needed. |
bleachbot <bleachbot@httrack.com>: Nov 05 08:41PM +0100 |
Tim Rentsch <txr@alumni.caltech.edu>: Nov 12 07:18AM -0800 > In general, the code for displaying, printing, etc should be kept > outside the object. The object should expose enough of itself to > make that possible. I would like to offer a different viewpoint. Both of the above positions are shortsighted, for the same underlying reason: they insist that one approach is better than the other in all cases. Questions like this one should be seen as offering design choices, and a good choice in one case may very well be a poor choice in other circumstances. Generically here we have three agents: a requester, something to be displayed, and a display medium. Which one is better positioned to decide how the display action should take place? In different circumstances, it could be the requester, the display medium, or the object to be displayed. In some cases no single agent has all the knowledge needed to carry out the assignment, in which case there needs to be a negotiation between two (or less often, more) agents to accomplish the task at hand. Of course we try to minimize the set of cases where the more complicated interactions are needed, but it isn't always possible to avoid them entirely, and it is foolish to pretend otherwise. As regards the single responsibility principle, and other similar principles - what we want is good design. Principles offer guidelines, or heuristics, for how to discover a good design, but they are means to an end, not an end in itself. As with geometry, there is no royal road to making good design choices. Different architectural choices will lead to different designs, and consequently different answers to questions like the one under consideration here. |
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