M-expression
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
M-expression
In computer programming, M-expressions (or meta-expressions) were intended to be the expressions used to write functions in the Lisp programming language. Data to be manipulated using M-expressions was to be written using S-expressions. M-expressions were used for the original theoretical language in early papers about Lisp, but the first working implementation of Lisp interpreted encodings of M-expressions as S-expressions, and M-expressions were never actually implemented. As John McCarthy explained in History of Lisp:
Historical relation to S-expressionsAn S-expression represents data made up of atoms and pairs. As originally described, an atom was a symbol written in upper case, and a pair was delimited by parentheses. Shorthand list notation was described, though it originally separated list elements by commas rather than whitespace. For example (using spaces rather than commas): ((A B) (C D) (E F)) which represents a list of three elements, each of which is a list of two symbols. An M-expression could also use operator names, meta-variables, and argument lists. Operator names and meta-variable names were in lower case, to show that they were not symbols (i.e., not data). Argument lists were delimited by brackets, car[cons[(A . B); x]] which represents a two-part operation. The first part constructs a pair from the data structure In McCarthy's original published paper on Lisp, as a demonstration of the theoretical universality of the language, he described a function (A B C) (QUOTE (A B C)) car[x] (CAR X) car[append[(A B C); (D E F)]] (CAR (APPEND (QUOTE (A B C)) (QUOTE (D E F)))) The initial implementation of Lisp was expected to be a very long process, as compilers at the time were expected to take years to write. Implementation began with hand-compiling particular functions while the M-expression sublanguage was still tentative. However, S.R. Russell realized that an implementation of Later use of M-expressionsWhile it is not uncommon for Lisp programmers to devise an alternate form for the language (of which MLISP is one example), some of which use M-expressions, such dialects generally lack the homoiconicity of S-expressions, which is considered an important part of the expressiveness of the language. As a result, virtually all mainstream Lisp dialects retain S-expressions as the main (or sole) syntax. Exceptions to this include Logo, which could be considered (loosely) to be an M-expression Lisp. Several other languages, such as Dylan and Python, borrow heavily from Lisp, but use an ALGOL-like syntax that differs from both S-expressions and M-expressions. There is also an implementation of a interpreter for M-LISP in Common Lisp, which evaluates M-Expressions. VariantsThe syntax of ML (Metalanguage), another functional programming language, provides somehow similar syntax, as it derived from math notation as well. However, additional concepts as type annotations and regular expressions hide this similarity. In addition, the Mathematica language uses a syntax similar to the original M-expression syntax, where lists can be written using braces (which can also be written using M-expression notation), and M-expression notation for functions. A more recent variant is I-expressions, which use indentation to indicate parentheses implicitly and are thus in some ways intermediate between S-expressions and M-expressions, were introduced in Scheme Request For Implementation 49 as an auxiliary syntax for Scheme, but they have not been widely adopted. The BYOND internet game development language, a relatively unknown but fairly advanced system based loosely around BASIC but with some LISP-like aspects, uses solely I-expressions. External linksSource: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement