How to implement a description for variables in the code?

조회 수: 8 (최근 30일)
Mhamad Hantro
Mhamad Hantro 2022년 9월 9일
댓글: Mhamad Hantro 2022년 9월 9일
Is there a possibility to add or write a sort of a description for the variables used in the code without using comments or writing their meaning in an adjacent txt file for instance?
I'm imagine it in my head as if it's possible to implement a description in matlab so that, for example, if I hover over a variable in the code a short description written by me appears.
Thanks !

채택된 답변

John D'Errico
John D'Errico 2022년 9월 9일
편집: John D'Errico 2022년 9월 9일
So you want a tooltip to appear, hovering over each variable or line of code, but have no explicitly written comments in the code? Sorry, but this is not something implemented in MATLAB.
Is it possible to do in some other language? Of course. Start writing, since you may nee to implement the entire programming language yourself. Or pick some language that I don't know of, which may already have this caapability. But MATLAB is not an option, at least not at this date, or even in the near future.
Of course, you could submit this as a feature request, but I doubt it will happen anytime soon, as this would be a massive change in how the code and editor works.
  댓글 수: 2
Rik
Rik 2022년 9월 9일
To add to this answer:
The reason behind it is that Matlab variables are very run-time dependent. You can use the same variable name for many different things in the same function.
The way Matlab is currently set up is that you need to use comments to explain what your code is doing.
Once thing that is often forgotten: you have 63 characters for your variable names, so need to use single-letter variable names. If you want to explain what something is/does, what better than using the variable name? You don't even need to move over your cursor to read it.
Mhamad Hantro
Mhamad Hantro 2022년 9월 9일
Thank you for your answers, of course I do name variables properly, but sometimes it's still better to have some sort of a description, describing the variable for what it does and how it acts. I don't know any other language that does this, it just occured to me and so I thought to ask because why not. But I guess the massive change in how the editor works is an enough why not.
Thanks !

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by