Giter VIP home page Giter VIP logo

Comments (3)

 avatar commented on July 20, 2024

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]opt

So 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.

ehpc avatar ehpc commented on July 20, 2024

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.

 avatar commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.