Content deleted Content added
m remove portal link |
Jerryobject (talk | contribs) m Template:Infobox programming language parameters: cut fixed size, fills, fix, carriage returns restore. Cut needless whitespace character spaces to standardize, aid work via small screens. |
||
(44 intermediate revisions by 38 users not shown) | |||
Line 1:
{{Short description|Functional logic programming language}}
{{For|Mercury Autocode|Autocode}}
{{Distinguish|Mercurial|Mercury (RemObjects BASIC programming language)}}
{{Infobox programming language
| name = Mercury
| logo = Mercury (programming language) logo.jpg
| paradigm = [[Logic programming|Logic]], [[Functional programming|functional]], [[Object-oriented programming|object-oriented]]{{citation needed|date=February 2024}}
| family = [[Prolog]], [[Haskell]]
| designer = Zoltan Somogyi
| developer = [[University of Melbourne]]
| released = {{Start date and age|1995|04|08}}
| latest release version =
| latest release date = {{Start date and age|
| typing = [[Strong and weak typing|
| scope = [[Scope (computer science)|lexical]]
| programming language = Mercury
| platform = [[IA-32]], [[x86-64]], [[ARM architecture family|ARM]], [[SPARC
| operating system = [[Cross-platform software|Cross-platform]]: [[Unix]], [[Linux]], [[macOS]], [[Oracle Solaris
| license = [[GNU General Public License|GPL]] compiler,<br
| file ext = .m
| file format =
Line 23:
| implementations = Melbourne Mercury Compiler
| dialects =
| influenced by = [[Prolog]], [[Hope (programming language)|Hope]], [[
| influenced =
}}
'''Mercury''' is a [[functional logic programming]] language made for real-world uses. The first version was developed at the [[University of Melbourne]], Computer Science department, by Fergus Henderson, Thomas Conway, and Zoltan Somogyi, under Somogyi's supervision, and released on April 8, 1995.
Mercury is a purely [[Declarative programming|declarative]] [[logic programming]] language. It is related to both [[Prolog]] and [[
The official implementation, the Melbourne Mercury Compiler, is available for most [[Unix]] and [[Unix-like]] platforms, including [[Linux]], [[macOS]], and for [[Microsoft Windows|Windows
== 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.
Line 41 ⟶ 40:
|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
Line 48 ⟶ 47:
|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>
|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.
Notable programs written in Mercury include the Mercury compiler and the [[Prince XML]] formatter. The Software company
==Back-ends==
Line 66 ⟶ 63:
===Production level===
* Low-level [[C (programming language)|C]] for [[GNU Compiler Collection]] (GCC), the original Mercury back-end
* High-level C
* [[Java (programming language)|Java]]
* [[C Sharp (programming language)|C#]]
*[[Erlang (programming language)|Erlang]]▼
===Past===
* [[Assembly language]] via the GCC back-end
* Aditi, a deductive database system also developed at the [[University of Melbourne]]. Mercury-0.12.2 is the last version to support Aditi.{{citation needed|date=January 2014}}
* [[Common Intermediate Language]] (CIL) for the [[.NET Framework]]
▲* [[Erlang (programming language)|Erlang]]
Mercury also features a foreign language interface, allowing code in other languages (depending on the chosen back-end) to be linked with Mercury code. The following foreign languages are possible:
Line 100 ⟶ 97:
== Examples ==
[[Hello world program|Hello World]]:
<
:- module hello.
:- interface.
Line 109 ⟶ 106:
main(!IO) :-
io.write_string("Hello, World!\n", !IO).
</syntaxhighlight>
Calculating the 10th [[Fibonacci number]] (in the most obvious way):<ref name="tutorial">Adapted from [http://www.mercurylang.org/documentation/papers/book.pdf Ralph Becket's Mercury tutorial]</ref>
<
:- module fib.
:- interface.
Line 129 ⟶ 126:
io.nl(!IO).
% Could instead use io.format("fib(10) = %d\n", [i(fib(10))], !IO).
</syntaxhighlight>
<code>!IO</code> is a "state variable", which is [[syntactic sugar]] for a pair of variables which are assigned concrete names at compilation; for example, the above is desugared to something like:
<syntaxhighlight lang="prolog">
main(IO0, IO) :-
io.write_string("fib(10) = ", IO0, IO1),
io.write_int(fib(10), IO1, IO2),
io.nl(IO2, IO).
</syntaxhighlight>
==Release schedule==
The stable release naming scheme was 0.1 up to 0.13 for the first thirteen stable releases. In February 2010 the Mercury project decided to name each stable release by using the year and month of the release. For example 10.04 is for a release made in April 2010.
There is often also a periodic snapshot of the development system ''release of the day'' (ROTD)
==IDE and editor support==
* Developers
* Flycheck library for [[Emacs]]
* A plugin is available for the [[Eclipse (software)|Eclipse IDE]]
Line 156 ⟶ 160:
* {{Official website|www.mercurylang.org}}
{{DEFAULTSORT:Mercury (programming language)}}
[[Category:Programming languages]]▼
[[Category:Cross-platform free software]]
[[Category:Functional logic programming languages]]
[[Category:.NET programming languages]]
[[Category:Programming languages created in 1995]]
|