Skip to content

Using @generated less? #21

@tkf

Description

@tkf

We are relying on @generated and it may create some concerns when using this package (e.g., mauro3/Parameters.jl#50).

I think the biggest issue is that setproperties generates a function for different patch type (e.g., different combination or even ordering of the property names).

It would be nice to write setproperties based on constant-propagatable code (e.g., recursions) and avoid using @generated. However, the major obstacle is that fieldnames cannot be inferred. To workaround this, how about just use

@generated __fieldnames__(::Type{T}) where T = fieldnames(T)

? We already use fieldnames inside @generated so this is not worse than the current situation.

Packages that controls struct definition like Parameters.jl can even define __fieldnames__ and constructorof to completely avoid @generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions