Closed phipsgabler closed 2 years ago
Nice! That looks handy. What happens if you try obj.$(f(x) ? An example with a nested attribute access could also be added.
You mean like that?
julia> @lens(_.a[1].$(rand([:x, :y])))
(@lens _.a[1].x)
julia> @lens(_.a[1].$(rand([:x, :y])))
(@lens _.a[1].x)
julia> @lens(_.a[1].$(rand([:x, :y])))
(@lens _.a[1].y)
julia> @macroexpand @lens(_.a[1].$(rand([:x, :y])))
:((identity)((Setfield.compose)((Setfield.PropertyLens){:a}(), (Setfield.IndexLens)((1,)), (Setfield.PropertyLens){rand([:x, :y])}())))
I think I will merge this one. If we decide to tweak the parser for https://github.com/TuringLang/AbstractPPL.jl/pull/54 that can be a separate PR. Sounds good @phipsgabler ?
Ah sry @phipsgabler, can you bump the patch version?
This comes up in some VarName use cases in DynamicPPL (cf. https://github.com/TuringLang/AbstractPPL.jl/issues/46).
I simply add a case to check property access with
is_interpolation
.Any ideas/requirements for more test cases?