Arrow functions and return values

2012-11-29 Thread Jussi Kalliokoski
It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); To me, it seems like this should return undefined. After all, the last statement in the function is empty. To actually return b * c, you should drop the semicolon: var a

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 06:20, Brandon Benvie a écrit : The answer though in that case is easy enough though, make sure the prototype descriptor is created with Object.create(null). This wouldn't solve compatibility issues with in-the-wild code but it solves the issue for most people who care enough to

Re: Arrow functions and return values

2012-11-29 Thread David Bruant
Le 29/11/2012 09:41, Jussi Kalliokoski a écrit : It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); To me, it seems like this should return undefined. After all, the last statement in the function is empty. To

Re: Arrow functions and return values

2012-11-29 Thread Brendan Eich
Jussi Kalliokoski wrote: It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); To me, it seems like this should return undefined. After all, the last statement in the function is empty. Not by the grammar. You would

Re: Arrow functions and return values

2012-11-29 Thread Peter van der Zee
On Thu, Nov 29, 2012 at 10:32 AM, Brendan Eich bren...@mozilla.com wrote: You would need a second ; after b * c; to spell the empty statement. Interesting fact actually, it would mean the empty statement is no longer a NOOP. It can actually alter a program. I can't think of a situation where

RE: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Nathan Wall
Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value: 123}); Er, shouldn't that be: Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}})); Seems pretty excessive. It's probably too late to make defineProperty only look at own properties, but how about

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 16:47, Nathan Wall a écrit : In addition, it'd be nice if there was an easier way to create an object with no [[Prototype]]... some sort of addition to object literal notation? I think ES6 will have such a notation with the __proto__ de facto standardization: var o = {

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Allen Wirfs-Brock
On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote: Object.defineProperty(obj,key, Object.create(defaultDataProperty, {value: 123}); Er, shouldn't that be: Object.defineProperty(obj,key,Object.create(null, {value: {value: 123}})); oops, yes create requires an addition object layer

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread David Bruant
Le 29/11/2012 17:02, Allen Wirfs-Brock a écrit : On Nov 29, 2012, at 7:47 AM, Nathan Wall wrote: Seems pretty excessive. It's probably too late to make defineProperty only look at own properties, but how about making it ignore properties inherited from Object.prototype? Fairly complex to

Re: Problems with strict-mode caller poisoning

2012-11-29 Thread Dave Fugate
The intention was definitely to test step 2 which this particular test doesn't hit. Looks like other 'step 2' tests do though: 6 http://hg.ecmascript.org/tests/test262/file/53c4ade82d14/test/suite/ch15/15.3/15.3.5/15.3.5.4/15.3.5.4_2-2gs.js#l6 /** 7

Re: Problems with strict-mode caller poisoning

2012-11-29 Thread Dave Fugate
Should be: 'caller' to false :) On Thu, Nov 29, 2012 at 9:10 AM, Dave Fugate dave.fug...@gmail.com wrote: 'caller' to true ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Arrow functions and return values

2012-11-29 Thread Kevin Smith
It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); Hmmm... I was under the impression that arrow functions with normal function bodies do *not* implicitly return anything. Maybe I need to adjust my spec goggles,

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
I really don't understand what is exactly the advantage of considering inherited properties for descriptors. If you create a new instance with those properties using a class to avoid writing them ... what are you gaining against a literal object? If you are doing this in order to have less code

Re: Arrow functions and return values

2012-11-29 Thread Brendan Eich
Kevin Smith wrote: It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); Hmmm... I was under the impression that arrow functions with normal function bodies do *not* implicitly return

Re: Arrow functions and return values

2012-11-29 Thread Rick Waldron
On Thu, Nov 29, 2012 at 8:49 AM, Kevin Smith khs4...@gmail.com wrote: It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); Hmmm... I was under the impression that arrow functions with normal function bodies do

Re: Arrow functions and return values

2012-11-29 Thread Rick Waldron
On Thu, Nov 29, 2012 at 9:41 AM, Brendan Eich bren...@mozilla.org wrote: Kevin Smith wrote: It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var b = 2; b * c; } a(4); Hmmm... I was under the impression

Re: Arrow functions and return values

2012-11-29 Thread Jussi Kalliokoski
On Thu, Nov 29, 2012 at 7:42 PM, Rick Waldron waldron.r...@gmail.comwrote: On Thu, Nov 29, 2012 at 9:41 AM, Brendan Eich bren...@mozilla.org wrote: Kevin Smith wrote: It's a bit unclear to me how arrow functions react to semicolons, for example: var a = (c) = { var

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Brendan Eich
Andrea Giammarchi wrote: I really don't understand what is exactly the advantage of considering inherited properties for descriptors. It's easy to overreact here. Don't mess with Object.prototype still applies, or you will have other WTF moments. ES5 shipped this and browsers shipped

Re: Problems with strict-mode caller poisoning

2012-11-29 Thread Andreas Rossberg
Or to null, which is exactly what the new semantics decided to do. ;) /Andreas On 29 November 2012 17:11, Dave Fugate dave.fug...@gmail.com wrote: Should be: 'caller' to false :) On Thu, Nov 29, 2012 at 9:10 AM, Dave Fugate dave.fug...@gmail.com wrote: 'caller' to true

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
I will ... but I still would like to know why other developers are using inheritance for this. No memory, performance, size, benefits and more verbose code, i.e. Object.defineProperty(o, p, Object.create(null, {value:{value:v}})) OR Object.defineProperty(o, p, new DefaultDescriptor(v)); VS

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Brandon Benvie
Here's a place I've made use of it, note Descriptor and Descriptors. https://github.com/Benvie/benvie.github.com/blob/master/client/modules/site/introspect.js#L221 ___ es-discuss mailing list es-discuss@mozilla.org

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
that's actually cool, but you suffer same problem? :-) desc.enumerable = 'get' in desc; On Thu, Nov 29, 2012 at 1:07 PM, Brandon Benvie bran...@brandonbenvie.comwrote: Here's a place I've made use of it, note Descriptor and Descriptors.

Re: Object.prototype.get bye bye Object.defineProperty

2012-11-29 Thread Andrea Giammarchi
Updated MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/defineProperty#Description Hope it's fine, feel fere to edit/add/change that, thanks On Thu, Nov 29, 2012 at 12:23 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: I will ... but I still