Skip to content

Commit 8071c05

Browse files
authored
doc: more tweaks that entered my head
1 parent 8dbd4b0 commit 8071c05

1 file changed

Lines changed: 18 additions & 19 deletions

File tree

doc/SPEC.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ appear within parens. In statement position, semicolons act as they do in javasc
169169
170170
12. `switch` with fallthroughs starts with `switch!`, and a phase 3 "[safe switch]" plugin will be written for "safe" switch statements, where each case breaks, and fallthrough is opt-in.
171171
172-
13. `with` will be reused for iife. The vanilla, (deprecated in strict mode anyways) `with` must be declared as `with!`
172+
13. `with` will be reused for various other features, such as iifes (`do with`), `Object.create` syntax sugar (`{ with proto = null }` and property descriptors (`with descriptor writable, not configurable, not enumerable`). The vanilla, (deprecated in strict mode anyways) `with` must be declared as `with with`
173173
174174
14. Python-ish import statements: As autocomplete systems can resolve the members to import once we have declared from which module we are importing members, it's more useful to declare the module name first
175175
```js
@@ -204,13 +204,6 @@ progress.
204204
* [ ] Automatic `const`, `extern` to assign undeclared (global) variables. [(spec)](./auto-const.md) [#18]
205205
206206
#### Phase 2 - A "Useful" language
207-
* [ ] IIFE syntax [#19]
208-
`(function(a, b, c){})(d, e, c)` ↔ `with {a: d, b: e, c}`
209-
`(function*(a, b, c){})(d, e, c)` ↔ `with* {a: d, b: e, c}`
210-
`(async function(a, b, c){})(d, e, c)` ↔ `with+ {a: d, b: e, c}`
211-
`((a, b, c) => {})(d, e, c)` ↔ `with= {a: d, b: e, c}`
212-
`((a, b, c) => (a + b + c))(d, e, c)` ↔ `with= {a: d, b: e, c} > a + b + c`
213-
214207
* [ ] `not instanceof` ([frappe])
215208
* [ ] `not in` ([frappe])
216209
* [ ] `a < b < c` ([frappe])
@@ -383,17 +376,16 @@ statements will be closed with `endswitch`, `endif`, `endwhile` `enddo`, etc.
383376
* [ ] [Const classes](http://wiki.ecmascript.org/doku.php?id=harmony:classes#const)
384377
* [ ] shorten `else if` to `elif`
385378
* [ ] Deep object properties (especially useful for destructuring): `{a.b: 1}` ↔ `{a: {b: 1}}`
386-
* [ ] `:=` for `Object.defineProperty`
387-
* `this.foo :=wce foo` ↔ `Object.defineProperty(this, 'foo', {writable: true, configurable: true, enumerable: true, value: foo})
388-
* `this.foo := foo` ↔ `Object.defineProperty(this, 'foo', {writable: false, configurable: false, enumerable: false, value: foo})
389-
* `this.foo :=+ foo` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(this, 'foo'), value: foo})
390-
* `this.foo :=-w foo` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(this, 'foo'), writable: false, value: foo})
391-
* `this.foo :=^ foo` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), 'foo'), value: foo})`
392-
* `^` is to get the prototype
393-
* also use `^*` to go up the prototype chain until a descriptor is found (would use a helper)
394-
* `this.foo :=ce {get() { return 'foo' }}` ↔ `Object.defineProperty({configurable: true, enumerable: true, get() { return 'foo' }, set: undefined})`
395-
* [ ] `::proto` for `Object.getPrototypeOf`
396-
* `this::proto` ↔ `Object.getPrototypeOf(this)`
379+
* [ ] `object.propertyName with descriptor writable, configurable, enumerable = ...` and `{with descriptor\npropertyName: ...}` for `Object.defineProperty`
380+
* `this.foo with descriptor writable, configurable, enumerable = foo` ↔ `Object.defineProperty(this, 'foo', {writable: true, configurable: true, enumerable: true, value: foo})
381+
* `this.foo with descriptor not writable, not configurable, not enumerable = foo` ↔ `Object.defineProperty(this, 'foo', {writable: false, configurable: false, enumerable: false, value: foo})
382+
* `this.foo with descriptor ... = foo` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(this, 'foo'), value: foo})
383+
* `this.foo with descriptor ..., not writable = foo` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(this, 'foo'), writable: false, value: foo})
384+
* `this.foo with descriptor ...proto` ↔ `Object.defineProperty(this, 'foo', {...Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), 'foo'), value: foo})`
385+
* also use `proto*` to go up the prototype chain until a descriptor is found (would use a helper)
386+
* `this.foo with descriptor configurable, enumerable = get() ->> 'foo'` ↔ `Object.defineProperty({configurable: true, enumerable: true, get() { return 'foo' }, set: undefined})` (tbd)
387+
* [ ] `.%proto` for `Object.getPrototypeOf`
388+
* `this.%proto` ↔ `Object.getPrototypeOf(this)`
397389
* [ ] `proto` in class declarations / expressions
398390
* ```
399391
class Foo {
@@ -406,6 +398,13 @@ statements will be closed with `endswitch`, `endif`, `endwhile` `enddo`, etc.
406398
Foo.prototype.bar = 'baz'
407399
```
408400
401+
* [ ] IIFE syntax [#19]
402+
`(function(a, b, c){})(d, e, c)` ↔ `do with {d: a, e: b, c}`
403+
`(function*(a, b, c){})(d, e, c)` ↔ `do with* {d: a, e: b, c}`
404+
`(async function(a, b, c){})(d, e, c)` ↔ `do with+ {d: a, e: b, c}`
405+
`((a, b, c) => {})(d, e, c)` ↔ `do with= {d: a, e: b, c}`
406+
`((a, b, c) => (a + b + c))(d, e, c)` ↔ `do with= {d: a, e: b, c} > a + b + c`
407+
409408
## Implementation Plan
410409
411410
* [x] Implement taco-generator to generate tacoscript (masascript) from babylon ASTs

0 commit comments

Comments
 (0)