摘要
C#作为一种现代编程语言,广泛应用于通用业务系统开发。由于早期的C#语法限制,在数据密集型领域使用MatLab、Python、IDL(Interactive Data Language)等动态脚本语言更为合适。C#7新增了简单灵活的轻量级元组类型。分析了元组的几个典型应用场景,并给出了具体示例,包括多变量初始化、多变量赋值、多变量互换、封装函数返回的多变量、作为中间层的数据容器、用于LINQ select表达式获得语义信息,以及利用析构(deconstructing)实现对象到元组的自动转换等。实践表明,元组适合数据驱动领域开发,提高了生产效率,达到了动态语言效果。对C#7tuple存在的缺陷,如deconstructing的非对称性、赋值的非传递性和可变性(mutable)等提出了改进意见,为利用开源编译器Roslyn优化C#特性提供了设计思路。
As a modern developing language, C# was widely used in general-purpose software development. But due to C # syn- tax limitation in the past, data-intensive application domain were dominated by dynamic script languages such as MatLab, Py- thon, IDL(Interactive Data Language). C# 7 introduces tuple feature which is a simple and flexible data type. Typical applica- tion scenarios were analyzed and example details were presented, including initialization, assignment and swap of multiple varia- bles, packing return values of a method, providing semantic information in LINQ select and transform object to tuple members automatically. The study showed that C# tuple is suitable for data-driven software development in order to improve developer productivity and achieves effects of dynamic languages. At last, the C#7 defects in design, including asymmetry of decon- structing, non-transitivity of assignment and mutable were analyzed, and corresponding updating suggestion were presented, providing ideal for optimize C# 7 features in the future using open source compiler Roslyn.
出处
《软件导刊》
2017年第9期7-9,共3页
Software Guide
基金
国家自然科学基金项目(51578243)
湖南省教育厅科学研究项目(16C0762)