Is it possible to annotate types so the tab completion works properly?
23 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jehanzeb Mirza
am 9 Jul. 2019
Kommentiert: Rik
am 9 Jul. 2019
I'm working on a project in Matlab which is pretty large and has many objects and functions. Matlab isn't exactly the best language for object oriented programming but its what I have to work with so it is what it is.
When writing functions that work on objects obviously the IDE has absolutely no idea what is the class of the variables being passed in since Matlab is dynamically typed. This means that the tab completion has no way to poll properties and is fairly useless.
In Python which can have similar issues this is remidied by optional type "hints" you can write in code.
# Regular Python code
def square(x):
y = x**2
return y
# Hinted Python code
def hinted_square(x: int) -> int:
y = x**2
y: int
return y
This is used both by static analyzers, and many IDEs because it can now do tab completion as it knows what the types are.
I don't really care too much about static analysis, but it would be really nice if I could get tab completion to work so I'm wondering if there is anything equivalent for MATLAB.
0 Kommentare
Akzeptierte Antwort
Guillaume
am 9 Jul. 2019
Matlab a way to customise tab completion with the functionsignatures.json file.It's not particularly well documented and when I last tried it, it behaved inconsistently with class methods. I don't think I found a way to make it work with properties but I've never had enough time to investigate properly.
2 Kommentare
Rik
am 9 Jul. 2019
I have also had some issues with it. I would agree with it being a bit more complicated than ideal, although I don't have a real solution either.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Call Python from MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!