Strange limitations on script files?
3 ビュー (過去 30 日間)
古いコメントを表示
Just wanted to clarify: Are there specific reasons to enforce scripts to
- have function definitions only at the end of the file
- disallow classdef in script files
?
This feels especially unnatural in live scripts, where it disallows naturally adding functions or data structures in the course of the document.
1 件のコメント
dpb
2023 年 9 月 22 日
I have absolutely no inside knowledge, but I would presume the reason is to make the parsing/compilation of code simpler by minimizing complexity.
回答 (1 件)
Walter Roberson
2023 年 9 月 23 日
- Not allowing function definitions in the middle of a script file removes ambiguity about whether code after a function definition is there accidentally (such as if there is an extra end in the code)
- requiring that classdef be the only (non-comment) thing in the file removes ambiguity about what exactly is executed when the class is defined or invoked.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Workspace Variables and MAT-Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!