MATLAB的一个函数=一个文件的最初原因是什么,为什么仍然如此? [英] What was the original reason for MATLAB's one function = one file and why is it still so?

查看:105
本文介绍了MATLAB的一个函数=一个文件的最初原因是什么,为什么仍然如此?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MATLAB的一个(主)函数=一个文件的最初原因是什么,为什么经过这么多年的开发却仍然如此?

What was the original reason for MATLAB's one (primary) function = one file, and why is it still so, after so many years of development?

与这种方法的劣势(人们在功能和脚本中放入太多东西,显然应该将它们分开,导致代码清晰性下降)相比,这种方法有什么优势?

What are the advantages of this approach, compared to its disadvantages (people put too many things in functions and scripts, when they should obviously be separated ... resulting in loss of code clarity)?

推荐答案

Matlab在每个文件中加载一个类/函数的模式在此问题上似乎与Java的选择相符.我敢打赌,在1980年代推出解析器时,还有其他技术原因可以加快解析器的速度. Java选择此模式是为了阻止包含所有内容的超大文件,这是我使用单文件类共生语言看到的任何语言的主要参数.

Matlab's schema of loading one class/function per file seems to match Java's choice in this matter. I am betting that there were other technical reasons for speeding up the parser in when it was introduced the 1980's. This schema was chosen by Java to discourage extremely large files with everything stuffed inside, which has been the primary argument for any language I've seen using one-file class symantics.

但是,强制每个文件语义一个类并不能阻止大型文件- KPIB 是一个复杂的,冗长的函数/类文件(尽管非常有用的maga文件)的完美示例.因此,一类文件系统是一种试图使用户更多地了解代码抽象的方法,而不是一种功能上有用的机制.

However, forcing one class per file semantics doesn't stop mega files -- KPIB is a perfect example of a complicated, horrifically long function/class file (though a quite useful maga file). So the one class file system is a way of trying to make the user aware about code abstraction more than a functionally useful mechanism.

Matlab的一个函数/类文件系统的一个积极结果是,只要一目了然就可以很容易地知道哪些函数可用.另外,许多名称必须具有足够的描述性,以使其与其他文件区分开,因此,命名为次要形式的文档会产生副作用.

A positive result of the one function/class file system of Matlab is that it's very easy to know what functions are available at a quick glance of a project directory. Additionally many of the names had to be made descriptive enough to differentiate them from other files, so naming as a minor form of documentation is present as a side effect.

最后,我认为对于一个文件类来说并没有强大的论据,因为从onw到另一个文件类通常只是一个很小的语义更改(除非您的代码处于极其无组织的状态...在在这种情况下,您应该羞于修复它.)

In the end I don't think there are strong arguments for or against one file classes as it's usually just a minor semantically change to go from onw to the other (unless your code is in a horribly unorganized state... in which case you should be shamed into fixing it).

编辑!

我修复了对Matlab采用Java的一类文件系统的错误引用-经过更多研究,似乎两个开发人员都独立采用了这种风格(或者未指定其他语言会影响他们的决定).尤其如此,因为Matlab直到2000年才捆绑Java.

I fixed the bad reference to Matlab adopting Java's one class file system -- after more research it appears that both developers adopted this style independently (or rather didn't specify that the other language influenced their decision). This is especially true since Matlab didn't bundle Java until 2000.

这篇关于MATLAB的一个函数=一个文件的最初原因是什么,为什么仍然如此?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆