Skip to content

2*_ + 1 #3

@jariji

Description

@jariji
julia> @underscores (2*_ + 1)(10)
ERROR: MethodError: no method matching +(::Fix1{typeof(*), Int64, Any}, ::Int64)

The current behavior is simple and hence easy to reason about which is a big advantage. The disadvantage is that it doesn't support this slightly more complex case. Do you think this the best option or would it be better to turn this into

using Accessors
julia> @o (2*_+1)
Base.Fix2{typeof(+), Int64}(+, 1)  Base.Fix1{typeof(*), Int64}(*, 2)

like Accessors.jl does?

Likewise

julia> (@underscores a[_.b])((;b=1))
ERROR: ArgumentError: invalid index: _.:b of type Fix2{typeof(getproperty), Symbol, Any}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions