ftp class 的 Metaclass 问题

Metaclass issue with the ftp class

我想获得一些 Matlab 内置 classes 的 metaclass,但我对 @ftp class 有疑问: class 被 which 看到,但 metaclass 系统看不到:

>> which('ftp')
/usr/local/MATLAB/R2016a/toolbox/matlab/iofun/@ftp/ftp.m  % ftp constructor

但是

>> ?ftp

ans = 

  0x0 class array with properties:

    Name
    Description
    ...

我得到与 meta.class.fromName 相同的空结果。

让我准确地说,which 和 metaclass 系统都可以找到其他 classes,例如 @serial class:

>> which('serial')
/usr/local/MATLAB/R2016a/toolbox/matlab/iofun/@serial/serial.m  % serial constructor

>> ?serial

ans = 

  class with properties:

                     Name: 'serial'
              Description: ''
                         ...

为什么会这样?是错误还是功能?

如果这有某种重要性,我是 运行 Matlab R2016a Ubuntu 16.04。

这是因为 ftp 实际上是一个老式的 class(使用 @classname 文件夹系统结合非 classdef 构造函数)。在这种样式中,您具有以下文件结构:

@ftp
    ftp.m       <--- Constructor (regular m-file, non-classdef)
    ascii.m     <--- Methods
    binary.m            |
    ...                 V
    delete.m

与 classes (classdef) 的新样式相比,这些旧的 classes 有一些限制,包括它们不能使用元classes.

Keep in mind that if you write classes in the old style, the following features, available in the new framework, are not supported: protected, abstract, static/constant, sealed, or hidden methods or properties; single file class definitions; events; handle classes; packages; special set and get methods; object.method() syntax; or meta-classes.

classes (classdef) can still use the @classname class folders 的新样式,但构造函数文件现在是 classdef 文件。对于这些类型的 classes(例如 serial),支持元classes