Skip to content

Commit 86b0d8d

Browse files
bobzhangryyppyeWert-Online
authored
Apply suggestions from code review
Co-authored-by: Patrick Ecker <[email protected]> Co-authored-by: Torben Ewert <[email protected]>
1 parent bb47849 commit 86b0d8d

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

_blogposts/2020-02-09-release-9-0.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ date: "2020-02-09"
44
previewImg:
55
category: compiler
66
title: ReScript 9.0
7+
badge: release
78
description: |
89
---
910

@@ -42,10 +43,10 @@ is indeed a problem for you.
4243

4344
### Zero-cost bundle size when adding ReScript
4445

45-
We keep generating code that is friendly for tree-shaking during each releases.
46-
We believe we reach a milestone that ReScript adds close to zero cost to your bundler
47-
size unlike many other programming languages compiled into JS; the bundled code is almost ReScript runtime free and
48-
the generated library code is fits the tree-shaking principle very well.
46+
With each release, we keep a close eye on generating code that is optimized for tree-shaking.
47+
We believe we reached a milestone that ReScript adds close to zero cost to your bundle-size.
48+
Unlike many other programming languages compiled into JS, the bundled code is almost ReScript runtime free and
49+
the generated library code fits the tree-shaking principle very well.
4950

5051
To demonstrate what we achieved, we made a [repo](https://github.com/bobzhang/zero-cost-rescript) so that
5152
you can try it and see how good the bundled code is.
@@ -55,7 +56,7 @@ you can try it and see how good the bundled code is.
5556

5657
We continue improving the quality of generated code in this release.
5758

58-
Take this [issue](https://github.com/rescript-lang/rescript-compiler/issues/4924) for example, for pattern match as below:
59+
Take this [issue](https://github.com/rescript-lang/rescript-compiler/issues/4924) for example:
5960

6061
```res
6162
let test = x =>
@@ -65,7 +66,7 @@ let test = x =>
6566
}
6667
```
6768

68-
It used to generate code as below:
69+
It used to generate the following code:
6970

7071
```js
7172
function test(x) {
@@ -77,19 +78,18 @@ function test(x) {
7778
}
7879

7980
```
80-
Now it is simplified as
81+
which now gets optimized to:
8182
```js
8283
function test(x){
8384
return x === 0
8485
}
8586
```
8687

87-
This is possible is that our optimizer will try to analyze several predicates and get rid of redundant predicates,
88-
more diffs could be found [here](https://github.com/rescript-lang/rescript-compiler/pull/4927/files?file-filters%5B%5D=.js).
88+
This is possible because our optimizer will try to analyze several predicates and get rid of redundant ones.
89+
More diffs can be found [here](https://github.com/rescript-lang/rescript-compiler/pull/4927/files?file-filters%5B%5D=.js).
8990

90-
Another important improvement is that we fixed the pattern match offset issue, the consequence is that
91-
magic number will not be generated
92-
for complex pattern matches any more, below is a represenative diff thanks to this clean up:
91+
Another important improvement is that we fixed the pattern match offset issue, which leads to the consequence, that magic numbers will not be generated for complex pattern matches anymore.
92+
Below is a representative diff resulting from this cleanup:
9393

9494
```diff
9595
function is_space(param){
@@ -109,7 +109,7 @@ function is_space(param){
109109

110110
We introduced two minor tweaks for the concrete syntax.
111111

112-
- guard in pattern matching is recommended to use `if` instead of `when`
112+
- It is now recommended to use `if` instead of `when` in pattern match guards
113113

114114
```res
115115
switch expr {
@@ -122,13 +122,13 @@ switch expr {
122122
- explicit nested object literal syntax
123123

124124

125-
`{"keya" : {keyb : 3 } }` used to be interpreted as `{"keya" : {"keyb" : 3 } } `, such implicity makes
126-
us not able to embed regular records inside JS object literals. Since this release,
127-
user has to write JS object literals explicitly and `{"keya" : {keyb : 3}}` will be interpreted as a regular
128-
record inside a js object literal. More discussions can be found [here](https://forum.rescript-lang.org/t/fixing-the-semantics-of-nested-objects-breaking-changes/976).
125+
`{ "keya": { keyb: 3 } }` used to be interpreted as `{ "keya": { "keyb": 3 } } `, such implicity makes
126+
us not able to embed regular records inside JS object literals. With this release,
127+
JS object literals have to be written explicitly and `{ "keya": { keyb: 3 } }` will be interpreted as a regular
128+
record inside a JS object literal. More discussions can be found [here](https://forum.rescript-lang.org/t/fixing-the-semantics-of-nested-objects-breaking-changes/976).
129129

130130

131-
Note there are some pretty interesting internal changes in this release -- for example, using WASM to replace Camlp4 and a
132-
generalized visitor pattern without using objects -- that we will discuss in a separate post
131+
There are also some pretty interesting internal changes in this release.
132+
For example, using WASM to replace Camlp4 and a generalized visitor pattern without using objects, which we will discuss in a separate post.
133133

134134
Happy Hacking! -- Hongbo Zhang

0 commit comments

Comments
 (0)