GithubHelp home page GithubHelp logo

Comments (12)

sergeyklay avatar sergeyklay commented on June 5, 2024

From @wapmorgan on February 20, 2014 19:52

Agree.

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @lstrojny on February 20, 2014 23:34

Wouldn’t proper destructuring be more desirable?

left, right = getimagesize(...}

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @nkt on February 21, 2014 0:1

@lstrojny 👍
I think there is no o need to add new keyword.

var a, b, c;
let c = [1, 2];
let a, b = c;

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @nkt on September 7, 2014 13:20

So, i've added support in parser for syntax like:

let [a, b, c] = arr;

@phalcon, @ovr, @mruz what do you think about this syntax?
I've tried to add support for

let a, b, c = arr;

But failed.

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @ovr on September 7, 2014 13:31

Vote for

let a, b, c = arr;

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @nkt on September 7, 2014 13:33

@ovr I agree with your vote, but do u know how to add this in parser?

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @ovr on September 7, 2014 13:40

@nkt
Nope 😄

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @mruz on September 7, 2014 15:5

let [a, b, c] = arr;

Is enough for me.

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @thaJeztah on September 7, 2014 15:58

I may actually prefer let [a, b, c] = arr.

It may be just me, but I would (at a glance) interpret

let a, b, c = arr

as

let a = arr; let b = arr; let c = arr;

The extra brackets would hint at 'something extra is performed here' when scanning code.

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @phalcon on September 7, 2014 19:49

I'd prefer

let (a, b, c) = arr;

We can use this syntax in the future to assign the same value to every index in the array:

let [0, 1, 2] = null;

from php-zephir-parser.

sergeyklay avatar sergeyklay commented on June 5, 2024

From @aschwin on November 26, 2014 15:52

Is there a decision already for this issue?

from php-zephir-parser.

flyingangel avatar flyingangel commented on June 5, 2024

Just want to add my bit..

Stolen from ECMAScript 6 (JS) :
http://es6-features.org/#ArrayMatching

let [item0, , item2] = arr;  // => let item0 = arr[0], item[2] = arr;

http://es6-features.org/#ObjectMatchingDeepMatching

let { key1, key2{subkey} } = someObject; // => let key1 = someObject->key1, key2 = someObject->key2->subkey;
let { key1, key2[subIndex] } = someObject; // => let key1 = someObject->key1, key2 = someObject->key2["subIndex"];

That's if you want to reinvent the wheel, then please stay as close as some standardized language.
Otherwise stick as close as PHP as possible (using parenthesis) :
let [a, , c] = arr;
Edit: bracket [] is the new standard of PHP7

from php-zephir-parser.

Related Issues (20)

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.