Language
      
        Keywords
        
          Core has 23 keywords in total, including 4 contextual keywords. 3 keywords are pending removal.
        
        
          Reserved keywords are regular, contextual keywords are italic.
          To-be-removed keywords are struckthrough
        
          
            | Namespacing |  | 
          
            | import | 
                bring existing type into scopeexamples:import core.String,import core.collection.{ List, Set, Map } | 
          
            | mod | (to be removed) | 
        
        
          
            | Type Definitions |  | 
          
            | class | 
                reference typeexamples:class String,class List[T],class Map[K, V] | 
          
            | value | 
                value typeexamples:value Bool,value Int64,value Float32 | 
          
            | union | 
                union type ( of  lists variants of the union type)examples:union Pet of Cat, Dog, Fish | 
          
            | trait | 
                interface type ( for  defines a trait implementation)examples:trait Hash,trait Hash for String | 
          
            | impl | trait implementation (to be removed) | 
        
        
          
            | Member Definitions |  | 
          
            | fun | function | 
          
            | let | value | 
          
            | var | variable | 
        
        
          
            | Control Flow |  | 
          
            | if else | unified condition expression ( is used for pattern matching) | 
          
            | return | return specified value from current function | 
          
            | while | looping construct | 
          
            | forin | looping construct (to be replaced by streaming combinators) | 
        
        
          
            | Qualifiers |  | 
          
            | Self | type qualifier, refer to current type | 
          
            | self | value qualifier, refer to current instance | 
        
        
          
            | Values |  | 
          
            | true false | literals of the two boolean values | 
        
        
          
            | Annotations |  | 
          
            | annotation | 
                annotation definitionexamples:annotation static,annotation pub,annotation test | 
        
      
      
        Operators
        From strongest precedence to weakest.
        Unary
        
        Binary
        
          
          
            | Precedence | Operator | 
          
          
          
            | 1 | */& | 
          
            | 2 | +-|^ | 
          
            | 3 | ==!=<<=>>====!== | 
          
            | 4 | && | 
          
            | 5 | || | 
          
        
      
    Literals
    Numbers
    
1         -23         123'456
1i32      -23i32      123'456i32
1.0       -23.0       123'456.0
1.0f32    -23.0f32    123'456.0f32
    
    Booleans
    
true      false
    
    Strings
    
"abc"      ""
    
    Definitions
    Constants
    
let a = 1
a
1
a = 2
    
    Variables
    
var a = 1
a
1
a = 2 * 3
6
    
    Functions
    
fun sum(a: Int64, b: Int64): Int64 = a + b
sum(12, 23)
35
    
    Classes
    
class Person(let firstName: String, let lastName: String, var age: Int64) {
  fun fullName: String = "${self.firstName} ${self.lastName}"
}
let alice = Person("Alice", "Smith", 23)
alice.lastName
"Smith"
alice.fullName
"Alice Smith"
alice.age = 24
alice.age
24
    
    Unions
    
union Pet of Cat, Dog 
    
    Static methods
    
class Utilities {
  @static
  fun appendTest(value: String): String = "${value} test"
}
Utilities.appendTest("string")
"string test"
    
    Control Flow
    Conditions
    
let a = 2
if a == 1 { println("a is one") } else { println("a is not one") }
a is not one
fun describeFloat(float: Float64): String =
  if float
  ... === Float64.NaN { "nonumber" }
  ... .isFinite.not   { "infinity" }
  ... >= 0.0          { "positive" }
  else                { "negative" }
describeFloat(123.4)
"positive"
describeFloat(1.0/0.0)
"infinity"
    
    Loops
    while loop
    
var i = 1
while i <= 3 {
  print(i.toString)
  i = i + 1
}
"123"
    
    for loop
    
for i in List[Int64](1, 2, 3) {
  print(i.toString)
}
"123"
    
    
    
    Standard Library
    Basic Types
    Numbers
    
1 + 1
2
23.0 + 42.0 / -2.0
-44.0
23.0.toInt64 * 3
69
    
    Booleans
    
true.not
false
true && false
false
true || false
true
    
    Strings
    
let a = "foo"
"foo"
let c = a + "bar"
"foobar"
c.size
6
c.isEmpty
false
c.contains("oba")
true
c.startsWith("f")
true
    
    Option & Result Types
    Options
    
let some = Some[String]("value")
Some("value")
let none = None[String]()
None
some.isSome
true
none.isSome
false
some.contains("value")
true
some.contains("other")
false
none.contains("value")
false
    
    Results
    
let pass = Pass[String, Unit]("value")
Pass("value")
let none = Fail[Unit, String]("error")
Fail("error")
pass.isPass
true
fail.isPass
false
pass.contains("value")
true
some.contains("other")
false
fail.contains("error")
true
pass.or(none)
Pass("value")
    
    Collection Types
    Lists
    
let list = List[Int64](30, 10, 20, 40)
List(30, 10, 20, 40)
list.size
4
list(0)        
30
list(0) = 5    
List(5, 10, 20, 40)
list.first
Some(5)
list.last
Some(40)
d.removeAt(3)
List(5, 10, 20)
d.push(40)
List(5, 10, 20, 40)
    
    Sets
    
let set = HashSet[String]("hello", "goodbye")
HashSet("hello", "goodbye")
set.contains("hello")
true
set("hello")        
Some("hello")
set.insert("ciao")
None
set.remove("ciao")
Some("ciao")
    
    Maps
    
let map = HashMap[String, String](("hello", "a greeting"), ("goodbye", "a parting"))
HashMap(("hello", "a greeting"), ("goodbye", "a parting"))
map.contains("hello")
true
map.get("hello")
Some("a greeting")
map.insert("ciao", "not sure ...")
None
map.remove("ciao")
Some("not sure ...")
    
    Arrays
    
let array = Array[Int64](30, 10, 20, 40)
Array(30, 10, 20, 40)
array.size
4
array(0)        
30
array(0) = 5    
List(5, 10, 20, 40)
array.first
Some(5)
array.last
Some(40)
    
    
    
      Module System
      (Not implemented yet.)
      A module.core file defines the module's metadata, including name, version, dependencies and exported packages:
      
module com.example.lib {
  version      = "1.2.34"
  exports      = foo.bar, foo.baz, foo.qux
  dependencies = com.example.core, com.example.std
  licenses     = [ "MPL2" ]
  source       = git:code.example.com
  website      = example.com/lib
  authors      = Eve <eve@example.com>, Joe <eve@example.com>
}
      
        The module's name is a reverse domain name (possibly including a sub-domain component).
        Control of the domain is validated through DNS TXT records, RFC5785 or other sufficient means.
      The location of the module.core file defines the module root directory.
      
        A source file's package path is the combination of the module name and directories underneath the module root;
        therefore a source file of the module com.example.lib placed in foo/bar/ is inside the package com.example.lib.foo.bar