You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let current_count: u64 = accumulator.get_or_use(0u8, 0u64);
70
+
let new_count: u64 = current_count + 1u64;
71
+
accumulator.set(0u8, new_count);
65
72
73
+
}
74
+
```
66
75
67
-
Sounds good to me. Is this just for readability/cleanliness, or because of maximum file size?
76
+
```leo title="Async Block:"
77
+
mapping accumulator: u8 => u64;
68
78
69
-
Strictly readability/cleanliness. No impact on size since modules are flattened into a single program eventually anyways. I just think this makes reading a program much more pleasant.
let current_count: u64 = accumulator.get_or_use(0u8, 0u64);
82
+
let new_count: u64 = current_count + 1u64;
83
+
accumulator.set(0u8, new_count);
84
+
}
85
+
return f;
86
+
}
87
+
```
70
88
71
-
Move all consts to a `constants.leo` module
72
-
Move all inlines to a `utils.leo` module
73
-
Consider moving some `struct`s to modules but that may not make sense in the general case.
74
89
75
-
The goal is to only have the interface of the program in `main.leo`. Every function I see should correspond to something I can call from an external context such as another program.
90
+
### Modules
76
91
92
+
For maximal code cleanliness and readability, take full advantage of Leo's module system:
93
+
```
94
+
src
95
+
βββ constants.leo
96
+
βββ utils.leo
97
+
βββ structs.leo
98
+
βββ main.leo
99
+
```
100
+
With the above structure, consider the following:
101
+
- Move all `const`s to the `constants.leo` module
102
+
- Move all `inline` functions to the `utils.leo` module
103
+
- Move some `struct`s to modules (but this may not make sense in the general case)
77
104
105
+
The goal is to only have the interface of the program in `main.leo`. Every function should correspond to something than can be called from an external context such as another program. Note that there is no impact on final program size since modules are flattened into a single program eventually anyways.
0 commit comments