Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Issue 1484263002: Use destructuring assignments for named parameters (#180) (Closed)

Created:
5 years ago by ochafik
Modified:
5 years ago
Reviewers:
vsm, Leaf, Jennifer Messerly
CC:
dev-compiler+reviews_dartlang.org
Base URL:
git@github.com:dart-lang/dev_compiler.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Before (for `f(a, {b, c: c_default})`): function f(a, opts) { let b = opts && 'b' in opts ? opts.b : null; let c = opts && 'c' in opts ? opts.c : c_default; ... After: function f(a, {b = null, c = c_default} = {}) { ... Note: - Still reverting to old code when any parameter clashes with reserved JS names (see discussion in https://github.com/dart-lang/dev_compiler/issues/392) - When a parameter clashes with a Object.prototype property, using a clean default opts value (Object.create(null)). - Passing opts through in aliased constructors, both for speed/concision and correctness (since default param value semantic is weird there) BUG= R=jmesserly@google.com Committed: https://github.com/dart-lang/dev_compiler/commit/c9d909ced98dea2aefe20322a59d18fbab2d93b2

Patch Set 1 #

Patch Set 2 : Destructure function params directly (no more opts in most cases) #

Total comments: 30

Patch Set 3 : Use Object.create(null) and simplify destructuring logic #

Patch Set 4 : test Object.create(null) behaviour in codegen #

Patch Set 5 : Rename Destructuring to BindingPattern + other nits #

Patch Set 6 : Drop out of destructuring when names clash with js reserved names #

Patch Set 7 : Rebased + squashed in 1 commit #

Total comments: 5

Patch Set 8 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+471 lines, -438 lines) Patch
M bin/devrun.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M lib/runtime/dart/_interceptors.js View 1 2 3 4 5 6 3 chunks +4 lines, -9 lines 0 comments Download
M lib/runtime/dart/_internal.js View 1 2 3 4 5 6 6 chunks +8 lines, -16 lines 0 comments Download
M lib/runtime/dart/_isolate_helper.js View 1 2 3 4 5 6 3 chunks +3 lines, -8 lines 0 comments Download
M lib/runtime/dart/_js_helper.js View 1 2 3 4 5 6 2 chunks +2 lines, -5 lines 0 comments Download
M lib/runtime/dart/async.js View 1 2 3 4 5 6 30 chunks +34 lines, -119 lines 0 comments Download
M lib/runtime/dart/collection.js View 1 2 3 4 5 6 20 chunks +20 lines, -53 lines 0 comments Download
M lib/runtime/dart/convert.js View 1 2 3 4 5 6 9 chunks +13 lines, -27 lines 0 comments Download
M lib/runtime/dart/core.js View 1 2 3 4 5 6 16 chunks +18 lines, -61 lines 0 comments Download
M lib/runtime/dart/isolate.js View 1 2 3 4 5 6 3 chunks +3 lines, -8 lines 0 comments Download
M lib/runtime/dart/js.js View 1 2 3 4 5 6 1 chunk +1 line, -2 lines 0 comments Download
M lib/runtime/dart/mirrors.js View 1 chunk +1 line, -5 lines 0 comments Download
M lib/src/closure/closure_annotator.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M lib/src/codegen/js_codegen.dart View 1 2 3 4 5 6 7 5 chunks +95 lines, -25 lines 0 comments Download
M lib/src/js/builder.dart View 1 2 3 4 5 6 4 chunks +92 lines, -39 lines 0 comments Download
M lib/src/js/nodes.dart View 1 2 3 4 5 6 7 chunks +71 lines, -6 lines 0 comments Download
M lib/src/js/printer.dart View 1 2 3 4 5 6 2 chunks +45 lines, -4 lines 0 comments Download
M lib/src/js/template.dart View 1 2 3 4 5 6 7 2 chunks +33 lines, -2 lines 0 comments Download
M test/codegen/expect/closure.js View 1 2 3 4 5 6 1 chunk +1 line, -4 lines 0 comments Download
M test/codegen/expect/collection/algorithms.js View 1 2 3 4 5 6 3 chunks +3 lines, -10 lines 0 comments Download
M test/codegen/expect/collection/src/canonicalized_map.js View 1 2 3 4 5 6 1 chunk +2 lines, -4 lines 0 comments Download
M test/codegen/expect/collection/wrappers.js View 1 2 3 4 5 6 3 chunks +3 lines, -6 lines 0 comments Download
M test/codegen/expect/constructors.js View 1 2 3 4 5 6 1 chunk +1 line, -2 lines 0 comments Download
M test/codegen/expect/methods.js View 1 2 3 4 5 6 2 chunks +9 lines, -6 lines 0 comments Download
M test/codegen/expect/temps.js View 1 2 3 4 5 6 1 chunk +1 line, -2 lines 0 comments Download
M test/codegen/expect/unittest.js View 1 2 3 4 5 6 2 chunks +2 lines, -6 lines 0 comments Download
M test/codegen/expect/unittest/unittest.js View 1 2 3 4 5 6 2 chunks +2 lines, -6 lines 0 comments Download
M test/codegen/methods.dart View 1 2 3 4 5 1 chunk +2 lines, -3 lines 0 comments Download

Messages

Total messages: 13 (6 generated)
ochafik
Sorry, looks like I created a new issue :-S Anyway, not 100% happy with the ...
5 years ago (2015-12-01 00:46:27 UTC) #4
Jennifer Messerly
haven't looked at the code yet but... > Note: still reverting to old code when ...
5 years ago (2015-12-01 01:06:37 UTC) #6
Jennifer Messerly
A few comments. But this is looking really nice! https://codereview.chromium.org/1484263002/diff/20001/lib/src/codegen/js_codegen.dart File lib/src/codegen/js_codegen.dart (right): https://codereview.chromium.org/1484263002/diff/20001/lib/src/codegen/js_codegen.dart#newcode930 lib/src/codegen/js_codegen.dart:930: ...
5 years ago (2015-12-01 02:10:28 UTC) #7
ochafik
Thanks a lot John! https://codereview.chromium.org/1484263002/diff/20001/lib/src/codegen/js_codegen.dart File lib/src/codegen/js_codegen.dart (right): https://codereview.chromium.org/1484263002/diff/20001/lib/src/codegen/js_codegen.dart#newcode930 lib/src/codegen/js_codegen.dart:930: node.parameters, allowDestructuring: false); On 2015/12/01 ...
5 years ago (2015-12-02 20:05:47 UTC) #9
Jennifer Messerly
LGTM! https://codereview.chromium.org/1484263002/diff/110001/lib/src/codegen/js_codegen.dart File lib/src/codegen/js_codegen.dart (right): https://codereview.chromium.org/1484263002/diff/110001/lib/src/codegen/js_codegen.dart#newcode1998 lib/src/codegen/js_codegen.dart:1998: {bool allowDestructuring}) { default to true? https://codereview.chromium.org/1484263002/diff/110001/lib/src/js/template.dart File ...
5 years ago (2015-12-02 20:41:09 UTC) #10
ochafik
Thanks! https://codereview.chromium.org/1484263002/diff/110001/lib/src/codegen/js_codegen.dart File lib/src/codegen/js_codegen.dart (right): https://codereview.chromium.org/1484263002/diff/110001/lib/src/codegen/js_codegen.dart#newcode1998 lib/src/codegen/js_codegen.dart:1998: {bool allowDestructuring}) { On 2015/12/02 20:41:09, John Messerly ...
5 years ago (2015-12-02 21:56:08 UTC) #11
ochafik
5 years ago (2015-12-02 21:56:40 UTC) #13
Message was sent while issue was closed.
Committed patchset #8 (id:130001) manually as
c9d909ced98dea2aefe20322a59d18fbab2d93b2 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698