Comments (3)
The word "rename" might not be the best, I agree. Reassign or alike might
be better fits.
Am 27.07.2015 8:22 nachm. schrieb "Eugene Maslovich" <
[email protected]>:
I want to disagree with you about renaming kata
http://tddbin.com/#?kata=es6/language/destructuring/rename. I think there
is no renaming. Let me explain my point of view.We have this code [1]:
const {x: y} = {x: 1};
assert.equal(y, 1);It is equivalent to [2]:
const {x: x} = {x: 1};
assert.equal(x, 1);Which is in turn equivalent to [3]:
const {x} = {x: 1};
assert.equal(x, 1);So in snippet 3 we have a case of shorthanding the destructuring
assignment. Basically it means: destructure an object which has a property
by the name "x" and assign it's value to a variable named "x". The explicit
version of this is in snippet 2.
Snippet 1 on the other hand tells: destructure an object which has a
property by the name "x" and assign it's value to a variable named "y".
There is no renaming of any kind, just a classical destructuring.We can see this in specs:
http://www.ecma-international.org/ecma-262/6.0/#sec-destructuring-assignment.
The grammar reads as follows:
AssignmentProperty[Yield] :
IdentifierReference[?Yield] Initializer[In,?Yield]opt
PropertyName : AssignmentElement[?Yield]
AssignmentElement[Yield] :
DestructuringAssignmentTarget[?Yield] Initializer[In,?Yield]optSo we have a "PropertyName" and an "AssignmentElement", which is no more
than a "DestructuringAssignmentTarget" with an optional "Initializer".
In out example:const {
x: // PropertyName
y // DestructuringAssignmentTarget
} = {x: 1};or even:
const {
x: // PropertyName
y // DestructuringAssignmentTarget
=42 // Initializer
} = {y: 23};—
Reply to this email directly or view it on GitHub
#15.
from katas.
Well I think reassign doesn't cut it either. We can see how destructuring is described in Clojure for example: http://clojure.org/special_forms, especially map binding destructuring. So basically the thing to the left of assignment operator in js code is binding form and the thing to the right is initialization expression. There is no reassignment, there is only an "assignment" of symbols from the left part of expression (would be variables) to parts of an object from the right part. So symbol "y" is bound to value of a property "x". No renaming, no reassignment, just plain straight name binding. Hope this makes sense.
from katas.
Right assigning would be the right thing then. Just don't know how to make
it work so it doesn't break bc for all links etc.
Am 27.07.2015 9:34 nachm. schrieb "Eugene Maslovich" <
[email protected]>:
Well I think reassign doesn't cut it either. We can see how destructuring
is described in Clojure for example: http://clojure.org/special_forms,
especially map binding destructuring. So basically the thing to the left of
assignment operator in js code is binding form and the thing to the right
is initialization expression. There is no reassignment, there is only an
"assignment" of symbols from the left part of expression (would be
variables) to parts of an object from the right part. So symbol "y" is
bound to value of a property "x". No renaming, no reassignment, just plain
straight name binding. Hope this makes sense.—
Reply to this email directly or view it on GitHub
#15 (comment).
from katas.
Related Issues (19)
- Kata "Destructuring":"rename":"rename object key" is green right away HOT 2
- Kata 34: Symbol HOT 1
- Shorter version of kata 51 "generator:yield" test case #2 HOT 8
- Rest in destructuring HOT 11
- Misprint in the test HOT 1
- Incorrect values in arrows kata HOT 3
- ES6 Kata 69 "Reflect - defineProperty" kata needs updating HOT 4
- Solution for Kata 40 freezes the browser tab HOT 1
- Kata 76 - Promise Creation - doesn't wrok in TDDbin HOT 5
- Object.is
- Kata 28 - TDDbin add indentation to super.constructor HOT 2
- Is it OK to move CHANGELOG.md into separate issues? HOT 2
- Two tests in Promises already green when starting
- Build issue HOT 2
- Question about what to fix in parseInt HOT 3
- template repository to fork and learn HOT 8
- `class extends null` is broken by ECMAScript HOT 7
- xdomain vendoring HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from katas.