mcdougallab / matlabneuroninterface

Interface for connecting NEURON and MATLAB
BSD 3-Clause "New" or "Revised" License
5 stars 1 forks source link

Dynamic object behavior #24

Open edovanveen opened 1 year ago

edovanveen commented 1 year ago
ramcdougal commented 1 year ago

Is there a good example of when we would want to do this in MATLAB?

vijayiyer05 commented 1 year ago

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.

edovanveen commented 1 year ago

@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.

AljenU commented 1 year ago

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.

vijayiyer05 commented 10 months ago
  • [ ] Can we add functionality for calling dynamic Object methods using syntax like method(obj) instead of obj.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!).