20

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)?

lance
  • 16,092
  • 19
  • 77
  • 136

5 Answers5

18

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].

Daniel DiPaolo
  • 55,313
  • 14
  • 116
  • 115
  • I looked at the Wikipedia article that you (and Marc) cited, but I'm still confused about /why/ it's called that (your answer, so far, seems to talk mostly about since /when/ it's been called that). Does /this Wikipedia article ( http://en.wikipedia.org/wiki/Comprehension_(logic) ) have relevance? Is it called "comprehension" syntax because *everything* about the query is defined together (as opposed to LINQ extension methods, which define the query one chunk at a time)? – lance Jun 03 '11 at 15:51
  • 3
    @lance - because it had to be called something ;p Sometimes it is as simple as that... – Marc Gravell Jun 03 '11 at 15:54
  • @lance that's kind of why I included the FOLDOC reference listing, as they mention some of the actual sources by name. If there's no justification or explanation in those sources, then yeah it's basically what Marc said - "it's called that because it's always been called that". – Daniel DiPaolo Jun 03 '11 at 16:14
6

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.

Mathias
  • 15,191
  • 9
  • 60
  • 92
  • 1
    Daniel's answer has given me some great reading, but I'm changing this question to accept Mathias' answer, instead. Daniel's answer goes more to the history of the term "comprehension", while Mathias' very simple point makes clear the association between the term and its secondary definition of _inclusion_, which is core to the idea of 'list comprehension': taking from one set or list and including in another. – lance Nov 06 '13 at 15:18
1

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.

vvassilev
  • 316
  • 2
  • 7
0

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.

Ciro Corvino
  • 2,038
  • 5
  • 20
  • 33
0

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.

Guest
  • 1