Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info about the unit type #401

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion docs/smart-contracts/data-types/complex-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Complex data types
authors: 'Mathias Hiron (Nomadic Labs), Sasha Aldrick (TriliTech), Tim McMackin (TriliTech)'
last_update:
date: 5 October 2023
date: 17 June 2024
---

Tezos contracts support these complex data types.
Expand All @@ -17,6 +17,15 @@ The high-level languages may implement these data types slightly differently, bu
- [Variants and Unions](#variants)
- [Lambdas](#lambdas)
- [Tickets](#tickets)
- [Unit](#unit)

This list is intended for general information for developers and is not intended to be comprehensive.
For a complete list of data types that are available, see the reference information for the language that you are using:

- Michelson: [Types](https://tezos.gitlab.io/michelson-reference/#types)
- LIGO: [Introduction](https://ligolang.org/docs/intro/introduction?lang=jsligo)
- Archetype: [Types](https://archetype-lang.org/docs/reference/types)
- SmartPy: [Overview](https://smartpy.io/manual/syntax/overview)

## Pairs {#pairs}

Expand Down Expand Up @@ -456,3 +465,28 @@ Contracts can run these operations on tickets:
- LIGO: [Tickets](https://ligolang.org/docs/reference/current-reference#tickets)
- Archetype: [create_ticket and related](https://archetype-lang.org/docs/reference/expressions/builtins/#create_ticket%28s%20:%20T,%20n%20:%20nat%29)
- SmartPy: [Tickets](https://smartpy.io/manual/syntax/tickets)

## Unit {#unit}

In Tezos, the `unit` type contains a single value that holds no information.
Smart contracts use unit values as placeholders where a variable is required but no other information is needed.
It is the input type of functions taking no input, the output type of functions producing no output, and the storage type of contracts storing no information.

For example, if a LIGO entrypoint receives no parameter, the data type of the entrypoint's parameter is `unit`:

```jsligo
@entry
const myentrypoint = (_unusedParameter: unit, store: storageType): returnType => {
// ...
}
```

Similarly, if you call this entrypoint with the Octez client and omit the `--arg` argument to pass no parameter, the client passes unit in the background.

Unit is a concept that Tezos inherits from OCaml; see [Side-Effects and the unit Type](https://ocaml.org/docs/tour-of-ocaml#side-effects-and-the-unit-type) in the OCaml documentation.

### Implementation details

- LIGO: [Unit](https://ligolang.org/docs/variants/unit/?lang=jsligo)
- Archetype: [Unit](https://archetype-lang.org/docs/reference/types/#unit)
- SmartPy: [Unit](https://smartpy.io/manual/syntax/unit)
10 changes: 9 additions & 1 deletion docs/smart-contracts/data-types/primitive-data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Primitive data types
authors: 'Mathias Hiron (Nomadic Labs), Sasha Aldrick (TriliTech), Tim McMackin (TriliTech)'
last_update:
date: 4 October 2023
date: 4 June 2024
---

Tezos contracts support these primitive data types.
Expand All @@ -16,6 +16,14 @@ The high-level languages may implement these data types slightly differently, bu
- [Timestamps](#timestamps)
- [Addresses](#addresses)

This list is intended for general information for developers and is not intended to be comprehensive.
For a complete list of data types that are available, see the reference information for the language that you are using:

- Michelson: [Types](https://tezos.gitlab.io/michelson-reference/#types)
- LIGO: [Introduction](https://ligolang.org/docs/intro/introduction?lang=jsligo)
- Archetype: [Types](https://archetype-lang.org/docs/reference/types)
- SmartPy: [Overview](https://smartpy.io/manual/syntax/overview)

## Numeric data types: `int` and `nat` {#numeric}

Integers (`int`) are whole numbers that can be positive or negative.
Expand Down
Loading