Version history
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
Num type (replacing the old 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
automatic destructive update where possible.
New features
- Added an 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 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 call native
code.
(LP: #488588)
- Removed the Int type, and added Num (double-precision
floating point numbers).
(LP: #870515)
- Functions with I/O effects now require an explicit io annotation
(see Procedure body).
(LP: #892922)
- Added infix arithmetic and comparison operators.
(LP: #871246)
- Assignment statements and parameters can now perform pattern matching.
(LP: #513633)
- Add an elif statement as syntactic sugar.
(LP: #872685)
- 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 is function now has unspecified behaviour in many
cases, allowing greater implementation freedom.
(LP: #708469)
- Updated all functions to use Num instead of Int.
(LP: #870515)
- To support the new foreign-function interface, added the modules
native and struct.
(LP: #488588)
- To support the new io keyword, added the modules iofuncs
and debug.
(LP: #912103)
- Added the module 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 eq or show closure.
(LP: #1205796)
- Improved the tutorial. It now covers first-class functions and currying.
(LP: #893471)
- Documentation: Wrote the section about 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 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 gvname, which they aren’t supposed to be represented as.
(LP: #700862)
- Fixed the built-in 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 show and eq functions are now implemented
non-primitively using type dictionaries (see Type dictionaries). 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 ir.varname_to_string_noescape to
simply ir.varname_string.
(LP: #690456)
Version 0.3.0
Released Friday, 25 Jun 2010
Core language changes
- Pattern bindings in 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 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 field reference and replace expressions and the 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
switch.
(LP: #439171)
- The 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 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 is function has been moved to the impure module.
(LP: #582634)
- The is function now works on objects of user-defined types
(previously always returned 0).
(LP: #585724)
- Added prelude function 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 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 error or get_env with '\0 in
string.
(LP: #534161)
- Library function encodeURIComponent gives garbage output on strings
with non-byte characters.
(LP: #585703)
- Now correctly sets the exit status of Mars to the result of main –
rounds to a machine-size int with wraparound rather than using mod.
(LP: #552413)
- The 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. 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 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 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 src directory now includes a Makefile, so Mars can be compiled
with a simple make.
(LP: #522477)
- The Mars Vim script (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 MARSPATH.
- No longer searches for the prelude in the current directory.
- Mars now allows source files with DOS/Windows newlines.
Library changes
- New built-in functions: array_add,
array_remove, __impure_array_delete (also added
array_delete to impure module).
- New prelude functions (based on the Haskell prelude): id,
const, min, max, filter, foldl1,
foldr1, minimum, maximum, index,
elem, range, array_filter, array_foldl1,
array_foldr1, array_elem, array_range.
- New prelude constants: false and 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 Array(Int), not 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.
- __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 array_set, array_append and
array_extend to __impure_array_set, etc; these are now
deprecated. Added new module impure which provides the original names
for these functions.
- prelude – Added constant 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
- marsc - Removed “python” backend. Added “asm” backend.
- Documentation – Finished 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 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).