Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ: Why is it called "Comprehension Syntax"

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

like image 970
lance Avatar asked Jun 03 '11 15:06

lance


People also ask

What is LINQ syntax?

LINQ query syntax is consist of a set of query keywords defined into the . NET Framework version 3.5 or Higher. This allows the programmer or developers to write the commands similar to SQL style in the code(C# or VB.NET) without using quotes. It is also know as the Query Expression Syntax.

What is the difference between query syntax and method syntax in LINQ?

Query syntax and method syntax are semantically identical, but many people find query syntax simpler and easier to read. Some queries must be expressed as method calls. For example, you must use a method call to express a query that retrieves the number of elements that match a specified condition.

What are the two forms of LINQ?

LINQ comes in two flavors – the Query Syntax and Method Syntax (aka Fluent Syntax).

How many types of LINQ query are there?

LINQ provides you three different ways to write a LINQ query in C# or VB.


3 Answers

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

like image 131
Daniel DiPaolo Avatar answered Oct 07 '22 05:10

Daniel DiPaolo


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.

like image 33
Mathias Avatar answered Oct 07 '22 05:10

Mathias


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.

like image 20
vvassilev Avatar answered Oct 07 '22 06:10

vvassilev