转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> Delphi程序 >> 正文
Delphi for .Net 编译器预览 - by John Kaster         ★★★★

Delphi for .Net 编译器预览 - by John Kaster

作者:闵涛 文章来源:闵涛的学习笔记 点击数:3210 更新时间:2009/4/23 18:39:15
erlying value type. For the following code,


TObject(12).ToString

the code TObject(12) boxes an integer into an object.

Boxing of value types in Delphi for .NET is a requirement. Boxing support is not planned for Win32 or Linux Delphi language implementations.

Records with inheritance

Delphi records will be implemented as value types in CLR. Record inheritance is an aspect of value types. Records with non-virtual methods is another aspect of value type support.

Records with methods

The declaration of methods on TRecord is supported. These behave as static non-virtual methods.

Sealed classes

A sealed class cannot be inherited from. Value types can only inherit from abstract value type classes, and only sealed value type classes can be instantiated. Value types are highly deterministic, and decidedly non-polymorphic.

Final methods

The final directive on a virtual method (or override) indicates that this method cannot be overridden in descendent classes. Descendents may still introduce new virtual methods with the same name as the inherited method, but since they do not override the inherited method (occupy the same vmt slot as the inherited method), they do not participate in polymorphic calls to the inherited method.

Possible Enhancements

Multicast events

With multicast events, you can have multiple listeners for each event. This event model is different from the Win32 event model, where an event is consumed and discarded by the first component responding to it. With event listeners, multiple components can respond to the same message (for example, all controls could respond to a "repaint" event).

In this event listener model, you can only remove your own listener. Include() and Exclude() are standard procedures overloaded to operate on events for adding or removing an event listener. Traditional singleton event semantics are supported through := assignments. If a singleton event is used with an assignment, it overrides Include() or other listeners.

Support for multicast events in Delphi for .NET is a requirement. Support for multicast events may appear in future releases of Delphi for Win32 and Linux.

Interface method resolution

Interface method resolution provides a convenient shorthand for implementing methods referenced in an interface. By default, the compiler attempts to bind a method name to a method of the same name in the class implementing the interface. With the following code,


Type
  TMyClass = class(TBaseClass, IFoo)
    procedure FooBar(paramlist);
    procedure IFoo.Bar = FooBar;
  end;

The new version would be:


Type
  TMyClass = class(TBaseClass, IFoo)
    procedure IFoo.Bar(paramlist);
  end;

A reference to TMyClass.IFoo.Bar is then valid.

When multiple interfaces are used, interface method resolution becomes even more valuable. The following code illustrates:


IFoo1 = interface
  procedure Bar;
end;

IFoo2 = interface
  procedure Bar;
end;

TSomeClass = class(TBaseClass, IFoo1, IFoo2)
  procedure IFoo1.Bar;
  procedure IFoo2.Bar;
end;

Array property overloads

Array property overloads will also be supported. The following example shows the probable syntax for overloading array property references.


TSomeClass = class
  property Item[Index: string]: string 
    read GetItem write SetItem; overload;

  property Item[Index: integer]: string
    read GetItem write SetItem; overload;

  property Names: string read GetNames write SetNames;
    overload;

  property Names[Index: Integer]: string
    read GetNames write SetNames; overload;

  function GetItem(Index: string): string; overload;
  procedure SetItem(Index:string; Value: string); overload;

  function GetItem(Index: Integer): string; 
    overload;
  procedure SetItem(Index: Integer; Value: string);
    overload;

  function GetNames: string; overload;
  procedure SetNames(Value: string); overload;

  function GetNames(Index: Integer): string; 
    overload;
  procedure SetNames(Index: Integer; Value: string);
    overload;

end;

Overload of array properties is required for CLS compliance. For example, the CLR NameValueCollection overloads integer and string index references for the default Item property, as does this code snippet example above.

Conclusion

This document is intended to introduce some of the new features and concepts under research for the Delphi for .NET compiler. While every attempt has been made to keep this information accurate, all of it is subject to change. Compiler support for .NET has provided some exciting opportunities for enhancement to the Delphi language. The language enhancements discussed here are for the Delphi for .NET compiler unless otherwise stated. Hopefully, you like what you see so far.

Stay tuned to this web site, as more articles on Delphi for .NET are coming very soon.


Add or View comments on this article

Article ID: 28972   Publish Date: August 06, 2002  Last Modified: August 05, 2002

Help  Feedback  Home Pages  Newsgroups  Search 

Made in Borland® Copyright© 1994-2002 Borland Software Corporation. All rights reserved. Legal Notices, Privacy Policy

上一页  [1] [2] [3] [4] 


[C语言系列][C#防止反编译].NET 产品版权保护方案 (.NET源码加…  [互联动态].NETFramework3.0新特性介绍与问答翻译
[Web开发]asp.net代码空格显示为……点号的原因及解决办法  [Web开发]asp.net调用压缩软件对文件进行压缩与解压缩的代码
[Web开发]详细介绍asp.net获取日期时间的各种格式的函数  [Web开发]如何将JS文件编译到ASP.NET项目里的DLL文件中
[Web开发]asp.net加密口令的最简单方法  [Web开发]目前asp.net开发主流工具软件介绍
[Web开发]asp.net中的反射介绍  [Web开发]制作留言板不使用数据库之asp.net操作XML文件的代…
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台