Desugar destructuring via builtin
This commit is contained in:
parent
64c9ca08d9
commit
53928bdeb5
1 changed files with 13 additions and 32 deletions
45
README.md
45
README.md
|
|
@ -84,42 +84,23 @@ In the following sections,
|
||||||
|
|
||||||
### Table destructuring
|
### Table destructuring
|
||||||
|
|
||||||
`{ a, b, foo: c } = d` is converted to
|
`{ foo, bar: baz } = a` is converted to
|
||||||
```
|
```
|
||||||
'{
|
'destructure{
|
||||||
local expr = 'arg()[0],
|
'scope(),
|
||||||
local scope = 'arg()[1],
|
{ "foo", bar: "baz" },
|
||||||
scope.a = expr[0],
|
a,
|
||||||
scope.b = expr[1],
|
}
|
||||||
scope.c = expr.foo,
|
|
||||||
}{d, 'scope()}
|
|
||||||
```
|
|
||||||
which is approximately equal to
|
|
||||||
```
|
|
||||||
(function{expr, scope} '{
|
|
||||||
scope.a = expr[0],
|
|
||||||
scope.b = expr[1],
|
|
||||||
scope.c = expr.foo,
|
|
||||||
}){d, 'scope()}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`local { a, b, foo: c } = d` is converted to
|
`local { foo, bar: baz } = a` is converted to
|
||||||
```
|
```
|
||||||
'{
|
'destructure{
|
||||||
local expr = 'arg()[0],
|
'scope(),
|
||||||
local scope = 'arg()[1],
|
{ "foo", bar: "baz" },
|
||||||
'setraw(scope, "a", expr[0]),
|
a,
|
||||||
'setraw(scope, "b", expr[1]),
|
local: true,
|
||||||
'setraw(scope, "c", expr.foo),
|
}
|
||||||
}{d, 'scope()}
|
|
||||||
```
|
|
||||||
which is approximately equal to
|
|
||||||
```
|
|
||||||
(function{expr, scope} '{
|
|
||||||
'setraw(scope, "a", expr[0]),
|
|
||||||
'setraw(scope, "b", expr[1]),
|
|
||||||
'setraw(scope, "c", expr.foo),
|
|
||||||
}){d, 'scope()}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Function definitions
|
### Function definitions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue