Open edovanveen opened 1 year ago
Is there a good example of when we would want to do this in MATLAB?
I'm curious to understand this one better, both from the language & use case points of view.
I knew this interface was making use of dynamic properties, but I'm not (yet!) aware of a dynamic method facility.
Generally class methods in MATLAB support both method(obj)
and obj.method()` semantics.
@vijayiyer05 We use subsref overloading for this, see https://nl.mathworks.com/help/matlab/matlab_oop/code-patterns-for-subsref-and-subsasgn-methods.html, and then case '.'
in the code framework example.
What we do not do correct yet in our subsref implementations, is first checking the type, before looking at the subs part. The example implementation from the link should be followed more. Then chaining is also possible, though might depend on what the first thing in the chain is. this also related to the behaviour of objects in arrays.
- [ ] Can we add functionality for calling dynamic Object methods using syntax like
method(obj)
instead ofobj.method()
? This one should just work! Please advise if not.
Maybe it's something to introduce in one of the tutorials: that either works and is acceptable (even if some people have strong opinions!).
method(obj)
instead ofobj.method()
?n.allsec()
) and Segments (sec.allseg()
), arrays (instead of cell arrays) would be preferable.n.SomeObject().somemethod()
? An example fix for Sections/Segments, e.g.soma(0.5).ref("v")
is available inexample_netcon.m
on the branch of issue #48.subsref
andsubsasgn
methods? See this example.