是否可能像LINQ一样创建C#语言修改? [英] Is it possible to create C# language modifications as did LINQ?

查看:127
本文介绍了是否可能像LINQ一样创建C#语言修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找先生。 Skeet的关于如何重新实现LINQ的博客

特别地,他说代码:

var list = (from person in people
        where person.FirstName.StartsWith("J")
        orderby person.Age
        select person.LastName)
       .ToList(); 

转换为由LINQ库提供的扩展方法的方法:

is translated to methods that are extension methods that are provided by the LINQ library:

people.Where(person => person.FirstName.StartsWith("J"))
  .OrderBy(person => person.Age)
  .Select(person => person.LastName) 

由编译器

我的问题是,如何让一个图书馆足够强大的图书馆,让他们允许语言改变以支持图书馆?

My question is, how does one impress the bigwigs enough with a library to cause them to allow the language to change to support the library? Or were those words already reserved before LINQ came along?

推荐答案

抓取Mono C#编译器 - 它是开源的,你可以做任何事情语言修改和.net支持的语言修改,例如使用枚举作为泛型约束,创建返回值类型引用的方法( public ref int Max(ref int x,ref int y){if(x> ; y)return ref x; else return ref y;} ),它们具有受保护或内部可见性等。

Grab the Mono C# Compiler - it's open source and you can do whatever language modifications you want and which .net supports, e.g., use enums as generic constraints, create methods that return references to value types (public ref int Max(ref int x, ref int y) { if (x>y) return ref x; else return ref y; }), that have protected or internal visibility etc.

当然,然后创建一个不兼容的C#导出,但如果你把它推得足够的人可能会喜欢它。

Of course, you are then creating an incompatible derivate of C#, but if you push it hard enough then people might like it.

另一个选项:开始一个博客,拿出一些很好的它的使用案例,可能是.net语言中的示例实现或使用定制的编译器,显示它解决了什么问题,为什么这将是一个伟大的胜利,证明在指定,设计,开发,测试和记录的成本该功能。

The other option: Start a blog, come up with some really good use cases for it, possibly a sample implementation in a .net language or using a customized compiler, show what problem it solves and why this would be a big win that justifies the cost that goes into specifying, designing, developing, testing and documenting of the feature.

这篇关于是否可能像LINQ一样创建C#语言修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆