On 07/07/2017 09:55 PM, Thiago Macieira wrote:
On sexta-feira, 7 de julho de 2017 18:25:19 PDT Phil Bouchard wrote:

JavaScript has no such thing as l or rvalues. Please define use proper terms
for the language in question.

I get your point but those are just shortcuts to the following definitions:

l-value: write variable
r-value: read-only variable

I don't see a problem with variables being modified. But I do see a problem if
a parameter is copied to a global variable. Requiring a deep copy is wasteful
when the current code requires no such thing. So now you have to prove that
htis extra waste is offset by the benefits of using root_ptr elsewhere.

function foo(source)
{
     var image = new Image();
     image.height = 100;
     image.title = file.name;
     image.src = source; // parameter used as an r-value will remain
unaffected
     return image; // return value will require 'image' to be a deep copy
},

So if this Image object opened a 4K image @ 3840x2160 (= just under 32 MB),
you're suggesting that all 32 MB be copied?

For this proposal, yes.

But if I can do a deep copy then I can certainly "re-set" the variable (change the set the variable is owned by). If I can do that then we won't need any deep copy.

I just need to think a little bit... thanks for your patience.

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to