Sponsored Link •
|
Summary
This is a very simple statement, but I don't like what C++ does with it.
Advertisement
|
In C++ the following code creates an extra temporary:
class MyClass { ... int m[1000000] } MyClass f() { MyClass ret; ... return ret; } int main() { MyClass x = f(); }In Heron I am seriously considering rewriting code like that to behave like:
class MyClass { ... int m[1000000] } void f(MyClass& ret) { ... } int main() { MyClass x; f(x); }This avoids the creation of a superflous temporary. Could programmers live with the difference?
Have an opinion? Readers have already posted 2 comments about this weblog entry. Why not add yours?
If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.
Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( www.heron-language.com ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at www.cdiggins.com. |
Sponsored Links
|