ftp类的元类问题

时间:2016-06-20 06:51:04

标签: matlab metaclass

我想获得一些Matlab内置类的metaclass,我对@ftp类有疑问:which看到了类,但是>> which('ftp') /usr/local/MATLAB/R2016a/toolbox/matlab/iofun/@ftp/ftp.m % ftp constructor 看不到元类系统:

>> ?ftp

ans = 

  0x0 class array with properties:

    Name
    Description
    ...

@serial

我使用meta.class.fromName得到了相同的空结果。

让我确切地说,which和元类系统都可以找到其他类,例如>> which('serial') /usr/local/MATLAB/R2016a/toolbox/matlab/iofun/@serial/serial.m % serial constructor 类:

>> ?serial

ans = 

  class with properties:

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

if (d3.event instanceof Event) {
}

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

如果这有一定的重要性,我在Ubuntu 16.04上运行Matlab R2016a。

1 个答案:

答案 0 :(得分:1)

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

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

与新式的类(classdef)相比,这些旧类有一些局限性,包括它们不适用于元类。

  

请记住,如果以旧样式编写类,则不支持新框架中提供的以下功能:protected,abstract,static / constant,sealed或hidden方法或属性;单个文件类定义;事件;处理班级;包;特殊设置和获取方法; object.method()语法;或元类

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

相关问题