how to make syntax highlight function names with bold ?
显示 更早的评论
In other languages the function names are written with bold characters
I think this makes the code more intelligible
Is this possible to set up in MATLAB ?
回答(1 个)
Jordan Ross
2016-9-21
2 个投票
Hello,
I work for MathWorks and currently there is no supported way highlight function names in the MATLAB environment.
I have forwarded this enhancement request to the appropriate product team.
6 个评论
William Braithwaite
2018-5-30
Has there been any updates to this? It would be very handy to highlight the functions within a script.
John D'Errico
2018-5-30
There are serious problems in this, I imagine. Suppose your script has this line in it:
plot = 5;
So in the current workspace, plot has now become a variable, instead of function.
Now, edit at a second script, one that uses plot. Would plot be a variable, or a function? How should MATLAB know which it is?
timo
2018-5-30
class member functions names have exactly the same issue. How is matlab going to know in
a.b
if b is a member function of object a, a property (which could be dynamic) of object a, a static function of class a, or a field of structure a. I'm sure I'm forgetting more possibilities.
It wouldn't be impossible to do for functions but for scripts I'm not sure it can be done.
Stephen23
2018-5-31
"It wouldn't be impossible to do for functions..." Thanks to the magic of string evaluation I would argue that it is impossible to do in functions as well.
John D'Errico
2018-5-31
编辑:John D'Errico
2018-5-31
The point is that in MATLAB, knowing if something is a function or not is possible to do only in context, at the time of execution. But to try to highlight something in the editor as a function or not is prone to failure in multiple ways. Again, consider this simple code:
% my EVIL script
plot(1:5)
eval(char([112 108 111 116 32 61 32 114 97 110 100 40 49 48 48 44 49 41 59]))
plot(1:5)
At first, plot is a function, and plot(1:5) will produce a plot. But the second time plot(1:5) occurs, it is no longer a function call. While this code is very simple, and what you want to see highlighted may appear obvious, the only way to know what is a function and is not, is to execute the code itself.
By the way, in case you want to know:
char([112 108 111 116 32 61 32 114 97 110 100 40 49 48 48 44 49 41 59])
ans =
'plot = rand(100,1);'
Honestly, I think such an idea would be the code from hell to write and try to produce a useful, accurate, consistent result. If MathWorks chooses to implement it, AND manages to find a way to do so in a robust way, then hey, GREAT!
However, the problems we have pointed out are real. If I were the MathWorks programmer assigned this task, I'd run screaming from the room in terror, as if Cthulhu himself was there. :) If I were the manager who chose to task some poor sot with the job, I'd think about investing TMW programming resources in a better place.
Remember that MathWorks has a finite set of resources. So their management needs to allocate those resources to tasks that have real value, AND will produce a stable result, not a bug filled mess.
Bug filled messes are something that management typically wishes only on their competition.
类别
在 帮助中心 和 File Exchange 中查找有关 Entering Commands 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!