Science Fair Projects Ideas - Syntactic sugar

All Science Fair Projects

      

Science Fair Project Encyclopedia for Schools!

  Search    Browse    Forum  Coach    Links    Editor    Help    Tell-a-Friend    Encyclopedia    Dictionary     

Science Fair Project Encyclopedia

For information on any area of science that interests you,
enter a keyword (eg. scientific method, molecule, cloud, carbohydrate etc.).
Or else, you can start by choosing any of the categories below.

Syntactic sugar

Syntactic sugar is a term coined by Peter J. Landin for additions to the syntax of a computer language that do not affect its expressiveness but make it "sweeter" for humans to use. Syntactic sugar gives the programmer (designer, in the case of specification computer languages) an alternative way of coding (specifying) that is more practical, either by being more succinct or more like some familiar notation. It does not affect the expressiveness of the formalism.

Syntactic sugar can be easily translated ("desugared") to produce a program (specification) in some simpler "core" syntax. In Landin's case, the core was a lambda calculus enriched with a few operations, such as assignment. Following Landin's insights, some later programming languages, such as ML and Scheme, were explicitly designed as a language core of essential constructs, into which other convenient features can be desugared. This is in fact the usual mathematical practice of starting from a minimal set of primitives.

For instance, while it is common for most programming languages to include standard mathematical operations using infix notation (you will often find operations such as i + 1 throughout a typical program's source code) many of these languages (mainly those that are functional languages), handle the actual math by calling functions. In these cases the infix notation is actually syntactic sugar for something such as add(i, 1).

Another example is in the C programming language's handling of arrays, in C arrays are constructed as blocks of memory, accessed via an offset to the array's starting point in memory. However pointer math can often be "tricky" and error prone, so C provides the a[i] syntax for what would otherwise be written as *(a + i)

Alan Perlis once quipped that "Syntactic sugar causes cancer of the semicolon."

The opposite of syntactic sugar is syntactic salt, a feature designed to make it harder to write bad code. Specifically, syntactic salt is a hoop the programmer must jump through just to prove that he knows what's going on, rather than to express a program action. Some programmers consider required type declarations to be syntactic salt. A requirement to write "end if", "end while", "end do", etc. to terminate the last block controlled by a control construct (as opposed to just "end") is widely considered syntactic salt. Syntactic salt is like the real thing in that it tends to raise programmers' blood pressures in an unhealthy way.

09-23-2007 01:00:40
The contents of this article is licensed from www.wikipedia.org under the GNU Free Documentation License. Click here to see the transparent copy and copyright details
Science kits, science lessons, science toys, maths toys, hobby kits, science games and books - these are some of many products that can help give your kid an edge in their science fair projects, and develop a tremendous interest in the study of science. When shopping for a science kit or other supplies, make sure that you carefully review the features and quality of the products. Compare prices by going to several online stores. Read product reviews online or refer to magazines.

Start by looking for your science kit review or science toy review. Compare prices but remember, Price $ is not everything. Quality does matter.
Science Fair Coach
What do science fair judges look out for?
ScienceHound
Science Fair Projects for students of all ages
All Science Fair Projects.com Site
All Science Fair Projects Homepage
Search | Browse | Links | From-our-Editor | Books | Help | Contact | Privacy | Disclaimer | Copyright Notice