Skip to content

RFE: syntactic sugar f(x) .= 3+4x for vectorized function definition #30520

Closed

Description

New to Julia, so please have patience if I am missing something in this suggestion.

Since the .= operator is used for in-place assignment, it does not currently make sense to define a function using this operator. That is to say, the statement f(x) .= 3+4x would not have any meaning. The statement and variations such as f .= x -> 3+4x indeed trigger strange errors.

I think it would be elegant to hijack the .= operator when the LHS is a function definition or RHS is a lambda; my hijack proposal is to make f(x) .= 3+4x and/or f .= x -> 3+4x into f(x) = @. 3+4x or something similar. This is less in-line with the behavior of .= as an "in-place assignment" operator, and more in-line with the dot as a broadcast operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionspeculativeWhether the change will be implemented is speculative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions