Categories
  Encyclosphere.org ENCYCLOREADER
  supported by EncyclosphereKSF

FunC

From HandWiki - Reading time: 2 min

Short description: Programming Language


FunC is a domain-specific, C-like, statically typed programming language used for smart contract development on the TON blockchain. The language is designed to be similar to C. Programs written in FunC are compiled into Fift assembler code which generates bytecode for the TON Virtual Machine (TVM). The bytecode can be used to create smart contracts on the blockchain or run on a local instance of the TVM.

FunC has a number of built-in types for data storage and manipulation, including:

  • int: for 257-bit signed integers, with overflow checks enabled by default.
  • cell: the fundamental unit of data storage in the TON blockchain, containing up to 1023 bits of arbitrary data and up to four references to other cells.
  • slice: a way to access the data bits and references of a cell.
  • builder: used to construct and finalize new cells.
  • tuple: an ordered collection of up to 255 components with arbitrary value types.
  • cont: used for controlling the flow of program execution in the TVM.

A notable feature of FunC is that it does not have a dedicated boolean type.[1] Instead, booleans are represented as integers with non-zero values representing true and zero representing false. Logical operations are done using bitwise operations. The language also has support for null values, which are represented using TVM type Null.

FunC also has support for type inference, allowing for "holes" in types to be filled during type checking. Complex types can be composed using functional and tensor types. Values of functional type A->B are represented as continuations internally and represent functions with a specified domain and codomain. Tensor types are used to represent ordered collections of values, which can occupy more than one TVM stack entry.

Overall, FunC aims to provide a familiar programming experience for developers while providing a strong type system and low-level control over the TVM, making it well-suited for developing smart contracts on TON blockchain.

References


Licensed under CC BY-SA 3.0 | Source: https://handwiki.org/wiki/FunC
16 views | Status: cached on August 25 2024 09:51:48
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF