Recognizing properties, methods and function names in Matlab code.
Mostrar comentarios más antiguos
I'm writing a global naming convention change utility for Matlab code. To this end, I would like to know the answers to the following:
In correctly written Matlab and excluding dynamic access:
1. Given a property name outside of its declaration in class, will it always be preceded by a dot?
2. Given a method name outside of its declaration in class, will it always be preceded by a dot?
3. Given a method name outside of its declaration in class, will it always be followed by zero or more whitespaces and an open parenthesis OR followed by an @ symbol?
4. Given a standalone function name will it always, in correctly (non-deprecated) written code, be followed by zero or more whitespaces and an open parenthesis OR be preceded by an @ symbol?
Thank you for any help.
Respuestas (1)
Bruno Luong
el 16 de Abr. de 2022
0 votos
None of that is true. Some counter examples:
- set(obj, 'property', value)
- mymeth(obj, ...)
- obj.mymeth % no argument
- feval('myfun', arg1)
8 comentarios
SK
el 16 de Abr. de 2022
Bruno Luong
el 16 de Abr. de 2022
Editada: Bruno Luong
el 16 de Abr. de 2022
"3 is bad form in my opinion"
it's your opinion. who use
alpha = pi();
insteade of
alpha = pi;
If you want your utility to work and robust, you cannot assume it only works on what you consider as good practice.
Bruno Luong
el 16 de Abr. de 2022
Editada: Bruno Luong
el 16 de Abr. de 2022
Also would you have to know foo is property or method for this case?
bar = obj.foo(1);
Then all the structure fields use also dot syntax that can create confusion.
SK
el 16 de Abr. de 2022
Bruno Luong
el 16 de Abr. de 2022
Well as you migh guess this is accessing to the first element of a property.
SK
el 16 de Abr. de 2022
SK
el 16 de Abr. de 2022
Categorías
Más información sobre Number Theory en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!