Struct update syntax

Rust has a struct update syntax that allows you to create a new struct object from another one by changing only some fields. That looks very convenient and would make me want to use more immutable types.

Has there been any discussion about adding such syntax to Julia? Something along the line of:

struct Point
    x::Int
    y::Int
    z::Int
end

p = Point(1, 2, 3)
q = Point(x = 10, p...)      # crazy syntax, just a thought
7 Likes

Setfield sort of does that:

using Setfield
q = @set p.x = 1.0
9 Likes

There is already some similar precedence from named tuples for something like that, right?

p = (x=1,y=2,z=3)
q = (p..., x=10)
7 Likes