Is it possible to annotate types so the tab completion works properly?

조회 수: 23 (최근 30일)
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.

채택된 답변

Guillaume
Guillaume 2019년 7월 9일
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
Jehanzeb Mirza
Jehanzeb Mirza 2019년 7월 9일
편집: Jehanzeb Mirza 2019년 7월 9일
Seems about what I was looking for, its a bit more convoluted than I'd like though.
Thanks!
Rik
Rik 2019년 7월 9일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by