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" :So, this is something that has been bothering me for a while n

Re: Subclassing ES6 objects with ES5 syntax.

2015-04-24 Thread Alex Kocharin
e sublcassed. 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.setP

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

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 happen

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: 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" :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 people using template

Re: (x) => {foo: bar}

2015-01-05 Thread Alex Kocharin
 06.01.2015, 06:38, "Gary Guo" : 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;})` which is a syntax erro

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
  04.01.2015, 07:36, "Brendan Eich" :  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: ' + variable)` would b

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
  04.01.2015, 05:44, "Rick Waldron" :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. Ho

Re: Implicit coercion of Symbols

2015-01-03 Thread Alex Kocharin
 04.01.2015, 04:58, "Brendan Eich" :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 reason.No g

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." : On Jan 3, 2015 3:38 PM, "Rick Waldron

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" :On Wed Dec 31 2014 at 2:45:57 PM Ale

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" :This is a bug in Traceur.On Mon, Dec 29, 2014, 11:35 Gary Guo wrote:From the specification I s

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

2014-12-18 Thread Alex Kocharin
  16.12.2014, 17:04, "Andrea Giammarchi" :On Tue, Dec 16, 2014 at 1:50 PM, Felipe Nascimento de Moura 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 discussed already other di

Re: how to delay interpolation of template strings?

2014-12-16 Thread Alex Kocharin
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(template({ name: &q

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, ...arg

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" :Can this be considered for a feature request? Provision in the language to dynamically construct template strings and interpol

Re: Retrieving generator references

2014-11-23 Thread Alex Kocharin
  23.11.2014, 07:03, "Brendan Eich" :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  to the generator o

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, when

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 s

Re: Generators with arrow functions.

2014-09-23 Thread Alex Kocharin
23.09.2014, 18:22, "Brendan Eich" : > 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" :I have used __proto__ simply because it allows for a feature nothing else has: to change the [[Prototype]] of a callable / constructor.Thi

Re: new instantiation design alternatives

2014-09-17 Thread Alex Kocharin
  17.09.2014, 18:10, "Kevin Smith" : 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 having to type more.  Yes,

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" :I personally find the `re.test(str)` case a

Re: new instantiation design alternatives

2014-09-16 Thread Alex Kocharin
  16.09.2014, 19:13, "Rick Waldron" :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.

Re: new instantiation design alternatives

2014-09-16 Thread Alex Kocharin
 16.09.2014, 18:56, "Rick Waldron" :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

Re: new instantiation design alternatives

2014-09-15 Thread Alex Kocharin
a version of placement new in JS, and it’s rather nice for providing these conveniences. It’s fair to say we’re doing it wrong, but it’s hard to ignore the advantages/flexibility of it. What is the advantage of returning an arbitrary object from a constructor, other than being similar to JS as it

Re: new instantiation design alternatives

2014-09-15 Thread Alex Kocharin
  15.09.2014, 23:23, "Rick Waldron" :On Mon, Sep 15, 2014 at 2:57 PM, Brendan Eich 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 `this`, that's just JS. Yi

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: https://gist.github.com/rlidwka/0ad094386f60

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" :I know this is probably W3C land but the following code shows the global object in every JS engin

Re: Fixing the associativity / precedence of the instanceof operator

2014-08-26 Thread Alex Kocharin
 26.08.2014, 17:54, "Till Schneidereit" :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 similar error was fi

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 lint

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 precede

Re: Promise() vs. new Promise()

2014-08-20 Thread Alex Kocharin
20.08.2014, 22:47, "Brendan Eich" : > Alex Kocharin wrote: >>  Still doesn't make much sense... This pattern (this instanceof ...) breaks >> another pattern (BaseClass.call(this)). Why first one is deprecated, not the >> second one? > > Fair point, a

Re: Promise() vs. new Promise()

2014-08-20 Thread Alex Kocharin
20.08.2014, 19:18, "Claude Pache" : > Le 20 août 2014 à 16:56, Alex Kocharin 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 construct

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 write

Re: Promise() vs. new Promise()

2014-08-20 Thread Alex Kocharin
 Normal classes throw an exception because they have a bug in them. :P Try "Error" vs "new Error" - no difference at all. `Promise` should do the same. The fact that it's a constructor is just an implementation detail after all. Thus, people shouldn't write `new` there.  20.08.2014, 16:52, "Axel Ra

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" :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 perl. You

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
elping.  07.08.2014, 19:32, "Mark S. Miller" :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 well. On Th

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" :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 Tu

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" : > On 7 Aug 2014, at 02:46, Bill Frantz wrote: >>  On Tue, Aug 5, 2014 at 7:56 AM, Mathias Bynens wrote: >> >>  ... >>>  In section 11.8.3 (Numeric Literals), the definition for >>>  `DecimalIntegerLiteral` should somehow be tweaked to match that of >>>  `Dec

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" : > On 5 Aug 2014, at 16:56, Alex Kocharin 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. > >

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
// alex 05.08.2014, 18:20, "Allen Wirfs-Brock" : > On Aug 4, 2014, at 9:55 AM, Jason Orendorff wrote: >>  On Mon, Aug 4, 2014 at 11:43 AM, Mark S. Miller wrote: >>>  Isn't the early error required only for strict code? > > There is actually no such Early Error in the ES6 spec, right?  We're ta

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

2014-07-29 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" :Hey all, I just read a bit about the ParallelJ

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" : > Unless you use leading comma style, trailing commas are very goo

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: Math.TAU

2014-07-02 Thread Alex Kocharin
he alternative to other things in _javascript_ (for the most part) 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

Re: Math.TAU

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

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" :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, from :  - jquery

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 r

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" : > ES6 adds a clz function, but it's a method of Number.prototype.clz > rather tha

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

2013-12-25 Thread Alex Kocharin
:29, "raul mihaila" :@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
23.12.2013, 05:59, "Brendan Eich" : > 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 b

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 co

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" :The use case for `Object.is()` that I see is to have a version of `===`, as a function, that allows

Re: Could "delete" methods rename to "remove"?

2013-12-17 Thread Alex Kocharin
E6 ? ... I don't understand your argument. We are talking about IE8 and polyfills that work already plus this does not solve the main 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 too

Re: Could "delete" methods rename to "remove"?

2013-12-17 Thread Alex Kocharin
n 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...@kochar

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" :not shold but *

Re: Could "delete" methods rename to "remove"?

2013-12-17 Thread Alex Kocharin
c/ses/WeakMap.jshttps://github.com/Benvie/ES6-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 o