-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initialize on access #8
Comments
This would be a really nice feature. Would it make sense for the computation function to take the (partially-initialized) So, e.g., something like this: function compute_double end
@lazy struct LazyDoubler
x::Int
@lazy double_of_x::Int = compute_double
end
LazyDoubler(x::Int) = LazyDoubler(x, uninit)
compute_double(foo::LazyDoubler) = foo.x + foo.x
bar = LazyDoubler(3)
bar.double_of_x # this will be computed on-demand, and the result will be 6 |
I wonder if this is not better: @lazy @kwdef struct Foo
x::Int = 3
@lazy field::Int = compute()
end I also think that indeed adding |
actually the |
I am not sure if this is related, but would it make sense to support |
Could be nice to support adding syntax so that:
would initialize
field
with the functioncompute
.The text was updated successfully, but these errors were encountered: