kc3-lang/kc3/doc/1_KC3/1.1_Introduction.en.md

Download

1.1 Introduction

KC3 is currently a programming language project, inspired by C, Elixir and Common Lisp. It could be described as C with Elixir modules, pattern matching, and a semantic object system. The idea is to plug modules, closures, pattern matching, a graph database and metaprogramming into C99 with an extremely small set of dependencies.

Supported operating systems (additionnal dependencies) :

Supported architectures :

1.1.1 Modules

Everything in KC3 is in a module. A module is a namespace, and is named with a symbol starting with a uppercase character. For instance Sym and Str are valid module names.

Use defmodule to define a module. Example :

defmodule Test do
  def one = 1
  def double = fn (x) { x * 2 }
  def add = cfn Tag "tag_add" (Tag, Tag, Result)
end

Each module can define a type and a module name can also be a type name if the corresponding module defines a type.

Use defstruct to define a struct type in a module. The struct will have the same name as the module. Example :

ikc3> defmodule Test do
ikc3>   defstruct [x: (F32) 0.0,
ikc3>              y: (F32) 0.0]
ikc3> end
ikc3> a = %Test{}
%Test{x: (F32) 0.0,
      y: (F32) 0.0}
ikc3> a.x
(F32) 0.0
ikc3> a.y
(F32) 0.0

The module can also include definitions for constants or functions for operating on the module type or other types.

The default module is KC3, which is defined as facts (triples) in lib/kc3/0.1/kc3.facts.

1.1.2 Data types

Basic data types in KC3 are :


Top : KC3 documentation

Previous : 1 KC3

Next : 1.2 Integer


Source

Download