[Development] Qt 5.9's new garbage collector documentation? + root_ptr
Phil Bouchard
philippeb8 at gmail.com
Sat Jul 8 03:25:19 CEST 2017
On 07/07/2017 12:44 PM, Phil Bouchard wrote:
> Thiago Macieira <thiago.macieira at intel.com> wrote:
>>
>> You're speaking in abstract terms. We actually need code.
>
> Ok I can reuse my Fornux Calculator parser and mimic a function call in
> Javascript.
Actually I can predict what is going to happen if I was to integrate the
actual root_ptr with the ability to unify sets implicitly, removed.
So if for each function there is 1 root_ptr pointing to a list of local
variables then:
- the parameters of the function will remain unaffected if they are used
as r-values
- the parameters of the function will require a deep copy of the
expression if they are used as l-values
- closures of the function will remain unaffected if they are used as
r-values
- closures of the function will require a deep copy of the expression if
they are used as l-values
- return values will be deep copies.
Example 1)
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
},
Example 2)
function previewFiles()
{
var preview = document.querySelector('#preview');
var files = document.querySelector('input[type=file]').files;
function readAndPreview(file)
{
var reader1 = new FileReader();
reader1.addEventListener
(
"load",
function ()
{
var image = new Image();
image.height = 100;
image.title = file.name;
image.src = this.result;
preview.appendChild(image); // closure used as an
l-value will require its parameter 'image' to be a deep copy
},
false
);
reader1.readAsDataURL(file);
}
if (files)
{
[].forEach.call(files, readAndPreview);
}
}
In these examples I am using an image because that is a worse case
scenario but 99% of the time parameters and closures will be simple
integers and strings. This way there can be no cyclic reference left alone.
See? We're getting somewhere. Thank you all for your input BTW; it
helped me came to the aforementioned conclusion.
Regards,
-Phil
More information about the Development
mailing list