Skip to content
Branch: master
Go to file

Latest commit

privat committed 0c011f8 Jun 8, 2020
Merge: Contract refactoring
This pr do the following changes:

* Authorize the declaration of identical contracts on the same method in order to facilitate the reading of contracts. Example
fun foo(x, y: Int)
	expect(x > 0)
	expect(y > 0)
do end

* Modification of the generation of contracts. In the default mode, the contracts are now generated even if they are not used, only the public facet is generated only if it is necessary. The objective is to provide the contracts verification when you are in a redefinition in a module where contracts must be applied. This solution is a compromise to try to keep acceptable performance in the default mode. Example

module one
import two

module two
import three

redef class C
	# Now all calls to foo of c (only in module one or two) check the `expect` property defined in module three (as defined by the default contract rule).
	redef foo ...

module three

class C
	fun foo is expect(true), ensure(true)

* When a contract is not fulfilled the messages displayed to the user are now more explicit. Example:

class A
	fun foo(i: Int) is expect(i > 0) do end

var a = new A
This is the output of the program
Runtime error: Assert 'expect(i > 0)' failed

* Cosmetic modifications have been made to remove useless methods, modify the names and comments of certain methods to be more explicit.

Pull-Request: #2827


Failed to load latest commit information.
Latest commit message
Commit time

Nit is an expressive language with a script-like syntax, a friendly type-system and aims at elegance, simplicity and intuitiveness.

Nit has a simple straightforward style and can usually be picked up quickly, particularly by anyone who has programmed before. While object-oriented, it allows procedural styles.

The Nit Compiler (nitc) produces efficient machine language binaries.

Some Nit features:

  • Pure Object-Oriented.
  • Multiple Inheritance.
  • Realist typing policy.
  • Light and clear syntax.


Those are available in most Linux distributions

$ sudo apt-get install build-essential ccache libgc-dev libunwind-dev pkg-config

and on OS X using brew

$ brew install ccache bdw-gc libunwind-headers pkgconfig

or with MacPorts

$ sudo port install ccache boehmgc libunwind-headers pkgconfig

Important files and directories:

  • benchmarks/ Script to bench the compilers
  • bin/ The Nit tools
  • c_src/ C code of nitc (needed to bootstrap)
  • clib/ C code needed by nitc to compile programs
  • contrib/ Various Nit programs (may or may not be useful)
  • doc/ Documentation
  • examples/ Program examples written in Nit
  • lib/ Nit standard library
  • LICENCE License of the software
  • Makefile Bootstrap the Nit tools
  • misc/ Some additional files for commons text editors and tools
  • List of the authors
  • README This file
  • share/ Common resources used by tools
  • src/ The Nit tool sources (written in Nit)
  • tests/ Non-regression test-suite

How to start:

$ make
$ bin/nitc examples/hello_world.nit
$ ./hello_world

You can source misc/ to setup your environment like PATH, MANPATH and bash completion. To have your environment automatically configured at login, just source it with install as argument.

$ . misc/ install

More tools:

Additional tools can also be compiled but require more dependencies.


To contribute to Nit, please see CONTRIBUTING.

The best way to ask the team for advice, submit bugs or request features, is through the use of Github issues, using the appropriate tag (forum, feature-request, bug).

Information, contacts and help:

You can’t perform that action at this time.