Open
Description
It occurred to me this morning that with the new setproperty!/getproperty
methods, it might be possible to do something like:
o = SettableRef(some_immutable_object)
o.f.x = 10
o.f.y = 23
some_immutable_object = get(o) # unwrap the object
as syntax equivalent to
@set some_immutable_object.f.x = 10
@set some_immutable_object.f.y = 23
Internally, o.obj
would contain the immutable, and o.f
(getproperty(o, :f)
) would return a proxy object p
so that p.x = 10
(setproperty(p, :x, 10)
) would be equivalent to o.obj = @set o.f.x = 10
.
It's not a great win over @set
, which is already pretty concise. But I think for us it would be interesting, as it turns an immutable object into (what looks like) a regular mutable object, without any scary macro involved. Was that discussed anywhere?
Metadata
Metadata
Assignees
Labels
No labels