为什么C#的功能写频语言吗? [英] Why is C# a functional programmming language?

查看:114
本文介绍了为什么C#的功能写频语言吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人说,C#可视为一个函数式编程语言,即使它被广泛认为是一个面向对象的编程语言。

It has been said that C# can be regarded as a functional programming language, even though it is widely recognized as a OO programming language.

那么,什么功能集使得C#函数式编程语言

So, what feature set makes C# a functional programming language?

我只能想到的:


  1. 代表(即使没有匿名方法和lambda表达式)

  2. 关闭

还有别的吗?

推荐答案

C#借来了,例如很多来自ML和Haskell特点:

C# has borrowed a lot of features from ML and Haskell for example:


  • C#2.0带给我们的参数多态(或仿制药)。我听说大教堂赛姆,F#的创造者之一,是在.NET BCL实施仿制药的主要原因。

  • C# 2.0 brought us parametric polymorphism (or "generics"). I've heard that Dom Syme, one of the creators of F#, was largely responsible for implementing generics in the .NET BCL.

C#2.0还允许程序员传递和返回功能的高阶函数值,并有匿名委托有限的支持。

C# 2.0 also allows programmers to pass and returns functions as values for higher-order functions, and has limited support for anonymous delegates.

C#3.0和3.5的改进支持匿名函数真正关闭

C# 3.0 and 3.5 improved support anonymous functions for true closures.

LINQ可以被认为是C#的自己的列表内涵的味道。

LINQ can be considered C#'s own flavor of list comprehensions.

匿名类型看起来像ML记录的近似

Anonymous types look like an approximation of ML records

类型推断是一个给定的。

Type-inference is a given.

我不知道你,但C#扩展方法看起来极像是哈斯克尔<一个HREF =htt​​p://en.wikipedia.org/wiki/Type_class>类型类的。

I don't know about you, but C# extension methods look an awful lot like Haskell type classes.

有已经有很多讨论有关动态关键字在C#4.0。我不是100%肯定它的实现细节,但我相当肯定它要使用结构性打字而不是后期绑定留住C#的编译时的安全性。结构类型大致相当于鸭打字静态语言,它是Haskell和ML黑客已享受了多年的功能。

There's been a lot of talk about the "dynamic" keyword in C# 4.0. I'm not 100% sure of its implementation details, but I'm fairly sure its going to use structural typing rather than late binding to retain C#'s compile time safety. Structural typing is roughly equivalent to "duck typing for static languages", its a feature that Haskell and ML hackers have been enjoying for years.

这是不是说C#是一种函数式编程语言。它仍然缺少重要的功能,例如模式匹配,尾部调用优化,以及列表和元组文字。此外,地道的C#是与可变状态的严重依赖从根本上必不可少的。

This isn't to say that C# is a functional programming language. Its still missing important features such as pattern matching, tail-call optimization, and list and tuple literals. Additionally, idiomatic C# is fundamentally imperative with a heavy dependence on mutable state.

我不一定会考虑一些上面的独家功能编程语言所提到的那些功能,但它相当清楚的是,C#开发人员已经采取了很多函数式编程语言的灵感,在过去的几年。

I wouldn't necessarily consider some of those features mentioned above as exclusive to functional programming languages, but its pretty clear that the C# developers have taken a lot of inspiration from functional programming languages in the past few years.

这篇关于为什么C#的功能写频语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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