It's often the case that we want to defer the computation of an object until we actually need that object. We should add a small wrapper object that allows us to do this in webkitcorepy.
Created attachment 435612 [details]
Comment on attachment 435612 [details]
View in context: https://bugs.webkit.org/attachment.cgi?id=435612&action=review
> +class Defer(object):
It might cause confusion with "Deferred" in twisted module, which is more about async operation.
For this one, we want to defer the evaluation of 'callback', this is more like lazily evaluated.
This also limits the callback to be a callable that takes no argument, would that work for what it's designed for?
Maybe we also want to have a test case that the evaluation is actually deferred.
value = 
d = Defer(lambda: value.append('foo'))
Created attachment 435768 [details]
Committed r281191 (240635@main): <https://commits.webkit.org/240635@main>