Re: Can't do push in forEach

2015-05-14 Thread Erik Arvidsson
Still, the callback for forEach is called with 3 arguments; value, index and the array. This is clearly documented in the spec and mdn and other resources. On Thu, May 14, 2015, 10:42 Garrett Smith dhtmlkitc...@gmail.com wrote: On 5/14/15, Emanuel Allen emanuelal...@hotmail.com wrote:

Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Surprise that I can't do arr1.forEeach(arr2.push); Will throw an error. Using bind as: push = arr2.bind(push); arr1.forEeach(push); Works... And not work. Seem to push individual elements and after every second element, it'll push the hold array.. And after and before each index that hold

Re: Can't do push in forEach

2015-05-14 Thread Garrett Smith
On 5/14/15, Emanuel Allen emanuelal...@hotmail.com wrote: Surprise that I can't do arr1.forEeach(arr2.push); Check that line more carefully. Will throw an error. Using bind as: push = arr2.bind(push); Arrays don't have a bind method. -- Garrett @xkit ChordCycles.com garretts.github.io

Re: About generators

2015-05-14 Thread Jeremy Martin
Hey (author of suspend here): this post was an earlier attempt I had an explaining some of the concepts involved: http://devsmash.com/blog/whats-the-big-deal-with-generators It covers some of the basics, like, what iterators are, how generators relate to iterators, how generators enable suspended

Re: Reflect.type

2015-05-14 Thread Andrea Giammarchi
FWIW, I think whatever contains type in modern JS should consider `int32`, `float64`, and all TypedArrays plus it would be awesome to have a way to define own types. In any case, if your idea will be implemented, I think it should have named Symbols for debugging sake. ```js Symbol('undefined'),

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
It should allow for: arr.forEach(arr.push.only(1));//only return a function limiting the number of arguments pass to it... But I guess this work too: arr.forEach(e=arr.push(e)); But my goal was to just: arr.forEach(arr.push);//will not work So this style I favorite since I want to avoid

let function

2015-05-14 Thread Alexander Jones
Propose adding support for let function foo() {}; which would have the equivalence of: let foo = function foo() {}; The idea is to support the normal scoping of let, but without forcing you to repeat yourself when naming the function, whilst still having the function's name property be

RE: let function

2015-05-14 Thread Domenic Denicola
They can, in fact, be scoped in a for loop. From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Andrea Giammarchi Sent: Thursday, May 14, 2015 14:53 To: Kevin Smith Cc: es-discuss@mozilla.org Subject: Re: let function I guess 'cause that cannot be scoped, let's say in a for

Re: Can't do push in forEach

2015-05-14 Thread Andrea Giammarchi
So this style I favorite since I want to avoid creating another function: this is like believing that `fn.bind()` won't create a different object/function ... right? Or you want to lock that function to receive one forever until you unlock it? That's the only way you could mutate the function

Re: let function

2015-05-14 Thread Kevin Smith
Why not use a function declaration instead? On Thu, May 14, 2015 at 2:37 PM Alexander Jones a...@weej.com wrote: Propose adding support for let function foo() {}; which would have the equivalence of: let foo = function foo() {}; The idea is to support the normal scoping of let,

Re: Can't do push in forEach

2015-05-14 Thread Allen Wirfs-Brock
On May 14, 2015, at 8:19 AM, Emanuel Allen wrote: Oh yes that is correct since push will push in elements separated by commas... Still my original problem is that I can't simply do arr.push(arr2.push); but it doesn't matter since it'll also push the three parameters into the array as

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
That would be great to have an only method on Function.prototype.only It can take one to three parameters as arguments: -Only with using the first argument: SomeFunction.only(1); only allow the first argument in. It target the place holder so: fn.only(2) allow the two most left argument in.

Re: About generators

2015-05-14 Thread Jason Orendorff
On Thu, May 14, 2015 at 2:05 AM, mohan.radhakrish...@cognizant.com wrote: Thanks. What is the underlying concurrency framework when we use generators for concurrent workloads ? Does it depend on the particular VM ? Generators aren't for concurrency. When a generator runs, it runs in the same

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Meant the method of the array not the array m itself: array[pushunshift].bind(array); Sent from my iPhone On May 14, 2015, at 10:42 AM, Garrett Smith dhtmlkitc...@gmail.com wrote: On 5/14/15, Emanuel Allen emanuelal...@hotmail.com wrote: Surprise that I can't do arr1.forEeach(arr2.push);

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Oh yes that is correct since push will push in elements separated by commas... Still my original problem is that I can't simply do arr.push(arr2.push); but it doesn't matter since it'll also push the three parameters into the array as well. Sent from my iPhone On May 14, 2015, at 10:49 AM,

Reflect.type

2015-05-14 Thread Alexander Jones
Just an idea, if it doesn't already exist somewhere. Reflect.type(x) would match the spec's Type(x) function, in that it would basically be a better, more convenient typeof, i.e. Reflect.types = { undefined: Symbol(), null: Symbol(), boolean: Symbol(), string:

RE: let function

2015-05-14 Thread Ron Buckton
I proposed something similar to this among the folks investigating decorators for ES7: https://github.com/jonathandturner/decorators/issues/17 In this case, it was for a `const function`, as a means to allow a decorator on a function declaration, as adding the `const` (or `let`) would

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
So this style I favorite since I want to avoid creating another function: this is like believing that `fn.bind()` won't create a different object/function ... right? I like how you pick out my word (like a certain gender group would) even know I re correct my self right after that with:

Re: let function

2015-05-14 Thread Bergi
Alexander Jones schrieb: On Thursday, May 14, 2015, Domenic Denicola d...@domenic.me wrote: They can, in fact, be scoped in a for loop. That's not what I see, in strict mode at least, which I assume most people consider de facto by now! From V8: SyntaxError: In strict mode code,

Re: let function

2015-05-14 Thread Alexander Jones
Ah, thanks for explaining! What about the Temporal Dead Zone of let, or const binding semantics, for those of us who are obsessive enough to desire that kind of thing everywhere? On Thursday, May 14, 2015, Bergi a.d.be...@web.de wrote: Alexander Jones schrieb: On Thursday, May 14, 2015,

Re: let function

2015-05-14 Thread Alexander Jones
Good points. All the more reason to throw out declarations as statements in favour of let/const/var, which we all have to understand well anyway, for other types of variable. Cheers On Thursday, May 14, 2015, Garrett Smith dhtmlkitc...@gmail.com wrote: On 5/14/15, Alexander Jones a...@weej.com

Re: Can't do push in forEach

2015-05-14 Thread Jordan Harband
`arr.push` is `Array.prototype.push`. If you want it bound to `arr`, you'd need to use `.bind` or actually call it with `arr.push()`. `arr.push.only` would lose the context of the arr, so that's not an option for your use case as described. Arrow functions (with Array#map perhaps?) are your best

RE: let function

2015-05-14 Thread Domenic Denicola
Not all browsers have implemented the spec yet. But you should read the spec before proposing changes to it! From: Alexander Jones [mailto:a...@weej.com] Sent: Thursday, May 14, 2015 15:16 To: Domenic Denicola Cc: Andrea Giammarchi; Kevin Smith; es-discuss@mozilla.org Subject: Re: let function

Re: function.next meta-property proposal

2015-05-14 Thread Alexander Jones
In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems like a reasonable behaviour to me, without introducing too much weirdness. TypeError: can't send non-None value to a just-started generator On Thursday, May 14, 2015, Allen

Re: let function

2015-05-14 Thread Andrea Giammarchi
like I've replied to Domenic, you need to transpile if you want function declaration block-scoped backward compatible and all other ES6 goodies. babeljs would be my pick: https://babeljs.io Best Regards On Thu, May 14, 2015 at 8:40 PM, Alexander Jones a...@weej.com wrote: Ah, thanks for

`const` function arguments and object property shorthand

2015-05-14 Thread Alexander Jones
Propose: function(const foo, const bar) { } { const foo: bar } Such that the names foo and bar are not assignable in the function body or as an object property - such assignment would ideally have identical behaviour to assigning to a const variable, i.e. a SyntaxError,

Re: let function

2015-05-14 Thread Garrett Smith
On 5/14/15, Alexander Jones a...@weej.com wrote: Ah, thanks for explaining! What about the Temporal Dead Zone of let, or const binding semantics, for those of us who are obsessive enough to desire that kind of thing everywhere? Let a constructive discussion about this proposal take place. The

Re: Can't do push in forEach

2015-05-14 Thread Andrea Giammarchi
(like a certain gender group would) what is this ? Anyway, you had your answers, I guess. Take care On Thu, May 14, 2015 at 8:11 PM, Emanuel Allen emanuelal...@hotmail.com wrote: So this style I favorite since I want to avoid creating another function: this is like believing that

Re: let function

2015-05-14 Thread Alexander Jones
That's not what I see, in strict mode at least, which I assume most people consider de facto by now! From V8: SyntaxError: In strict mode code, functions can only be declared at top level or immediately within another function. Similar error from SpiderMonkey. On Thursday, May 14, 2015,

Re: let function

2015-05-14 Thread Alexander Jones
Yep, that's the reason. It's invalid with 'use strict' to put function declarations inside an if or for block, and function declarations get hoisted. Alternatively, as we have object shorthand notation, e.g. { foo() {}, } that does not require the function keyword, yet still

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Yes I was thinking that too. But if it just default to binding to the object on which the method is being call on it self since this is technically an partial application function. Or it can have a forth optional parameters to allow what object should be this. Or can simple just use bind call

Re: let function

2015-05-14 Thread joe
Hay, I've not read all of the spec, and I've implemented much of it. :P Joe On Thu, May 14, 2015 at 12:16 PM, Domenic Denicola d...@domenic.me wrote: Not all browsers have implemented the spec yet. But you should read the spec before proposing changes to it! *From:* Alexander Jones

Re: let function

2015-05-14 Thread Andrea Giammarchi
not, in fact, in a backward compatible way, unless transpiled. On Thu, May 14, 2015 at 8:00 PM, Domenic Denicola d...@domenic.me wrote: They can, in fact, be scoped in a for loop. *From:* es-discuss [mailto:es-discuss-boun...@mozilla.org] *On Behalf Of *Andrea Giammarchi *Sent:*

Re: let function

2015-05-14 Thread Michael Haufe
As Perlis has said: too much syntactic sugar causes cancer of the semicolon. IMO, this is not much of a win given what is now available, especially with arrow functions and shorthand method definitions On Thu, May 14, 2015 at 1:37 PM, Alexander Jones a...@weej.com wrote: Propose adding support

Re: let function

2015-05-14 Thread André Bargull
On May 14, 2015, at 12:40 PM, Alexander Jones wrote: Ah, thanks for explaining! What about the Temporal Dead Zone of let, or const binding semantics, for those of us who are obsessive enough to desire that kind of thing everywhere? ES6 specifies that function declarations are allowed in

Re: function.next meta-property proposal

2015-05-14 Thread Andrea Giammarchi
Alexander ES6 is out as it is, here the proposal is to make reachable that argument because indeed, since about ever, in JS you can ignore arguments, but you can also always reach them through the argument object. When it comes to generators, arguments object would be a misleading place to give

Re: let function

2015-05-14 Thread Allen Wirfs-Brock
On May 14, 2015, at 3:39 PM, André Bargull wrote: On May 14, 2015, at 12:40 PM, Alexander Jones wrote: Ah, thanks for explaining! What about the Temporal Dead Zone of let, or const binding semantics, for those of us who are obsessive enough to desire that kind of thing everywhere?

Re: let function

2015-05-14 Thread Kevin Smith
Good points. All the more reason to throw out declarations as statements in favour of let/const/var, which we all have to understand well anyway, for other types of variable. Declarations aren't going anywhere, and there is zero interest in deprecating them. You might want to spend a bit

Re: Can't do push in forEach

2015-05-14 Thread Michael Haufe
...but you can do this: [].push.apply(arr1,arr2); On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen emanuelal...@hotmail.com wrote: Surprise that I can't do arr1.forEeach(arr2.push); Will throw an error. Using bind as: push = arr2.bind(push); arr1.forEeach(push); Works... And not work.

Re: function.next meta-property proposal

2015-05-14 Thread Kevin Smith
Alexander, ES6 generators accept any arbitrary values for the first invocation of next. That's not going to change. On Thu, May 14, 2015 at 3:49 PM Alexander Jones a...@weej.com wrote: In Python, sending a value other than `None` into the first invocation of `send` raises an error. That seems

Re: let function

2015-05-14 Thread Alexander Jones
When I said throw out, I didn't mean deprecate. I meant like 'let is the new var' - an entirely optional programming choice. I'm not sure what warrants that kind of hostility, but I knew enough of the spec to know that 'use strict' prohibited function declarations as statements, and that let and

Re: let function

2015-05-14 Thread Allen Wirfs-Brock
On May 14, 2015, at 12:40 PM, Alexander Jones wrote: Ah, thanks for explaining! What about the Temporal Dead Zone of let, or const binding semantics, for those of us who are obsessive enough to desire that kind of thing everywhere? ES6 specifies that function declarations are allowed in

Re: function.next meta-property proposal

2015-05-14 Thread Andrea Giammarchi
actually, that won't work ... so yeah, that pattern is somehow compromise, arguments is used to indeed initialize the generator, no way to put first value in ... oh well On Thu, May 14, 2015 at 11:44 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: Alexander ES6 is out as it is, here

Re: function.next meta-property proposal

2015-05-14 Thread Alexander Jones
I don't think that's a good enough reason by itself to make this observable. You can pass arbitrary numbers of arguments to any function in JS, and they are generally ignored. On Thursday, 14 May 2015, Kevin Smith zenpars...@gmail.com wrote: Alexander, ES6 generators accept any arbitrary values

Re: let function

2015-05-14 Thread Alexander Jones
Thanks for sharing. Are there any known, viable alternatives for decorators? On 14 May 2015 at 21:55, Ron Buckton ron.buck...@microsoft.com wrote: I proposed something similar to this among the folks investigating decorators for ES7: https://github.com/jonathandturner/decorators/issues/17

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
kudos to you sir or ma'am, It work! var arr = [9,8,7,'a','b','c'], arr2 = []; [].push.apply(arr2,arr); arr2;// [9,8,7,'a','b','c'] JS4L On May 14, 2015, at 6:40 PM, Michael Haufe t...@thenewobjective.com wrote: ...but you can do this: [].push.apply(arr1,arr2); On Thu, May 14, 2015

Re: let function

2015-05-14 Thread Garrett Smith
On 5/14/15, Kevin Smith zenpars...@gmail.com wrote: Good points. All the more reason to throw out declarations as statements in favour of let/const/var, which we all have to understand well anyway, for other types of variable. Declarations aren't going anywhere, Getting rid of

Re: Reflect.type

2015-05-14 Thread Alexander Jones
I'm sure there will evolve some other nomenclature for that in due course. From http://www.slideshare.net/BrendanEich/value-objects2 it sounds as if it would be reasonable to define `Type(x)` to be `Value`, and thus `Reflect.type(x)` to be `Reflect.types.value`. Agree with the Symbol labels. On

RE: About generators

2015-05-14 Thread Mohan.Radhakrishnan
Thanks. What is the underlying concurrency framework when we use generators for concurrent workloads ? Does it depend on the particular VM ? Mohan From: Aaron Powell [mailto:m...@aaron-powell.com] Sent: Thursday, May 14, 2015 12:00 PM To: Radhakrishnan, Mohan (Cognizant); es-discuss@mozilla.org

About generators

2015-05-14 Thread Mohan.Radhakrishnan
Hi, I have used simple generators but there seem to be some advanced usages. I came across these git references from another post and I have looked at the code. What are some articles that explain these concepts for JS developers before delving into this type of code ? Is reading this

RE: About generators

2015-05-14 Thread Aaron Powell
I've done a few blog posts on the topic: http://www.aaron-powell.com/posts/2014-01-13-functions-that-yield-mutliple-times.html http://www.aaron-powell.com/posts/2014-01-18-calling-up-callbacks-with-yield.html http://www.aaron-powell.com/posts/2014-01-28-cleaning-up-promises-wit-yield.html Axel

RE: About generators

2015-05-14 Thread Mohan.Radhakrishnan
This is interesting too. http://syzygy.st/javascript-coroutines/ http://www.dabeaz.com/coroutines/Coroutines.pdf Mohan From: Aaron Powell [mailto:m...@aaron-powell.com] Sent: Thursday, May 14, 2015 12:00 PM To: Radhakrishnan, Mohan (Cognizant); es-discuss@mozilla.org Subject: RE: About

Re: About generators

2015-05-14 Thread Axel Rauschmayer
Thanks Aaron! The longer version of that blog post is here: http://www.2ality.com/2015/03/es6-generators.html On 14 May 2015, at 08:30, Aaron Powell m...@aaron-powell.com wrote: I’ve done a few blog posts on the topic: