Skip to content
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

[FR] Auto-generate zero-argument constructors when all fields are @lazy #7

Open
DilumAluthge opened this issue May 25, 2021 · 1 comment

Comments

@DilumAluthge
Copy link
Contributor

I have multiple structs that look like this:

@lazy struct MyStruct
    @lazy field_1::T_1
    @lazy field_2::T_2
    @lazy field_3::T_3
    ...
    @lazy field_N::T_N
end

That is, each struct has a lot of fields, and every field in the struct is @lazy.

For each struct, I want to have a zero-argument constructor that passes uninit to each field. I.e.

function MyStruct()
    return MyStruct(
        uninit,
        uninit,
        uninit,
        ...
        uninit,
    )
end

It's kind of tedious to write out all of these constructors by hand. Would it be possible for LazilyInitializedFields to auto-generate these zero-argument constructors for me?

@DilumAluthge DilumAluthge changed the title Auto-generate zero-argument constructors when all fields are @lazy [FR] Auto-generate zero-argument constructors when all fields are @lazy May 25, 2021
@DilumAluthge
Copy link
Contributor Author

Or, alternatively, is there a way that I could combine LazilyInitializedFields.@lazy with Base.@kwdef so that I can automatically get a kwarg constructor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant