.. Mars Documentation Copyright (C) 2010 Matt Giuca .. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. .. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. .. You should have received a copy of the GNU General Public License along with this program. If not, see . Version history =============== .. sectionauthor:: Matt Giuca This document details the changes made to Mars since its first release. This is a fairly high-level document, describing only the visible changes. For details on the individual bugs fixed, see the bugs targeted to each release in the `trunk series `_. For a complete history of changes to Mars, see the `commit log `_. Version 1.0 ----------- Released Sunday, 6 Jul 2014 This is the first full release of the language and compiler. It introduces backwards-incompatible changes to the built-in types and syntax to make the language more palatable, including operator syntax, a floating-point :type:`Num` type (replacing the old :type:`Int` type) and mandatory annotation of **io** functions. It also introduces a foreign function interface. The backend is now implemented using LLVM, and the compiler performs :ref:`automatic destructive update ` where possible. New features ++++++++++++ * Added an :ref:`automatic destructive update ` system, which performs a sophisticated higher-order aliasing analysis, and transforms copy-and-update array operations into efficient in-place updates where possible to do so without changing the semantics of the program. (LP: `#1338015 `_) * The compiler now internally uses LLVM to generate assembly code which is directly executed on the machine (rather than an interpreter), making execution hundreds of times faster. The :command:`marsc` compiler can now be used to generate a native executable from a Mars program. (LP: `#690006 `_) Core language changes +++++++++++++++++++++ * Added a foreign-function interface, with the ability to :ref:`call native code `. (LP: `#488588 `_) * Removed the :type:`Int` type, and added :type:`Num` (double-precision floating point numbers). (LP: `#870515 `_) * Functions with I/O effects now require an explicit :keyword:`io` annotation (see :ref:`ref-io-context`). (LP: `#892922 `_) * Added infix arithmetic and comparison operators. (LP: `#871246 `_) * Assignment statements and parameters can now perform pattern matching. (LP: `#513633 `_) * Add an :keyword:`elif` statement as syntactic sugar. (LP: `#872685 `_) * :keyword:`for` is now a reserved keyword (it is a syntax error to ever use it, as it may be used in a future version). (LP: `#892948 `_) * Explicitly specified that the evaluation order of function arguments is unspecified. (LP: `#897070 `_) Library changes +++++++++++++++ * The built-in :func:`is` function now has unspecified behaviour in many cases, allowing greater implementation freedom. (LP: `#708469 `_) * Updated all functions to use :type:`Num` instead of :type:`Int`. (LP: `#870515 `_) * To support the new foreign-function interface, added the modules :mod:`native` and :mod:`struct`. (LP: `#488588 `_) * To support the new :keyword:`io` keyword, added the modules :mod:`iofuncs` and :mod:`debug`. (LP: `#912103 `_) * Added the module :mod:`set`. Bug fixes +++++++++ * Fixed pattern matching parsing for negative literals. (LP: `#912145 `_) * The parser now exits properly if it cannot read a file. (LP: `#894619 `_) * Fixed test framework crash if "?>" is split across read chunks. (LP: `#1101674 `_) Miscellaneous +++++++++++++ * Updated to build with modern versions of Mercury. Now requires Mercury 14.01 or greater. (LP: `#894607 `_; `#1332958 `_) * The official build now comes bundled with the Mercury library files, and a wrapper script to run with the correct library path. Previous versions were statically linked with the Mercury libraries, but that does not work with the new Mars LLVM runtime, which requires a dynamic version of libgc. (LP: `#1338058 `_) * Calls to known type dictionaries are now optimized, avoiding a dynamic lookup. (LP: `#720588 `_) * Optimised indirection when getting the :func:`eq` or :func:`show` closure. (LP: `#1205796 `_) * Improved the tutorial. It now covers first-class functions and currying. (LP: `#893471 `_) * Documentation: Wrote the section about :ref:`ref-values`. (LP: `#912041 `_) Version 0.3.1 ------------- Released Thursday, 27 Oct 2011 This version focuses almost exclusively on redesigning the Mars internal representation so that it is easier to implement in low-level back-ends such as LLVM. While there are almost no publicly-visible changes, the instruction set architecture is drastically different than in previous versions. The code generator has to work much harder to generate lower-level code, but this pays off in that the many different back-ends have a much easier job to do. Bug fixes +++++++++ * Case-bound variables now conform to SSA, preventing internal errors for some programs. (LP: `#578068 `_) * Fixed temporary names being reused within a single-case switch. (LP: `#682536 `_) * Fixed interactive mode not catching errors raised by evaluating CGCs. (LP: `#697929 `_) * Fixed interactive mode remembering the value of every temporary variable in the history of the session. (LP: `#871725 `_) * Fixed :func:`mars.exec_main_func`; now puts the result in the localtable. (LP: `#600467 `_) * Internal software errors now go to stderr, not stdout. (LP: `#690053 `_) * When printing the environment, fixed internally representing constructor names with :func:`gvname`, which they aren't supposed to be represented as. (LP: `#700862 `_) * Fixed the built-in :func:`show` type (the variable `a` was not rigid). (LP: `#708486 `_) * The test framework now reports test cases that crash and those that don't end properly. (LP: `#576385 `_; `#690054 `_) * Readline completion no longer shows internal (synthetic) functions. (LP: `#702205 `_) * The "``:e``" display no longer shows subscripted variables. (LP: `#710450 `_) * Fixed the ordering of blocks in the Mars IR code. It now reasonably well follows the order of the original source code. (LP: `#412367 `_) Internal changes ++++++++++++++++ * The :func:`show` and :func:`eq` functions are now implemented non-primitively using type dictionaries (see :ref:`ref-typedicts`). This means back-ends do not need to supply an implementation for these type-specific functions. (LP: `#710495 `_) * Changed the semantics of the field access instructions so they are much lower level. The code generator now generates field access functions in Mars IR to non-primitively perform the high-level actions. The instructions implemented by the back-end now perform very simple tasks. (LP: `#690017 `_) * There is now an instruction for directly calling a constructor, rather than having to load it into a local function first. (LP: `#766796 `_) * Major change to Mars IR: global variables are no longer accessible as variable names (only local variables). Rather, we provide special instructions to call and load the value of global variables. (LP: `#699721 `_) * Mars IR can no longer partially apply functions. Replaced this feature by introducing "closure templates" which are much easier to implement on low-level back-ends. The code generator must now generate a closure template for each partial application, which explicitly accepts a certain number of parameters in its closure. (LP: `#744760 `_) * Removed instructions for loading int literals and constructor symbols; instead, int literals and constructor symbols are considered to be "atoms" along with variable names, and atoms can now be referenced by most instructions that used to refer only to variable names. (LP: `#440429 `_) * Renamed the internal function :func:`ir.varname_to_string_noescape` to simply :func:`ir.varname_string`. (LP: `#690456 `_) Miscellaneous +++++++++++++ * Documentation now builds with Sphinx 1.0.1. (LP: `#780331 `_) * Added high-level :ref:`architecture documentation `. (LP: `#881836 `_) Version 0.3.0 ------------- Released Friday, 25 Jun 2010 Core language changes +++++++++++++++++++++ * Pattern bindings in :keyword:`case` statements are now like any other assignment -- scoped to the entire function and in the same namespace as all the other locals. Patterns no longer create a new scope, and the variables they create no longer shadow existing locals. It is now a type error if a local variable has the same name but different type as a pattern variable (**backwards incompatible**). (LP: `#513638 `_) * It is now a compiler error if a :keyword:`switch` statement does not cover all possible constructors of the type it switches over, preventing the possibility of runtime pattern match failure errors (**backwards incompatible**). (LP: `#408411 `_) * Variables no longer require declaration. Any variable assigned in a function is now implicitly a local variable. It is no longer an error to assign to a global variable or an undefined variable (this just creates a new local variable). (LP: `#483082 `_) * The :ref:`field reference ` and :ref:`replace ` expressions and the :ref:`field update ` statement now work (previously they displayed "not implemented" errors). It is now possible to access and update individual fields of an object by name, without having to use a :keyword:`switch`. (LP: `#439171 `_) * The :ref:`field replace ` statement is now an expression; its result is the updated object. It previously didn't make much sense because the statement performed an implicit assignment of its source variable. (LP: `#408301 `_) * The :ref:`field update ` operator changed from "``=``" to "``=!``", reflecting its impure nature. (LP: `#595782 `_) * It is now an error to have two fields of the same name in a given constructor. (LP: `#513585 `_) * It is now an error to have two variables of the same name in a given pattern. (LP: `#509939 `_) * Reading the value of (and therefore executing the body of) a computable global constant now caches the result so subsequent reads do not re-execute the body. Previously CGCs would be re-executed on each read. (LP: `#491697 `_) Library changes +++++++++++++++ * The built-in :func:`is` function has been moved to the :mod:`impure` module. (LP: `#582634 `_) * The :func:`is` function now works on objects of user-defined types (previously always returned 0). (LP: `#585724 `_) * Added :mod:`prelude` function :func:`ref` which gets the element of a list with a particular index. (LP: `#582635 `_) Bug fixes +++++++++ * Paul Bone: Fixed error compiling Mars on some systems, due to Readline code. (LP: `#552168 `_) * Critical type safety problem -- if a declared local variable and pattern binding have different types, after the :keyword:`switch`, the variable name has the declared type, but the value bound by the case (of the wrong type). Fixed by giving pattern bindings the full function scope, forcing them to have the same type as any declared variable. (LP: `#513638 `_) * Internal error "Phi missing predecessor in CFG" for programs with complex nested switches. (LP: `#567082 `_) * Internal error "Field reference to something not an ADT" for case statements with a nested pattern with two fields. (LP: `#576375 `_) * Type error for cases with int literals on polymorphic types. (LP: `#509457 `_) * Internal error for string literals with ``'\0``. (LP: `#534159 `_) * Internal error calling :func:`error` or :func:`get_env` with ``'\0`` in string. (LP: `#534161 `_) * Library function :func:`encodeURIComponent` gives garbage output on strings with non-byte characters. (LP: `#585703 `_) * Now correctly sets the exit status of Mars to the result of :func:`main` -- rounds to a machine-size int with wraparound rather than using mod. (LP: `#552413 `_) * The :func:`show` function now correctly includes empty parens for terms built from nullary constructors. (LP: `#587787 `_) Test suite and internal changes +++++++++++++++++++++++++++++++ * Replaced "dummy term binding" technique with explicit rigid type variables (as now described in documentation for type unification). (LP: `#488595 `_) * The control-flow graph (CFG) representation now includes full type information. (LP: `#574108 `_) * The ``t_switch`` instruction no longer includes fully-recursive patterns, but a limited format which matches only a single tag. :ref:`Switch statements are now factored ` into this much lower-level construct which is easier to compile into machine code. (LP: `#408411 `_) * The interactive environment now uses SSA variable names, so variables which are re-assigned are no longer physically clobbered in the environment; they are assigned with a new qualified name. This makes the semantics of interactive consistent with the rest of the language and fixes issues with certain backends or analyses. (LP: `#580487 `_) * Fixed test suite silently treating invalid "outcome" values as "fail". (LP: `#574141 `_) * No longer generates code for statements which are inaccessible because they are preceded by a :keyword:`return` statement. This prevents malformed code generation. (LP: `#517403 `_) * Fixed parser not allocating a type to subexpressions of expressions which already have a type annotation. (LP: `#578082 `_) * Interactive mode executes type-annotated versions of statements. (LP: `#578084 `_) * Test suite is now orders of magnitude faster to run (fixed re-compilation for every case, causing N^2 behaviour). (LP: `#589000 `_) * Interpreter interface is now abstracted so it is possible to plug in different interpreter backends. (LP: `#550708 `_) * In the test framework, expecting a compile error now causes all of the runtime tests to be expected to be skipped, so they don't raise large errors when they are. (LP: `#596734 `_) * Terminator instructions now hold a context object. (LP: `#408291 `_) * Function signatures no longer have an "argmode". This was part of some uniqueness information analysis which was abandoned for a different representation, and has since been unused and completely obsolete. (LP: `#550739 `_) Miscellaneous +++++++++++++ * All :ref:`library functions ` are now documented. (LP: `#486958 `_) * The documentation is now syntax-highlighted for all Mars code. (LP: `#576776 `_) * If a bug in Mars causes an internal error, it will be displayed much more neatly, with a link to the "file bug" page on the bug tracker. (LP: `#534165 `_) * The test framework no longer generates ``.py`` files with Mars assembly (a bug dating back to when we actually generated Python output). (LP: `#521992 `_) * The :file:`src` directory now includes a Makefile, so Mars can be compiled with a simple ``make``. (LP: `#522477 `_) * The Mars Vim script (:file:`misc/mars.vim`) has an updated list of built-in names. (LP: `#539368 `_) Version 0.2.1 ------------- Released Friday, 27 Nov 2009 Core language changes +++++++++++++++++++++ * Rather than searching the current directory for imports, searches the directory the initial module is located in. This makes multi-module programs possible, without having to run them from the current directory or add them to :envvar:`MARSPATH`. * No longer searches for the :mod:`prelude` in the current directory. * Mars now allows source files with DOS/Windows newlines. Library changes +++++++++++++++ * New :ref:`built-in functions `: :func:`array_add`, :func:`array_remove`, :func:`__impure_array_delete` (also added :func:`array_delete` to :mod:`impure` module). * New :mod:`prelude` functions (based on the Haskell prelude): :func:`id`, :func:`const`, :func:`min`, :func:`max`, :func:`filter`, :func:`foldl1`, :func:`foldr1`, :func:`minimum`, :func:`maximum`, :func:`index`, :func:`elem`, :func:`range`, :func:`array_filter`, :func:`array_foldl1`, :func:`array_foldr1`, :func:`array_elem`, :func:`array_range`. * New :mod:`prelude` constants: :const:`false` and :const:`true`. Bug fixes +++++++++ * Fixed unbounded stack growth during interpretation. Programs can now run for arbitrary lengths of time. * Cyclic imports now work properly (previously failed if the top-level module was involved in an import cycle). * String literals now have type :type:`Array(Int)`, not :type:`Array(a)` (minor fix). * Interactive: Fixed interactively-assigned variables sometimes losing part of their type, causing them to be usable where they shouldn't, and also strange type errors. * Interactive: Fixed exception associated with assigning an error expression to a variable, and then reading the variable's value. * :func:`__impure_array_extend` pre-grows the array to the full size, to avoid multiple regrows. * Fixed syntax error messages with special or non-ASCII characters. * Now fails correctly if given a directory name on the command line. Miscellaneous +++++++++++++ * Interactive: Added readline support (proper command-line editing and completion). Mars now depends upon the GNU Readline library. Version 0.2.0 ------------- Released Saturday, 03 Oct 2009 Library changes +++++++++++++++ * Renamed impure primitives :func:`array_set`, :func:`array_append` and :func:`array_extend` to :func:`__impure_array_set`, etc; these are now deprecated. Added new module :mod:`impure` which provides the original names for these functions. * :mod:`prelude` -- Added constant :const:`eof` with a value of -1. Bug fixes +++++++++ * Fixed software exceptions on user array bounds errors (now displays proper Mars errors). Test suite and internal changes +++++++++++++++++++++++++++++++ * Fixed testing framework (was broken on compilation testing). * Test cases -- More tests for runtime errors. * Internal representation -- Now uses an instruction-based representation rather than statement/expression-based. This is visible in the "asm" backend output. Miscellaneous +++++++++++++ * :command:`marsc` - Removed "python" backend. Added "asm" backend. * Documentation -- Finished :ref:`Introduction to Mars ` section. Added more language features, and removed references to the language Venus. * Documentation -- Renamed "functions" to "procedures" when referring to a function as defined in source code, and renamed "parameter-less function" to "computable global constant". * Samples -- Added sample input to :file:`samples/bfs.mar`. Version 0.1.0 ------------- Released Wednesday, 07 Jan 2009 * First release of Mars. Includes complete interpreter/compiler and documentation (though buggy and missing some features).