LINQ: Why is it called “Comprehension Syntax”

感情迁移 提交于 2019-11-29 06:01:40

问题


Why is the following LINQ syntax (sometimes called "query" syntax) called "comprehension" syntax? What's being comprehended (surely that's wrong)? Or, what is comprehensively represented (maybe I'm on the right track, now)?


回答1:


I suspect this is related to the second meaning of Comprehend:

to take in or embrace; include; comprise

This syntax has to do with defining what should be included in a set.




回答2:


It comes from the more language-agnostic term List Comprehension which many languages follow. The history apparently is:

The SETL programming language (later 1960s) had a set formation construct, and the computer algebra system AXIOM (1973) has a similar construct that processes streams, but the first use of the term "comprehension" for such constructs was in Rod Burstall and John Darlington's description of their functional programming language NPL from 1977.

FOLDOC mostly echoes this as well:

According to a note by Rishiyur Nikhil , (August 1992), the term itself seems to have been coined by Phil Wadler circa 1983-5, although the programming construct itself goes back much further (most likely Jack Schwartz and the SETL language).

The term "list comprehension" appears in the references below.

The earliest reference to the notation is in Rod Burstall and John Darlington's description of their language, NPL.

["The OL Manual" Philip Wadler, Quentin Miller and Martin Raskovsky, probably 1983-1985].

["How to Replace Failure by a List of Successes" FPCA September 1985, Nancy, France, pp. 113-146].




回答3:


I think this paper can shed light http://dl.acm.org/citation.cfm?id=181564 I.e they argue and define (I think) what a comprehension syntax is. It is issued in 1994 and maybe it affected the design concepts of LINQ.




回答4:


My understanding of the term linq comprehension syntax as a.NET developer is that it allows you to write linq in a familiar style query language. As a person's understanding of linq improves they may move to what is known in .NET as extension method syntax, which is also how the .NET compiler will interpret linq at compile time.




回答5:


Since the term "comprehension" and "comprehensive" is very often used in English language to indicate the "whole" and "completeness", one meaning of comprehension syntax could be a sintax that allows to build expressions which are able to generate sets of values that "include all values"(comprehend) that respect the rules expressed by those expressions.

Another meaning could be more related to the generation of subsets of values (lists) starting from some specified set, and therefore the subset of values that belongs to the starting set and it is "comprised" in the original set. For that reason, the comprehension sintax could be the sintax for the programming languages's constructs that can generate subset values comprised into a specified original set.



来源:https://stackoverflow.com/questions/6229187/linq-why-is-it-called-comprehension-syntax

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!