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

String properties not supported #145

Open
aplavin opened this issue Mar 20, 2024 · 3 comments
Open

String properties not supported #145

aplavin opened this issue Mar 20, 2024 · 3 comments

Comments

@aplavin
Copy link
Collaborator

aplavin commented Mar 20, 2024

julia> @optic _."abc"
ERROR: TypeError: in Type, in parameter, expected Type, got a value of type String

This is because PropertyLens is defined to hold the property name as a type parameter, and Strings cannot be type params.
Not sure what we can do, but maybe someone has ideas on how to fix it?

@jw3126
Copy link
Member

jw3126 commented Mar 20, 2024

We could fix it by storing it as a symbol using StringPropertyLens. Do we want and need that?

@aplavin
Copy link
Collaborator Author

aplavin commented Mar 20, 2024

I noticed this missing in terms of actual underlying functionality, not syntax: that is, I haven't needed @o _."abc" syntax yet, but wanted a way to refer to arbitrary properties. Their "names" in Julia can be symbols or int (these are supported by PropertyLens), but also strings (actually occur in the ecosystem) or arbitrary objects (haven't seen these in practice).

@jw3126
Copy link
Member

jw3126 commented Mar 20, 2024

We could also have

struct DynamicPropertyLens{T}
    propertyname::T
end

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

2 participants