Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Syntactic sugar
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Programming language syntax designed for ease of use}} In [[computer science]], '''syntactic sugar''' is [[Syntax (programming languages)|syntax]] within a [[programming language]] that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer. Syntactic sugar is usually a shorthand for a common operation that could also be expressed in an alternate, more verbose, form: The programmer has a choice of whether to use the shorter form or the longer form, but will usually use the shorter form since it is shorter and easier to type and read. For example, many programming languages provide special syntax for referencing and updating [[Array data type|array]] elements. Abstractly, an array reference is a procedure of two arguments: an array and a subscript vector, which could be expressed as <code>get_array(Array, vector(i,j))</code>. Instead, many languages provide syntax such as <code>Array[i,j]</code>. Similarly an array element update is a procedure consisting of three arguments, for example <code>set_array(Array, vector(i,j), value)</code>, but many languages also provide syntax such as <code>Array[i,j] = value</code>. A construct in a language is syntactic sugar if it can be removed from the language without any effect on what the language can do: [[Function (engineering)|functionality]] and [[expressive power (computer science)|expressive power]] will remain the same. Language processors, including [[compiler]]s and [[Static program analysis|static analyzers]], often expand sugared constructs into their more verbose equivalents before processing, a process sometimes called "desugaring".
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)