Syntactic Sugar

In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for humans to use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

For example, many programming languages provide special syntax for referencing and updating array elements. Abstractly, an array reference is simply a procedure of two arguments: an array and a subscript vector, which could be expressed as get_array(Array,vector(i,j)); but many languages provide special syntax like Array; similarly an array element update is abstractly something like set_array(Array,vector(i,j),value), but many languages provide syntax like Array := value.

Specifically, a construct in a language is called syntactic sugar if it can be removed from the language without any effect on what the language can do: functionality and expressive power will remain the same. For instance, in the C language the a notation is syntactic sugar for *(a+i).

More generally, the term is used to characterize syntax as being designed for ease of expression, for instance list comprehension in Python. In C#, the property construct may be called syntactic sugar: it is roughly, but not exactly equivalent to a getter-setter pair of functions.

Language processors, including compilers, static analyzers, and the like, often expand sugared constructs into more fundamental constructs before processing, a process sometimes called "desugaring".

Read more about Syntactic Sugar:  Origins, Criticism

Famous quotes containing the words syntactic and/or sugar:

    The syntactic component of a grammar must specify, for each sentence, a deep structure that determines its semantic interpretation and a surface structure that determines its phonetic interpretation.
    Noam Chomsky (b. 1928)

    The sugar maple is remarkable for its clean ankle. The groves of these trees looked like vast forest sheds, their branches stopping short at a uniform height, four or five feet from the ground, like eaves, as if they had been trimmed by art, so that you could look under and through the whole grove with its leafy canopy, as under a tent whose curtain is raised.
    Henry David Thoreau (1817–1862)