Sys

class Sys

The main class of the program.

Sys is a singleton class, its only instance is accessible from everywhere with sys.

Because of this, methods that should be accessible from everywhere, like print or exit, are defined in Sys. Moreover, unless there is an ambiguity with self, the receiver of a call to these methods is implicitly sys. Basically it means that the two following instructions are equivalent.

print "Hello World"
sys.print "Hello World"

Methods Implicitly Defined in Sys

Sys is the class where are defined top-level methods, i.e. those defined outside of any class like in a procedural language. Basically it means that

redef class Sys
   fun foo do print "hello"
end

is equivalent with

fun foo print "hello"

As a corollary, in a top-level method, self (the current receiver) is always sys.

Inheritance

dep_class_core__kernel__SysObjectObjectSysSysSys->Object

Parents

  • Object: The root of the class hierarchy.

Constructors

Concerns

  • core: Nit common library of core classes and methods
    • kernel: Most basic classes and methods.
    • gc: Access to the Nit internal garbage collection mechanism
    • collection: This module define several collection classes.
      • sorter: This module contains classes used to compare things and sorts arrays.
    • math: Mathematical operations
    • bytes: Services for byte streams and arrays
    • posix: Services conforming to POSIX
    • text: All the classes and methods related to the manipulation of text entities
      • abstract_text: Abstract class for manipulation of sequences of characters
      • ropes: Tree-based representation of a String.
    • codecs: Group module for all codec-related manipulations
    • time: Management of time and dates
    • file: File manipulations (create, read, write, etc.)
    • environ: Access to the environment variables of the process
    • exec: Invocation and management of operating system sub-processes.
  • emscripten: Platform for the emscripten framework
    • emscripten: Platform for the emscripten framework
  • for_abuse: Service management through the for control structure.
    • for_abuse: Service management through the for control structure.
  • hash_debug: Inject behavior analysis to hash-collections (HashMap, HashSet, etc.)
    • hash_debug: Inject behavior analysis to hash-collections (HashMap, HashSet, etc.)
  • libevent: Low-level wrapper around the libevent library to manage events on file descriptors
    • libevent: Low-level wrapper around the libevent library to manage events on file descriptors
  • niti_runtime: Runtime library to loop around the main program for each line in file-name arguments
    • niti_runtime: Runtime library to loop around the main program for each line in file-name arguments
  • pipeline: Pipelined filters and operations on iterators.
    • pipeline: Pipelined filters and operations on iterators.
  • readline: GNU readline library wrapper
    • readline: GNU readline library wrapper
  • signals: ANSI C signal handling
  • x11: Services from the X11 library
    • x11: Services from the X11 library
  • bcm2835: Services to control the bcm2835 chipset used in the Raspberry Pi
  • dot: Dot rendering library
  • egl: Interface between rendering APIs (OpenGL, OpenGL ES, etc.) and the native windowing system.
    • egl: Interface between rendering APIs (OpenGL, OpenGL ES, etc.) and the native windowing system.
  • gen_nit: Support to generate and otherwise manipulate Nit code
    • gen_nit: Support to generate and otherwise manipulate Nit code
  • gettext: Internationalization of Strings using gettext library
    • gettext: Internationalization of Strings using gettext library
    • examples
      • langannot: Sample module showing the use of the i18n annotation
  • html: HTML output facilities
  • logic: First-order logic data structure and algorithm.
    • lexpr: Logical expression.
  • performance_analysis: Services to gather information on the performance of events by categories
  • pnacl: Provides PNaCl support for Nit.
  • sendmail: Send emails using the sendmail program
    • sendmail: Send emails using the sendmail program
  • sqlite3: Services to manipulate a Sqlite3 database
  • xdg_basedir: Services for using the XDG Base Directory specification
    • xdg_basedir: Services for using the XDG Base Directory specification
    • show_basedir: Prints the local base directories as per the XDG Base Directory specification
  • curl: Data transfer with URL syntax
  • privileges: Process privileges management utilities
  • socket: Socket services
  • template: Basic template system
  • cocoa: Cocoa API, the development layer of OS X
  • counter: Simple numerical statistical analysis and presentation
    • counter: Simple numerical statistical analysis and presentation
  • glesv2: OpenGL graphics rendering library for embedded systems, version 2.0
  • java: Supporting services for the FFI with Java and to access Java libraries
    • ffi_support: Core supporting services for the FFI with Java
  • markdown: A markdown parser for Nit.
    • nitmd: A Markdown parser for Nit.
  • pthreads: POSIX Threads support
  • websocket: Adds support for a websocket connection in Nit
  • actors: Nit Actor Model
    • examples
      • chameneos-redux
        • chameneosredux: Example implemented from "The computer Language Benchmarks Game" - Chameneos-Redux
      • fannkuchredux: Example implemented from "The computer Language Benchmarks Game" - Fannkuch-Redux
        • fannkuchredux: Example implemented from "The computer Language Benchmarks Game" - Fannkuch-Redux
      • mandelbrot: Example implemented from "The computer Language Benchmarks Game" - Mandelbrot
        • mandelbrot: Example implemented from "The computer Language Benchmarks Game" - Mandelbrot
      • simple: A very simple example of the actor model
        • simple: A very simple example of the actor model
      • thread-ring
        • thread_ring: Example implemented from "The computer Language Benchmarks Game" - Thread-Ring
      • agent_simulation: a "Framework" to make Multi-Agent Simulations in Nit
    • actors: Abstraction of the actors concepts
  • array_debug: Exposes functions to help profile or debug Arrays.
    • array_debug: Exposes functions to help profile or debug Arrays.
  • crapto: Cryptographic attacks and utilities.
  • text_stat: Injects stat-calculating functionalities to Text and its variants
    • text_stat: Injects stat-calculating functionalities to Text and its variants
  • ai: Simple library for basic artificial intelligence algorithms
    • examples
      • queens: Example of the famous eight-queens problem solved with the ai::backtrack module.
      • puzzle
  • sdl2: This is a low-level wrapper of the SDL 2.0 library (as sdl2) and SDL_image 2.0 (as sdl2::image).
  • vsm: Vector Space Model
  • gtk: GTK+ widgets and services
    • v3_4
      • gtk_core: Classes and services to use libGTK widgets
      • gdk: Services from GDK
  • serialization: Abstract serialization services
    • safe: Services for safer deserialization engines
    • examples
      • custom_serialization: Example of an ad hoc serializer that is tailored to transform business specific objects into customized representation.
  • geometry: Basic geometry data structures and services.
    • polygon: Convex Polygons manipulations
  • dom: Easy XML DOM parser
  • json: read and write JSON formatted text
  • app: app.nit, a framework for portable applications
    • app_base: Base of the app.nit framework, defines App
    • audio: Services to load and play Sound and Music from the assets folder
    • ui: Portable UI controls for mobiles apps
    • examples
      • ui_example: User interface example using app::ui
  • ios: iOS support for app.nit
    • app: Basic structure for Nit apps on iOS
    • ios: iOS platform support
  • linux: Implementation of app.nit for the Linux platform
    • linux: Implementation of app.nit for the Linux platform
    • ui: Implementation of the app.nit UI module for GNU/Linux
  • mongodb: MongoDB Nit Driver.
  • mpi: Implementation of the Message Passing Interface protocol by wrapping OpenMPI
    • examples: Examples using the MPI protocol
    • mpi: Implementation of the Message Passing Interface protocol by wrapping OpenMPI
  • msgpack: MessagePack, an efficient binary serialization format
  • nlp: Nit wrapper for Stanford CoreNLP
  • nitcorn: Lightweight framework for Web applications development
  • github: Nit wrapper for Github API
  • popcorn: Popcorn
  • gamnit: Portable game and multimedia framework for Nit
    • display: Abstract display services
    • textures: Load textures, create subtextures and manage their life-cycle
    • texture_atlas_parser: Tool to parse XML texture atlas and generated Nit code to access subtextures
    • font: Abstract font drawing services, implemented by bmfont and tileset
    • network: Easy client/server logic for games and simple distributed applications
      • common: Services common to the client and server modules
      • client: Client-side network services for games and such
    • depth: gamnit depth, a framework to create portable 3D games in Nit.
      • more_models: Services to load models from the assets folder
  • android: Android platform support and APIs
    • platform: Triggers compilation for the android platform
    • key_event
    • log: Advanced Android logging services
    • dalvik: Java related services specific to Android and its Dalvik VM
    • native_app_glue: Wrapper of the Android native_app_glue framework to implement app.nit
    • nit_activity: Core implementation of app.nit on Android using a custom Java entry point
    • http_request: Android implementation of app:http_request
    • service: Android service support for app.nit centered around the class Service
      • service: Android service support for app.nit centered around the class Service
    • ui: Views and services to use the Android native user interface
      • native_ui: Native services from the android.view and android.widget namespaces
    • intent: Services allowing to launch activities and start/stop services using
      • intent_api10: Services allowing to launch activities and start/stop services using

in core::kernel

redef type SELF

Type of this instance, automatically specialized in every class

A common use case of the virtual type SELF is to type an attribute and store another instance of the same type as self. It can also be used as as return type to a method producing a copy of self or returning an instance expected to be the exact same type as self.

This virtual type must be used with caution as it can hinder specialization. In fact, it imposes strict restrictions on all sub-classes and their usage. For example, using SELF as a return type of a method foo forces all subclasses to ensure that foo returns the correct and updated type. A dangerous usage take the form of a method typed by SELF which creates and returns a new instance. If not correctly specialized, this method would break when invoked on a sub-class.

A general rule for safe usage of SELF is to ensure that inputs typed SELF are stored in attributes typed SELF and returned by methods typed SELF, pretty much the same things as you would do with parameter types.

fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization

fun run

The entry point for the execution of the whole program.

When a program starts, the following implicit sequence of instructions is executed

sys = new Sys
sys.run

Whereas the job of the run method is just to execute main.

The only reason of the existence of run is to allow modules to refine it and inject specific work before or after the main part.

in core::gc

in core::collection::sorter

in core::math

fun inf: Float

Positive float infinite (IEEE 754)

assert inf > 10.0
assert inf.is_inf == 1

inf follows the arithmetic of infinites

assert (inf - 1.0) == inf
assert (inf - inf).is_nan

The negative infinite can be used as -inf.

assert -inf < -10.0
assert (-inf).is_inf == -1

fun nan: Float

Not a Number, representation of an undefined or unrepresentable float (IEEE 754).

nan is not comparable with itself, you should use Float::is_nan to test it.

assert nan.is_nan
assert nan != nan

nan is the quiet result of some undefined operations.

assert (1.0 + nan).is_nan
assert (0.0 / 0.0).is_nan
assert (inf - inf).is_nan
assert (inf / inf).is_nan
assert (-1.0).sqrt.is_nan

fun srand

Reinitialize the pseudo-random generator used by the method rand and other.

This method is automatically invoked at the begin of the program, so usually, there is no need to manually invoke it. The only exception is in conjunction with srand_from to reset the pseudo-random generator.

fun srand_from(x: Int)

Initialize the pseudo-random generator with the given seed.

The pseudo-random generator is used by the method rand and other to generate sequence of numbers. These sequences are repeatable by calling srand_from with a same seed value.

srand_from(0)
var a = 10.rand
var b = 100.rand
srand_from(0)
assert 10.rand == a
assert 100.rand == b

in core::bytes

in core::posix

in core::text::abstract_text

in core::text::ropes

fun maxlen: Int

Maxlen is the maximum length of a Leaf node

When concatenating two leaves, if new_length > maxlen, A Concat node is created instead

Its purpose is to limit the depth of the Rope (this improves performance when accessing/iterating).

in core::codecs::iso8859_1

in core::codecs::utf8

in core::time

in core::file

in core::exec

in emscripten::emscripten

in for_abuse::for_abuse

in hash_debug::hash_debug

redef fun run

The entry point for the execution of the whole program.

When a program starts, the following implicit sequence of instructions is executed

sys = new Sys
sys.run

Whereas the job of the run method is just to execute main.

The only reason of the existence of run is to allow modules to refine it and inject specific work before or after the main part.

in libevent::libevent

in niti_runtime::niti_runtime

redef fun run

The entry point for the execution of the whole program.

When a program starts, the following implicit sequence of instructions is executed

sys = new Sys
sys.run

Whereas the job of the run method is just to execute main.

The only reason of the existence of run is to allow modules to refine it and inject specific work before or after the main part.

in pipeline::pipeline

in readline::readline

in signals::signals

in x11::x11

in bcm2835::bcm2835

in bcm2835::examples::blink

in bcm2835::examples::input

redef fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization

in dot::examples::clusters

redef fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization

in dot::examples::hello

redef fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization

in dot::examples::undirected_clusters

redef fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization

in egl::egl

in gen_nit::gen_nit

in gettext::gettext

redef fun run

The entry point for the execution of the whole program.

When a program starts, the following implicit sequence of instructions is executed

sys = new Sys
sys.run

Whereas the job of the run method is just to execute main.

The only reason of the existence of run is to allow modules to refine it and inject specific work before or after the main part.

in gettext::examples::langannot

redef fun main

The main method of a program.

In a module, the instructions defined outside any classes or methods (usually called the main of the module) is an implicit definition of this main method. Basically it means that the following program

print "Hello World"

is equivalent with

redef class Sys
   redef fun main do
      print "Hello World"
   end
end

Linearization