text Metaobject类型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text Metaobject类型相关的知识,希望对你有一定的参考价值。

package metaobjectTest


@doc{*
  Annotation 'type' should be attached to a type. It works 
  much like a language-C typedef but without the explicit 
  declaration. Every type  T@type(id)  is compatible only with literals
  and types annotated with T@type(id) (both should have the same 'id'). 
*}
object Type

    func run {
        var Int@type(inBytes) size = 100;
        var Int@type(inBytes) otherSize = size;
           // the line below, if uncommented, 
           // causes a compiler error
        // var Int@type(inKbytes) sizeKb = size; 
        // ok, inBytes to Int
        var Int n = size; 
          // if uncommented, compiler error:
          // value of raw type, Int, is assigned
          // to inBytes
        // size = n; 
          // if uncommented, compiler error:
          // value of inKbytes is assigned
          // to inBytes
        
        // size = sizeKb;
    
    }

end

以上是关于text Metaobject类型的主要内容,如果未能解决你的问题,请参考以下文章

text Metaobject callUnaryMethods

text Metaobject callTestMethods

text Metaobject callRunMethods

text Metaobject正则表达式

text Metaobject范围

text Metaobject annot