Re: Cross language discussion

2015-07-01 Thread Alex Kocharin
 People regularly suggest borrowing concepts from different languages here (we got arrow functions from coffee, generators are from python I believe). I don't see what more is there to achieve.   01.07.2015, 15:38, "Benjamin Gruenbaum" benjami...@gmail.com:So, this is something that has been

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-24 Thread Alex Kocharin
 I believe you can subclass anything using code like this: function MyPromise(executor) {  var self = new Promise(executor)  self.setPrototypeOf(self, MyPromise.prototype)  return self}Object.setPrototypeOf(MyPromise, Promise)  ... and it can be easily subclassed itself in the same way.  

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-24 Thread Alex Kocharin
 RegardsOn Fri, Apr 24, 2015 at 10:24 AM, Alex Kocharin a...@kocharin.ru wrote: I believe you can subclass anything using code like this: function MyPromise(executor) {  var self = new Promise(executor)  self.setPrototypeOf(self, MyPromise.prototype)  return self}Object.setPrototypeOf(MyPromis

Re: Should const be favored over let?

2015-04-17 Thread Alex Kocharin
 There won't be any performance gain. "const" is used to be much slower in v8 actually. But they fixed it as far as I know. I think it's a code style matter. And speaking about that, realistically, most code base will never use "const" widely. Just one reason: 5 characters vs 3 characters to type. 

Re: Putting `global` reference in specs

2015-04-17 Thread Alex Kocharin
 `self` is a very common local variable name, usually used as a substitute of `this`. So making it a global variable is a terrible idea. Consider this: ```function blah() {} blah.prototype.foo = function () {  var self = this   asyncStuff(function () {    self.complete = true  })}``` So what

Re: Should `use strict` be a valid strict pragma?

2015-02-05 Thread Alex Kocharin
 Why is there two of them, not one?  05.02.2015, 18:06, "Frankie Bagnardi" f.bagna...@gmail.com:I think any issues with that are imagined.  Languages have rules, and of the people who both know what 'use strict' does and are using es6 syntax, they're very unlikely to make the mistake. I don't see

Re: (x) = {foo: bar}

2015-01-05 Thread Alex Kocharin
 06.01.2015, 06:38, "Gary Guo" nbdd0...@hotmail.com: Though I am strongly negative, but there actually is such an implementation. The REPL of node will parse {a:1} as object literal while {a:1;} as block. Node.js REPL wraps all the statements in parentheses. Therefore `{a:1;}` becomes `({a:1;})`

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
 The code will be incorrect if you pass any regular object in there. Why should symbol be any different? For me, its throwing behavior is just another thing that could crash server-side node.js process for no good reason.   04.01.2015, 04:44, "Tab Atkins Jr." jackalm...@gmail.com: On Jan 3, 2015

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
 04.01.2015, 04:58, "Brendan Eich" bren...@mozilla.org:Alex Kocharin wrote:  The code will be incorrect if you pass any regular object in there.  Why should symbol be any different? For me, its throwing behavior is just another thing that could crash  server-side node.js process for no good

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
  04.01.2015, 05:44, "Rick Waldron" waldron.r...@gmail.com:On Sat Jan 03 2015 at 9:41:57 PM Alex Kocharin a...@kocharin.ru wrote:  Also, if you want to prevent mistakes like `object['blah' + symbol]`, linters could be changed to forbid/warn about concatenation inside property names.

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
  04.01.2015, 07:36, "Brendan Eich" bren...@mozilla.org:  My point is: concatenating Symbols with other strings have legitimate  uses.Name one.I did name one in another message. Logging. If somebody wants to output a variable just to see what it is, something like `console.log('hey, I got this: '

Re: Can `let`, `static` and `yield` still be used as Identifier?

2015-01-01 Thread Alex Kocharin
 I just tested in the JS console of my FireFox 34, where "let=1" seems to be a "SyntaxError: missing variable name". But your jsfiddle works fine, so you're right, everything is good here.   01.01.2015, 00:36, "Rick Waldron" waldron.r...@gmail.com:On Wed Dec 31 20

Re: Can `let`, `static` and `yield` still be used as Identifier?

2014-12-31 Thread Alex Kocharin
 Firefox does parse `let=1` as illegal, and I think this is a desired behavior. Otherwise you can't use `let` in non-strict mode, which is bad.  29.12.2014, 17:39, "Erik Arvidsson" erik.arvids...@gmail.com:This is a bug in Traceur.On Mon, Dec 29, 2014, 11:35 Gary Guo nbdd0...@hotmail.com

Re: What would a 1JS-friendly strict mode look like?

2014-12-18 Thread Alex Kocharin
  16.12.2014, 17:04, "Andrea Giammarchi" andrea.giammar...@gmail.com:On Tue, Dec 16, 2014 at 1:50 PM, Felipe Nascimento de Moura felipenmo...@gmail.com wrote: function () {    use strict, safe;} This could allow us to even add some extra scoped-options, such as a safe mode..  I'm quite sure we've

Re: how to delay interpolation of template strings?

2014-12-16 Thread Alex Kocharin
 Function('a', 'b', 'a = String(a), b = String(b); return `${a}, ${b}!`')('hello', 'world') eval isn't evil, only some of its users are.  16.12.2014, 14:48, "Niloy Mondal" niloy.monda...@gmail.com:Can this be considered for a feature request? Provision in the language to dynamically construct

Re: how to delay interpolation of template strings?

2014-12-16 Thread Alex Kocharin
 I think ES6 is more awesome than people usually realize. Oh by the way, here is some sugar:     var template = compile`Hello, ${"name"}!`    console.log(template({ name: "world" }))   Of course, ES6 does not have a compile function built-in, but I surely have one:     function compile(strs,

Re: how to delay interpolation of template strings?

2014-12-16 Thread Alex Kocharin
” function which processed templates differently though :()On Dec 16, 2014, at 12:30 PM, Alex Kocharin a...@kocharin.ru wrote: I think ES6 is more awesome than people usually realize. Oh by the way, here is some sugar:     var template = compile`Hello, ${"name"}!`    console.log(tem

Re: Retrieving generator references

2014-11-23 Thread Alex Kocharin
  23.11.2014, 07:03, "Brendan Eich" bren...@mozilla.org:Axel Rauschmayer wrote: As an aside, I still feel that two concerns are mixed in a generator  function: * The creation of the generator object. This is where the generator  function is like a constructor and where you’d expect `this` to refer

Re: Proposal: Syntax sugar for single exit and early exit functions.

2014-11-17 Thread Alex Kocharin
I don't think we need to add any syntax sugar for the examples below.Answering with examples inline:17.11.2014, 03:07, “Biju” bijumaill...@gmail.com:  I wish, I could write elegant two of the code pattern I use frequently.Patten 1.HTML button click event handler should always return false (ie,

Re: Function.arguments in JSC

2014-09-28 Thread Alex Kocharin
 Yes, it's a powerful meta-programming tool. I don't use it much, but it's sad to see things like that going away from _javascript_. For example, it could allow to build stack traces without any support from the engine. How do you like this one?: ```jsfunction type(n) { return typeof n } function

Re: Generators with arrow functions.

2014-09-23 Thread Alex Kocharin
23.09.2014, 18:22, Brendan Eich bren...@mozilla.org: Hemanth H.M wrote:  It is one proposed syntax for async functions.  Cool, thanks. Not sure who wrote the -cited line -- Jeremy didn't. It was written by Erik Arvidsson 10 months ago in the thread Jeremy linked to.

Re: Idea for Strawman: separate the core standard library itself into modules

2014-09-22 Thread Alex Kocharin
 Please show an example of the code you're using __proto__ in. I'm sure it can be rewritten with Object.setPrototypeOf.  23.09.2014, 01:46, "Jasper St. Pierre" jstpie...@mecheye.net:I have used __proto__ simply because it allows for a feature nothing else has: to change the [[Prototype]] of a

Re: new instantiation design alternatives

2014-09-17 Thread Alex Kocharin
  17.09.2014, 18:10, "Kevin Smith" zenpars...@gmail.com: That seems fine. Enabling different behaviour for called vs. constructed should only be used to explain the builtins; user code should not do so themselves. So it makes sense to me that those trying to do that would get "punished" with

Re: new instantiation design alternatives

2014-09-16 Thread Alex Kocharin
 16.09.2014, 18:56, "Rick Waldron" waldron.r...@gmail.com:On Mon, Sep 15, 2014 at 8:37 PM, Alex Kocharin a...@kocharin.ru wrote:  15.09.2014, 23:23, "Rick Waldron" waldron.r...@gmail.com:On Mon, Sep 15, 2014 at 2:57 PM, Brendan Eich bren...@mozilla.org wrote:Rick Waldron wro

Re: new instantiation design alternatives

2014-09-16 Thread Alex Kocharin
  16.09.2014, 19:13, "Rick Waldron" waldron.r...@gmail.com:On Tue, Sep 16, 2014 at 11:10 AM, Alex Kocharin a...@kocharin.ru wrote: 16.09.2014, 18:56, "Rick Waldron" waldron.r...@gmail.com:On Mon, Sep 15, 2014 at 8:37 PM, Alex Kocharin a...@kocharin.ru wrote:  15.09.2014,

Re: RegExps that don't modify global state?

2014-09-16 Thread Alex Kocharin
 What's the advantage of `re.test(str); RegExp.$1` over `let m=re.match(str); m[1]`? I assume RegExp["$'"] and RegExp["$`"] are nice to have, I remember them from perl, but never actually used them in _javascript_.  16.09.2014, 23:03, "Andrea Giammarchi" andrea.giammar...@gmail.com:I personally

Re: new instantiation design alternatives

2014-09-15 Thread Alex Kocharin
  15.09.2014, 23:23, "Rick Waldron" waldron.r...@gmail.com:On Mon, Sep 15, 2014 at 2:57 PM, Brendan Eich bren...@mozilla.org wrote:Rick Waldron wrote:The first is also objectionable because it breaks existing implicit return semantics.Say what? Constructors can return a different object from

Re: new instantiation design alternatives

2014-09-15 Thread Alex Kocharin
ep 15, 2014, at 8:37 PM, Alex Kocharin a...@kocharin.ru wrote:  15.09.2014, 23:23, "Rick Waldron" waldron.r...@gmail.com:On Mon, Sep 15, 2014 at 2:57 PM, Brendan Eich bren...@mozilla.org wrote:Rick Waldron wrote:The first is also objectionable because it breaks existing implicit return se

Re: ... A community is writing the spec...

2014-09-11 Thread Alex Kocharin
  You can inject the proto but that's not really subclassing ... You know, I'm starting to think that injecting proto is actually the right way to do subclassing. It preserves [[Class]], it doesn't depend on `new`, etc. Here is some code I checked with:

Re: ... A community is writing the spec...

2014-09-10 Thread Alex Kocharin
  assumes you have created a subclassed Array ... which trust me, it's the least common case you gonna have in the real world  I've been subclassing arrays in at least two separate projects, and it is very much possible via prototype injection. You (almost) can't intercept direct arr[x] calls, but

Re: use strict VS setTimeout

2014-09-07 Thread Alex Kocharin
 I would add that in node.js it returns neither undefined nor window, but a timer object, which you can clear up with `clearInterval(this)` inside the callback.  07.09.2014, 21:30, "Andrea Giammarchi" andrea.giammar...@gmail.com:I know this is probably W3C land but the following code shows the

Re: Fixing the associativity / precedence of the instanceof operator

2014-08-26 Thread Alex Kocharin
 You sound like strict mode is a different language designed to reduce user errors. It is not. It is just an intermediate mode between es3 and es7+, which makes incompatible changes easier, and the name is misleading. Making this an error in strict mode is only valid, if we are changing its

Re: Fixing the associativity / precedence of the instanceof operator

2014-08-26 Thread Alex Kocharin
  use developer tools such as linters. Those certainly should warn about code like that. I was trying to find such a tool a few days ago (after similar error was fixed in bunyan), and I found nothing: https://gist.github.com/rlidwka/8b904ca00b1e76731270 So I agree that it should be catched by

Re: Fixing the associativity / precedence of the instanceof operator

2014-08-26 Thread Alex Kocharin
 26.08.2014, 17:54, "Till Schneidereit" t...@tillschneidereit.net:On Tue, Aug 26, 2014 at 3:38 PM, Alex Kocharin a...@kocharin.ru wrote:  use developer tools such as linters. Those certainly should warn about code like that. I was trying to find such a tool a few days ago (after sim

Re: Promise() vs. new Promise()

2014-08-20 Thread Alex Kocharin
 But... why? I mean, every constructor can determine if it is called without `new` (that "this instanceof" check on top of every other constructor). So `new` keyword can really be removed from everywhere except in constructors themselves. Using `new` does create issues. For example, you can't

Re: Promise() vs. new Promise()

2014-08-20 Thread Alex Kocharin
20.08.2014, 19:18, Claude Pache claude.pa...@gmail.com: Le 20 août 2014 à 16:56, Alex Kocharin a...@kocharin.ru a écrit :  But... why?  I mean, every constructor can determine if it is called without `new` (that this instanceof check on top of every other constructor). So `new` keyword

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-07 Thread Alex Kocharin
07.08.2014, 09:49, Mathias Bynens math...@qiwi.be: On 7 Aug 2014, at 02:46, Bill Frantz fra...@pwpconsult.com wrote:  On Tue, Aug 5, 2014 at 7:56 AM, Mathias Bynens math...@qiwi.be wrote:  ...  In section 11.8.3 (Numeric Literals), the definition for  `DecimalIntegerLiteral` should somehow

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-07 Thread Alex Kocharin
 07.08.2014, 18:51, "Mark S. Miller" erig...@google.com:On Thu, Aug 7, 2014 at 7:08 AM, Alex Kocharin a...@kocharin.ru wrote: 07.08.2014, 09:49, "Mathias Bynens" math...@qiwi.be: On 7 Aug 2014, at 02:46, Bill Frantz fra...@pwpconsult.com wrote:  On Tue, Aug 5, 2014 at 7:56 AM,

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-07 Thread Alex Kocharin
2014, 19:32, "Mark S. Miller" erig...@google.com:The web seems unable to shed its past. In the absence of opt-in (either "use strict";, classes, or modules) legacy web code will probably be sloppy forever. In sloppy mode, you can probably use "with" forever as w

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-07 Thread Alex Kocharin
  07.08.2014, 20:16, "Mark S. Miller" erig...@google.com:On Thu, Aug 7, 2014 at 8:52 AM, Alex Kocharin a...@kocharin.ru wrote: So strict mode is mandatory in classes and modules, and can't be turned off. Since it is mandatory, it is no longer "strict mode" like it is in per

Re: Early error on '0' followed by '8' or '9' in numeric literals does not seem to be web-compatible

2014-08-05 Thread Alex Kocharin
05.08.2014, 19:07, Mathias Bynens math...@qiwi.be: On 5 Aug 2014, at 16:56, Alex Kocharin a...@kocharin.ru wrote:  What about allowing one-digit numbers with leading zeroes? 07 equals to 7 no matter whether it parsed as an octal or as a decimal. Thus, no harm there. That wouldn’t solve

Re: use es6; Any plans for such a mode?

2014-07-30 Thread Alex Kocharin
 No modes, please. "use strict" was a terrible idea, and I don't want to see that repeating. If you're worrying about typeof, better solution would be to deprecate it; and it's a job for linters, not compilers.  29.07.2014, 23:02, "Christoph Martens" cmarten...@gmail.com:Hey all, I just read a

Re: Trailing comma for function arguments and call parameters

2014-07-06 Thread Alex Kocharin
Unless you use leading comma style, trailing commas are very good to have for anything that has variable amount of items/keys/arguments. This is a classic example I use to show why JSON is a bad idea: https://github.com/npm/npm/commit/20439b21e103f6c1e8dcf2938ebaffce394bf23d#diff-6 I believe

Re: Trailing comma for function arguments and call parameters

2014-07-06 Thread Alex Kocharin
In fact, how about the same syntax for arrays and function calls? With trailing commas and elisions? So foo(1,,3,,) would be an alias for foo(1,undefined,3,undefined) ? 06.07.2014, 11:57, Alex Kocharin a...@kocharin.ru: Unless you use leading comma style, trailing commas are very good

Re: Math.TAU

2014-07-02 Thread Alex Kocharin
) spending time researching how to implement it, comparing existing implementations, or having to look up a constant value (e.g. 3.141592653589793). Seems a little silly, and I'd rather see some of the use cases for it end up on Math if anything.On Mon, Jun 30, 2014 at 4:55 PM, Alex Kocharin a...@k

Re: Math.TAU

2014-06-30 Thread Alex Kocharin
  30.06.2014, 21:09, "C. Scott Ananian" ecmascr...@cscott.net:On Mon, Jun 30, 2014 at 1:01 PM, Rick Waldron waldron.r...@gmail.com wrote:Just because other languages don't include a TAU constant doesn't mean ECMAScript cannot. Just because "serious mathematicians" think this is "crackpot

Re: Object copy

2014-06-10 Thread Alex Kocharin
 Object.create() ? It's not exactly cloning, but it'll probably work better than cloning in most cases.  10.06.2014, 20:33, "Maxime Warnier" mar...@gmail.com:Hi All Do you know if it is planned or maybe in discussion for ES7 to have a simple clone system on objects ? There are different notations,

Re: Lexical scope while extending prototype?

2014-02-10 Thread Alex Kocharin
 In the first case "this" is window, because it's inherited from whatever scope you call it. For example, in this case it won't be window:!function() { ((n) = console.log(this))() }.call({foo: 'bar'}) In the second case "this" is window as well. But second case won't get executed, because you're

Re: Rename Number.prototype.clz to Math.clz

2014-01-15 Thread Alex Kocharin
What if we add a uint64 type, we'd just have Math.clz64 (which is better than have X.clz returning something depending on a type, so you always have to check the type first) 15.01.2014, 23:18, Jason Orendorff jason.orendo...@gmail.com: ES6 adds a clz function, but it's a method of

Re: es-discuss Digest, Vol 82, Issue 95

2013-12-25 Thread Alex Kocharin
;raul mihaila" raul.miha...@gmail.com:@Alex Kocharin: I would't call the functions like time. It was only a very simple example. Often my functions would be called from outside so I wouldn't be able to pass the values. Also the main reason I want this is for optimizations, so as you pointed out,

Re: local variables with inherited values

2013-12-24 Thread Alex Kocharin
 ;(function() {  var x = 2   ;(function(x) {    x = 100    x // x = 100  })(x)   x // x = 2})() Wow, it works already. You just have to write a bit less semicolons there. Merry Christmas! :) Also this: ;(function() {  var x = 2   with({x: x}) {    x = 100    x // x = 100  }   x // x = 2})() But js

Re: Object.is()

2013-12-22 Thread Alex Kocharin
 Object.is() looks like a perfect function for checking oddballs (-0, NaN) if you want to represent an arbitrary data correctly. In that case distinguishing signed zeroes is a big plus (making (-0).toString() === '-0' would be better though). I don't understand your use-case. If you just want to

Re: Object.is()

2013-12-22 Thread Alex Kocharin
23.12.2013, 05:59, Brendan Eich bren...@mozilla.com: Alex Kocharin wrote:  Object.is() looks like a perfect function for checking oddballs (-0,  NaN) if you want to represent an arbitrary data correctly. In that  case distinguishing signed zeroes is a big plus or absolutely required

Re: Object.is()

2013-12-21 Thread Alex Kocharin
 I wonder why isn't it ``. Would be funny. +0 and -0 should be distinguished there. If you don't want them to be, you can always use comparison operators.  22.12.2013, 10:00, "Axel Rauschmayer" a...@rauschma.de:The use case for `Object.is()` that I see is to have a version of `===`, as a

Re: Could delete methods rename to remove?

2013-12-17 Thread Alex Kocharin
S6-Harmony-Collections-Shimhttps://github.com/paulmillr/es6-shimhttps://gist.github.com/Gozala/1269991 regards On Tue, Dec 17, 2013 at 11:38 AM, Alex Kocharin a...@kocharin.ru wrote: ES6 scripts will not work in IE8. Period. What's the point of making it work with a bit more ES6 scripts since a

Re: Could delete methods rename to remove?

2013-12-17 Thread Alex Kocharin
 ES6 scripts will not work in IE8. Period. What's the point of making it work with a bit more ES6 scripts since all of them will never be supported anyway? I would only welcome if that badly written or outdated software gets exposed this way.  17.12.2013, 22:59, "Andrea Giammarchi"

Re: Could delete methods rename to remove?

2013-12-17 Thread Alex Kocharin
problem which is about tools not always compatible with ES6 and/or future proof and shim aware. If tools were OK you wuld just write wm.delete(obj); and the tool would wrap that for you instead of throwing as these might do today. Regards On Tue, Dec 17, 2013 at 1:52 PM, Alex Kocharin a.

Re: Could delete methods rename to remove?

2013-12-17 Thread Alex Kocharin
p by step.On Wed, Dec 18, 2013 at 6:53 AM, Alex Kocharin a...@kocharin.ru wrote: Well, you said that it works in IE8, and I don't care enough to test it, so said about IE6 because it is the same legacy kind of thing. Doesn't matter. Legacy and broken tools is not a valid reason to avoid perfectl