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
Mercury (programming language)
(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!
==Overview== Mercury is based on the logic programming language [[Prolog]]. It has the same syntax and the same basic concepts such as the [[SLD resolution|selective linear definite clause resolution]] (SLD) algorithm. It can be viewed as a pure subset of Prolog with strong types and modes. As such, it is often compared to its predecessor in features and run-time efficiency. The language is designed using [[software engineering]] principles. Unlike the original implementations of Prolog, it has a separate [[compiler|compilation]] phase, rather than being directly interpreted. This allows a much wider range of errors to be detected before running a program. It features a strict [[Type system#Static type checking|static type]] and mode system<ref name=motivation/> and a module system. By using information obtained at compile time (such as type and mode), programs written in Mercury typically perform significantly faster than equivalent programs written in Prolog.<ref name="benchmarks">[http://www.mercurylang.org/about/benchmarks.html The Mercury Project - Benchmarks]</ref><ref name="jlp">{{cite journal |last= Somogyi |first= Zoltan |last2= Henderson |first2= Fergus |last3= Conway |first3= Thomas |title= The execution algorithm of Mercury: an efficient purely declarative logic programming language |journal= Journal of Logic Programming |volume= 29 |issue= 1–3 |pages= 17–64 |publisher= Mercurylang.org |date= October–December 1996 |url= http://www.mercurylang.org/documentation/papers.html#jlp |doi= 10.1016/S0743-1066(96)00068-4 |access-date = 2008-08-30|citeseerx=10.1.1.46.9861}}</ref> Its authors claim that Mercury is the fastest logic language in the world, by a wide margin.<ref name="motivation"/> Mercury is a purely [[Declarative programming|declarative]] language, unlike [[Prolog]], since it lacks ''extra-logical'' Prolog statements such as <code>!</code> (cut) and [[imperative programming|imperative]] [[input/output]] (I/O). This enables advanced [[static program analysis]] and [[program optimization]], including compile-time [[Garbage collection (computer science)|garbage collection]],<ref>{{cite thesis |url=https://mercurylang.org/documentation/papers/CW2004_03_mazur.pdf |title=Compile-time garbage collection for the declarative language Mercury |first=Nancy |last=Mazur |date=May 2004 |publisher=Katholieke Universiteit Leuven}}</ref> but it can make certain programming constructs (such as a switch over a number of options, with a default{{Dubious|Examples_of_difficulties_introduced_by_declarativeness.3F|date=February 2009}}) harder to express. While Mercury does allow impure functionality, it serves mainly as a way to call foreign language code. All impure code must be explicitly marked. Operations which would typically be impure (such as [[input/output]]) are expressed using pure constructs in Mercury using [[Linear type system|linear types]], by threading a dummy ''world'' value through all relevant code. Notable programs written in Mercury include the Mercury compiler and the [[Prince XML]] formatter. The Software company ODASE has also been using Mercury to develop its Ontology-Centric software development platform, ODASE.<ref>[https://www.odase.io/ ODASE]</ref>
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)