+37
CHANGELOG.md
+37
CHANGELOG.md
···
159
159
160
160
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
161
161
162
+
- Code generators now reuse existing variables when possible for the record
163
+
update syntax, reducing the size of the generated code and number of
164
+
variables defined for both Erlang and JavaScript.
165
+
166
+
```gleam
167
+
pub fn main() -> Nil {
168
+
let trainer = Trainer(name: "Ash", badges: 0)
169
+
battle(Wobble(..trainer, badges: 1))
170
+
}
171
+
```
172
+
173
+
Previously this Gleam code would generate this Erlang code:
174
+
175
+
```erlang
176
+
-spec main() -> nil.
177
+
main() ->
178
+
Trainer = {trainer, 0, <<"Ash"/utf8>>},
179
+
battle(
180
+
begin
181
+
_record = Trainer,
182
+
{trainer, 1, erlang:element(3, _record)}
183
+
end
184
+
).
185
+
```
186
+
187
+
188
+
Now this code will be generated instead:
189
+
190
+
```erlang
191
+
-spec main() -> nil.
192
+
main() ->
193
+
Trainer = {trainer, 0, <<"Ash"/utf8>>},
194
+
battle({trainer, 1, erlang:element(3, Trainer)}).
195
+
```
196
+
197
+
([Louis Pilfold](https://github.com/lpil))
198
+
162
199
### Build tool
163
200
164
201
- `gleam update`, `gleam deps update`, and `gleam deps download` will now print