From: Mirek Fidler on 27 Nov 2006 12:23 > Inlining a function doesn't necessarily imply replacing a reference type > with a value type. > > The problem is, a compiler looks at a UDT from the lowest level > possible. It has *no idea* what that type is supposed to be; not a clue. > All it sees are the low level operations on it. Trying to infer > identities and high level operations from that is akin to handing an AI > engine a few identities and expecting it to construct all kinds of > useful theorems from them. It ain't gonna happen. I am afraid my response might be considered a little bit offending, but I have to ask: Are we speaking about DMC++ here? :) In reality, I see no reason why good compiler could not optimize out a reference. I have just checked with GCC4.1 / AMD64 (to reduce register pressure): struct Foo { int a, b; }; inline void Add(Foo& x, int q) { x.a += q; x.b += q; } void Print(int); // just to force code generation void main() { Foo x; x.a = 10; x.b = 20; Add(x, rand()); Print(x.a); Print(x.b); } and it produced this: callq 0x4055b0 <rand(a)plt> mov %eax,%ebx lea 0xa(%rbx),%edi callq 0x406038 <_Z5Printi> lea 0x14(%rbx),%edi callq 0x406038 <_Z5Printi> Or maybe I misunderstood the problem? Mirek -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Nemanja Trifunovic on 27 Nov 2006 12:57 Walter Bright wrote: > Having them 'mostly' work isn't good enough. Searching doesn't work, for > example. In my experience, the libraries for string manipulation work just fine with utf-8 within std::string as long as the user knows what he is doing. For instance, a search for the letter U+045A (Cyrillic small Nje) would mean searching for substring "\xd1\x9a". -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: werasm on 27 Nov 2006 13:01 Francis Glassborow wrote: > Well why is English the > commonest second language in the World. It is a terrible language full > of special cases. I personally don't think it is the most common because its the best medium for communication (It may be the commonest, yes ;-). Jokes aside. I'm no historian, but... My great grand parents were forced to learn English. The same went for generations prior to them. Some of them were even prohibit to speak their own language in public. Ever hear of the event of the previous millennium - colonisation/colonization (as an answer to your why). Why is French a popular language in some parts of Canada? Why is Spanish the third most commonly spoken language? Is is perhaps because the French settled their? Does the Spanish settlement in South America have an influence? Furthermore, the USA itself is a economic giant. It's official language is English (not that I know, I'm not from their, but its a fair guess). This fact further pushed English as language. How many Eastern countries nowadays pay English teachers good money. They need to know English to survive, as that is the medium wherein economic giants deal. They did not decide to learn English because its a good language, but because it feeds them. On this topic of the USA. Who is the greatest presenter of Media in the modern world, and in which language is that media presented, and why did they choose that language? Who colonised the USA? Yes, the Germans and French had a part to play... The English just about settled and dominated everywhere at some point in history. Small wonder English has become so widely spoken. English became a common denominator due to colonization. Globalization require/d a language, and English was there for the taking. I must mention that I don't mind English at all, but I don't think it superior or more practical (not that I'm a linguist). All languages have its strengths and weaknesses. The fact that people tend to prefer one language (usually the one taught to them by their parents), make the comparison very subjective. > In a similar vein C++ is a good general purpose language despite (or > perhaps because of) its idiosyncrasies. Of course you have to understand > what you are doing and C++ will provide much less nannying because being > multi-paradigm requires that it trust the programmer. I don't know whether the reasons for C++ being popular or not are at all comparable with English. I suppose from an historic point of view, "C" made its appearance at the right time for it to become widespread (just prior to IT revolution). The C++ author's choice to be compatible with C made people take notice. Even the name implied an upgrade of C. Better than C. After C, but compatible (Which makes me think of the choice of D - after C++, better than, but not compatible - with all respect). C was the language of that time, C++ was the upgrade, supporting the new paradigm (OO). People (especially when competition is still sparse) don't like making a paradigm shift and changing their language of use :-). Does D, BTW. support other paradigms (I'm not counting concurrent programming as a paradigm, since I've been using C++ to do that for some time now)? From the little I've seen it does seem to support TMP better, but I'm not the one to debate that - others are more qualified. In some way I do think, wrt. the TMP paradigm, D stands towards C++ as C++ stood towards C in the OOP paradigm. One can program in OOP fashion using C, but it is not natural. One can do TMP with C++ but with D, is it more natural? I have not found C++ templates that unnatural for the cause, though. > We have a choice between putting effort into improving what we already > have or starting over when we want to design a cross-platform language. > Note that neither C# nor Java fall into that group because both aim at a > (virtual) platform and transfer issues of portability to a virtual > machine. The problem is that not all hardware can comfortably support > the required VM efficiently (for example any hardware whose native types > mis-match Java's has to sacrifice low-level efficiency. Java for me had synergy with the RDBMS idea. Originally everybody cried out, we don't have enough processing power, now its happening. Processing power to have the tendency to become more some way or another). Pitty they took out all the good aspects of C++. If they hadn't, it would have taken off (IMO). C# has the name Microsoft associated with it. > What makes a good new language? I doubt if anyone can say. What history > suggests to me is that any new language that becomes popular because it > addresses some perceived problems with a widely used existing language > acquires an exponentially rising number of users (and advocates and > devotees). I'm assuming English is not part of this argument. In the case of English it was simply dominance. As far as programming languages are concerned, maybe yes. > After it has been in use for five-ten years the problems > hidden in the design begin to surface and become increasingly more > irritating (the strengths of the language are then forgotten because > they are just assumed) I've not really become irritated with C++'s weaknesses yet, and the lack of its strengths in Java made me not taking enough interest to spend more than a month on it (Java). Java (and C#) to me is like English, I would learn it to bring bread to the table. C++, OTOH - for fun. > Languages need to be durable, or at the very least able to easily assume > responsibility for source code written in a predecessor. If not that > they usually need a familiar syntax and semantics so that adoptees do > not have to steep a learning curve. Yes, agreed. > Finally we should be careful about comparing like with like. The > interesting features of languages like Ruby and Python is that the come > from a very different ancestry (that of scripting languages) I don't disagree. Eventually the advantages/disadvantages of ancestry may be compared, and certain descendents may disappear altogether. Kind regards, Werner -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Gabriel Dos Reis on 27 Nov 2006 17:47 Walter Bright <walter(a)digitalmars-nospamm.com> writes: [...] | The problem is, a compiler looks at a UDT from the lowest level | possible. Facts: making a type built-in does not imply that values of that type will be passed in registers. Conversely making a type UDT does not necessarily imply that values of that type will not be passed in registers. -- Gabriel Dos Reis gdr(a)integrable-solutions.net [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Walter Bright on 27 Nov 2006 17:49
Nemanja Trifunovic wrote: > Walter Bright wrote: > >> Having them 'mostly' work isn't good enough. Searching doesn't work, for >> example. > > In my experience, the libraries for string manipulation work just fine > with utf-8 within std::string as long as the user knows what he is > doing. For instance, a search for the letter U+045A (Cyrillic small > Nje) would mean searching for substring "\xd1\x9a". Third party users of std::string would assume (and correctly so, according to the standard) that there is a one-to-one correspondence between characters and string elements. There isn't with UTF-8. Functions like strchr, which take a *character* (not a string) to search for, will fail. The design of strchr is simply wrong for UTF-8. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |