2020-01-02 09:30:50 +04:00
|
|
|
---
|
|
|
|
id: include
|
|
|
|
title: Including Other Contracts
|
|
|
|
---
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
import Syntax from '@theme/Syntax';
|
|
|
|
|
2020-02-12 01:29:12 +04:00
|
|
|
Let us say that we have a contract that is getting a too large. If it
|
|
|
|
has a modular structure, you might find it useful to use the
|
|
|
|
`#include` statement to split the contract up over multiple files.
|
2020-01-02 09:30:50 +04:00
|
|
|
|
2020-02-12 01:29:12 +04:00
|
|
|
You take the code that you want to include and put it in a separate
|
|
|
|
file, for example `included.ligo`:
|
2020-01-02 09:30:50 +04:00
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```pascaligo
|
|
|
|
|
|
|
|
// Demonstrate PascaLIGO inclusion statements, see includer.ligo
|
|
|
|
|
|
|
|
const foo : int = 144
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```cameligo
|
|
|
|
// Demonstrate CameLIGO inclusion statements, see includer.mligo
|
|
|
|
|
|
|
|
let foo : int = 144
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```reasonligo
|
|
|
|
// Demonstrate ReasonLIGO inclusion statements, see includer.religo
|
|
|
|
|
|
|
|
let foo : int = 144;
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
|
|
|
|
|
|
|
|
And then you can include this code using the `#include` statement like so:
|
|
|
|
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
|
|
|
|
<Syntax syntax="pascaligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```pascaligo
|
|
|
|
#include "included.ligo"
|
|
|
|
|
|
|
|
const bar : int = foo
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="cameligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```cameligo
|
|
|
|
#include "included.mligo"
|
|
|
|
|
|
|
|
let bar : int = foo
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
<Syntax syntax="reasonligo">
|
|
|
|
|
2020-01-02 09:30:50 +04:00
|
|
|
```reasonligo
|
|
|
|
#include "included.religo"
|
|
|
|
|
|
|
|
let bar : int = foo;
|
|
|
|
```
|
|
|
|
|
2020-03-04 17:19:00 +04:00
|
|
|
</Syntax>
|
|
|
|
|