|
From: Gerry Ford on 2 Apr 2008 20:39 "Arjen Markus" <arjen.markus(a)wldelft.nl> wrote in message news:d9078f0f-d62f-4d3b-8cea-caf6168f563d(a)e23g2000prf.googlegroups.com... > On 1 apr, 06:20, "Gerry Ford" <ge...(a)nowhere.ford> wrote: >> When I first read this a couple weeks ago, I wondered what this looks >> like >> in fortran: >> >> template <class StrictWeakOrdered> >> inline StrictWeakOrdered& max(StrictWeakOrdered& x, >> StrictWeakOrdered& y) { >> return x < y ? y : x; >> >> } >> >> and >> template <class StrictWeakOrdered> >> inline const StrictWeakOrdered& max(const StrictWeakOrdered& x, >> const StrictWeakOrdered& y) { >> return x < y ? y : x; >> >> } > > That is an easy one: > > max(x,y) > > Well, this Fortran equivalent is a trifle less powerful than the C++ > one, > but that does not mean it is not basically true :). Stepanov thought it was important that one of the above was & and the other was const &. The distinction is lost on me. My problem with c++ is that when you take out Microsoft and C, I'm not left with much. The template syntax is, e.g., beyond me. I like Stepanov's emphasis on algorithms. -- "That this social order with its pauperism, famines, prisons, gallows, armies, and wars is necessary to society; that still greater disaster would ensue if this organization were destroyed; all this is said only by those who profit by this organization, while those who suffer from it - and they are ten times as numerous - think and say quite the contrary." ~~ Leo Tolstoy
From: James Giles on 3 Apr 2008 17:45 Craig Powers wrote: .... > You could write code like this with the former: > max(x, y) = max(x, y) + 10; > > As a result, whichever of x or y contained the larger value gets 10 > added to it. > > (setting aside whether that would be appropriate -- keeping in mind > even if, at first blush, it appears to be a bad idea, there may be > other contexts where it is extremely useful for writing concise code) Given that conciseness is never by itself a measure of code quality, but both legibility and correctness are, it would still seem to be a bad idea. Certainly any tool which does such a thing should have that characteristic of its behavior encoded into its name in some unmistakable way. Other precautions might also be relevant. -- J. Giles "I conclude that there are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies." -- C. A. R. Hoare
|
Pages: 1 Prev: Bug in Salford's FTN95 compiler version 5.20.1? Next: UPdate all Dependencies(CVF) |