Comments on: Class object tab completion & improper field names https://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names Charting Matlab's unsupported hidden underbelly Wed, 20 May 2020 03:01:17 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Jim Hokansonhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-372393 Sun, 20 Mar 2016 18:20:21 +0000 https://undocumentedmatlab.com/?p=4918#comment-372393 Hi Yair,

I came across a use case where sadly I needed to use this approach to support arbitrary variable names. Any idea on how to support tab completion within the parentheses? e.g.:
c.(‘ %tab complete after the quote

Thanks,
Jim

]]>
By: Nick Gaulhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-345400 Mon, 09 Feb 2015 16:54:44 +0000 https://undocumentedmatlab.com/?p=4918#comment-345400 I am creating some custom classes for a project. I am overloading the subsasgn and subsref methods and that is working wonderfully. I tried overloading the properties method so I could provide a list of specific properties and I would say it is 50/50 working and not working. This is what I mean by 50/50 working:

obj = myclass(x);
obj. % this shows the property names that my overloaded properties method returns
i = [1,3];
obj(i). % this shows a popup message saying no completions found. Do you know if that is considered correct/normal Matlab behavior?

I also tried overloading the fieldnames method as well but I still get the no completions found message. Any ideas of how I can get this to work?

Being I am already overloading the subsasgn and subsref methods I do realize I could change them such so that instead of doing obj(i).property_name I could use obj.property_name(i) and then I think the tab completion would work. However, my custom class (obj) actually contains an array of a different custom class. So it seems more natural to specify the objects I want first, obj(i) and then the property to get/set, obj(i).property_name.

]]>
By: Lorinhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-337340 Wed, 12 Nov 2014 20:31:30 +0000 https://undocumentedmatlab.com/?p=4918#comment-337340 I am currently using R2014a and are using Michal’s solution to attempt to hide handle superclass methods (addlistener.m, etc) when using tab-completion. I’m not getting the desired result using R2014a.

In 2013a and 2013b, I am able to hide handles’ methods by inheriting from a class that overloading the functions (addlistener.m, etc) and gives them access of ‘Hidden’. As seen in the stackoverflow questions below:
http://stackoverflow.com/questions/6621850/is-it-possible-to-hide-the-methods-inherited-from-the-handle-class-in-matlab

My question is: Is anyone aware of changes made to R2014a+ that would not allow overloading of ‘methods’ and thus not resolve the hiding of handles’ methods when using the tab-completion tool tip?

]]>
By: Setting class property types | Undocumented Matlabhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-329536 Tue, 12 Aug 2014 17:21:37 +0000 https://undocumentedmatlab.com/?p=4918#comment-329536 […] additional aspects of class property tab-completion […]

]]>
By: Danielhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328306 Tue, 22 Jul 2014 10:31:30 +0000 https://undocumentedmatlab.com/?p=4918#comment-328306 I find it completely unprofessional that the official “bug list” doesn’t list all known bugs.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328291 Tue, 22 Jul 2014 04:25:10 +0000 https://undocumentedmatlab.com/?p=4918#comment-328291 Thanks for letting me know about this. I can see how this might indeed be seen in that light and so I have removed the relevant phrases.

]]>
By: TheBlackCathttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328259 Mon, 21 Jul 2014 12:42:05 +0000 https://undocumentedmatlab.com/?p=4918#comment-328259 I would like to apologize. I am sure you are trying your best to give the best advice possible to us and your clients. I do think those paragraphs are easy to misunderstand and I would probably have phrased them differently. That was really my ultimate point, but considering what a terrible job I did expressing myself I am probably the last person who should be giving that sort of advice. So please accept my apology and believe me when I say I do not doubt your integrity.

]]>
By: TheBlackCathttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328254 Mon, 21 Jul 2014 11:04:39 +0000 https://undocumentedmatlab.com/?p=4918#comment-328254 Fair enough. However, from those two paragraphs, you seem to put a lot of focus on what would benefit you. I hope you can see how that sort of thing could give the wrong impression.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328195 Sun, 20 Jul 2014 16:49:09 +0000 https://undocumentedmatlab.com/?p=4918#comment-328195 Ouch, that hurt. It’s a pity that after so many years, you underestimate me so much. My client could not modify the legacy system. The options were either to keep that system and the discrepancies vs. Matlab (which made R&D difficult across the two groups), or to find a way to migrate to Matlab, or to redo everything from scratch (at a huge R&D cost). My client decided to migrate to Matlab before they contacted me, but hit the problem I described above. They came to me asking for a solution after MathWorks support and other consultants were not able to help them solve the problem. I was able to give them a pointer in this direction which nobody else was able to do before then. Having said that, I did warn them that it might not be cost-effective. But now at least my client has an alternative that they can consider vs. their current ongoing development difficulties – an alternative that they did not have beforehand.

]]>
By: Amrohttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328194 Sun, 20 Jul 2014 16:44:03 +0000 https://undocumentedmatlab.com/?p=4918#comment-328194 All of these restrictions are on the MATLAB side, the underlying MEX API actually does not impose such limitations.

I implemented a MEX-function “my_setfield.cpp” to illustrate: http://pastebin.com/j69kQEur
To keep it simple, I only handle scalar structures, but you can extend the code to work with struct arrays..

Here is an example showing the use of illegal field names:

% create struct
s = struct();
s = my_setfield(s, 'a a', 1);
s = my_setfield(s, 'b.b', 2);
s = my_setfield(s, 'c-c', 3);
s = my_setfield(s, '1dd', 4);
s = my_setfield(s, repmat('e',1,70), 5);
s = my_setfield(s, ' asd f @#$^$%&', 6);
 
% retrieve fields using "dynamic field names" syntax
disp(s)
a = s.('a a')
b = s.('b.b')
c = s.('c-c')
d = s.('1dd')
%e = s.(repmat('e',1,70))   % this one didn't work :)
f = s.(' asd f @#$^$%&')

(Note: you can workaround the “namelengthmax” restriction by similarly implementing a C++ MEX-function that uses mxGetField/mxGetFieldByNumber).

]]>
By: TheBlackCathttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328193 Sun, 20 Jul 2014 16:15:23 +0000 https://undocumentedmatlab.com/?p=4918#comment-328193 Shouldn’t you be advising them to use the solution that best suits their needs? Sometimes that isn’t Matlab. If I was hiring a consultant that is what I would want them to do.

]]>
By: Davidhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328105 Fri, 18 Jul 2014 19:42:20 +0000 https://undocumentedmatlab.com/?p=4918#comment-328105 I’m sorry but this is just terrible. Why on earth did you develop such a hack? Your time would have been far better spent sorting out their mess like Seb suggested. Now they don’t have any reason to tidy up!

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328069 Fri, 18 Jul 2014 08:08:32 +0000 https://undocumentedmatlab.com/?p=4918#comment-328069 @Seb – I believe it was names of data channels that contained spaces, dots (.) and dashes (-). These could be valid channel names yet still illegal Matlab identifiers. In the real world, such channel names are quite common. I added the special symbols in my example just to illustrate the point.

]]>
By: sebhttps://undocumentedmatlab.com/blog_old/class-object-tab-completion-and-improper-field-names#comment-328066 Fri, 18 Jul 2014 07:48:55 +0000 https://undocumentedmatlab.com/?p=4918#comment-328066 Out of curiosity – if that doesn’t contradict any NDA:
What technology allows “fieldnames” or property names to contain special characters and even whitespaces?

I’d go for a consulting project helping them to get rid of that mess :>

]]>