• What's NEW in C++/CLI Language


    作为同时适用于本地/托管环境的新一代C++语言扩充,C++/CLI的定位与原有的Managed Extensions for C++基本一致,在CLR 2.0环境中,它主要承载了如下5个使命:

    A.  源码级集成 (本地/托管/混合代码编译)
    B.  对象模型集成 (本地类型/指针、CLR类型/指针等)
    C.  组件模型集成 (元数据支持、属性-事件语义、P/Invoke/COM Interop/C++ Interop集成等)
    D.  泛型及模板集成 (传统Template、托管Template、Generics、泛型集合类)
    E.  大型框架集成 (STL.net等)

    由于目前除了ECMA标准文本之外,还没有一本关于C++/CLI的入门专著,因此,我根据自己的理解对其所引入的新特性进行了简要的总结和分类,其详细内容均可在MSDN中按图索骥。在理解其目标定位的前提之下,从语言特性的角度来看,C++/CLI对ISO C++的扩充主要包括如下3方面,其中的下划线部分是目前网上谈论得比较多的dd:

    1. Object-Model related
    1.1 Memory Managements
         ·managed handle & tracking reference
         ·reference type / value type / interface
         ·boxing / unboxing / stack sementics
         ·interior_ptr<T> / pin_ptr<T>
    1.2 Resource Managements
         ·IDispose pattern
         ·destructor / finalizer 
         ·static constructor
    1.3 Managed Array
         ·multi-dimensional array
         ·jagged array
    1.4 New modifiers
         ·class-modifiers: abstract / sealed
         ·member function-modifiers: virtual / new / override

    2. Component-Model related
    2.1 Delegate & Event
         ·bound delegate / unbound delegate 
         ·event pattern / composing delegates
         ·accessor of event: add / remove / raise
    2.2 Managed Property
         ·accessors: getter / setter
         ·indexed property
         ·multi-dimensional property
    2.3 Exceptional Processing
         ·managed exception
         ·wraps of SEHException

    3. Templates & Generics related
    3.1 Generics
         ·generic functions / classes / interfaces / delegates
         ·explicit constraints of type parameters based on base-class & interface
         ·classes of generic collections (what, why, how)
    3.2 Managed Template
         ·differences between templates and generics
         ·combining templates and generics
    3.3 'for each ... in' statement

    最后以blog风格废话几句,嗯... 总体感觉C++/CLI语义比MCPP更加清晰、规范,也更简练,但并没有绝大多数人强调的那般夸张,比方说我就不认为__box是多余的,新引入的隐式boxing和栈对象语义反倒还更容易鼓励程序员忘却装箱性能损耗、妨碍优化并制造混乱...也许我从来没有真正觉得MCPP麻烦过... 尽管C++/CLI已经成为了一门现实中的标准语言,尽管它不断地追求着文法的完备和完美,但还是存在着许多令人觉得不自然的地方,也许这应当归结成为:“微软的产品,凡属是不好用的,都是那些连微软自己都没想清楚的”。
    不管怎么说,.Net发展至今,无论是何种语言,语言本身已不再重要(apl.net/ocaml.net/oberon.net/haskell.net,who care?),重要的是语言对CLR及组件环境的支持和理解,或许对我们而言,处于托管/非托管边界上的C++/CLI所揭示的CLR思想和设计理念,比它本身所具备的语法特性更为关键。

  • 相关阅读:
    高级选择器
    CSS的选择器
    HTML——标签
    HTML
    并发编程——协程
    并发编程——线程(二)
    并发编程——线程
    4.栈
    3.链表
    2.顺序表
  • 原文地址:https://www.cnblogs.com/neoragex2002/p/290549.html
Copyright © 2020-2023  润新知