开发者

Rationale behind renaming of higher order list operations

开发者 https://www.devze.com 2023-01-17 11:41 出处:网络
What was the rationale behind renaming of higher order list operations in C#? (Examples: map -> Select, filter -> Where开发者_开发百科, fold -> Aggregate)LINQ tries to be roughly familiar to people kn

What was the rationale behind renaming of higher order list operations in C#? (Examples: map -> Select, filter -> Where开发者_开发百科, fold -> Aggregate)


LINQ tries to be roughly familiar to people knowing SQL, where projection is select, etc. You could write your own extension methods with names to suit, of course.


Regarding the meta-question...

The functional programming community and mainstream imperative programming community have evolved in near-isolation from one another for a long time. As a result, there are fundamental vocabulary differences; for example, a common term like "polymorphism" means completely different things to each group (parametric polymoprhism, a.k.a. "generics" or "templates" to the FP-ers; versus subtype polymorphism to the rest).

Asking for the rationale behind names (if there even is one) often results in one simple answer - you name stuff according to the "local culture". In C#, LINQ is a query language like SQL, so it looks a lot like SQL.

But asking this question is roughly analogous to going to Spain and asking what the rationale is for everyone calling his house "mi casa". ("What do you mean why do I call it that? That's what it's called! You mean you call it something different?")


Not an answer, but a worthy aside:

See http://blogs.msdn.com/b/jaredpar/archive/2008/12/02/mapping-linq-to-f.aspx for a 'decoder ring' translation between LINQ (as in C#/Enumerable) and F# Seq functions (which mostly follow the more traditional functional names).


Well, IMO, "fold" is a pretty terrible name for "Aggregate". Freaking math people. :) Mostly though the C# names are more in-line with SQL/LINQ.

0

精彩评论

暂无评论...
验证码 换一张
取 消