Re: How to modify the scope chain without `with` ?

2016-02-22 Thread Coroutines
On Mon, Feb 22, 2016 at 4:07 AM, Isiah Meadows wrote: > FYI, this part might not work as you might expect. I've already been > tripped up by similar. > > ```js > var o = { > index: 0, > func() { return this.index++ }, > } > > with (o) { > func() // TypeError: Cannot

Re: How to modify the scope chain without `with` ?

2016-02-22 Thread Coroutines
To me "don't use `with` - assign the object to a smaller reference" just seems unsustainable. Say you're using a bunch of functions from 'ReallyLongModuleName'. So you do something like this: var x = require('ReallyLongModuleName'); And you start doing this everywhere: x.something();

Re: es7 proposal/polyfill?: base Map/WeakMap off Proxy + Weak References

2016-02-19 Thread Coroutines
On Fri, Feb 19, 2016 at 1:03 PM, Tab Atkins Jr. <jackalm...@gmail.com> wrote: > On Fri, Feb 19, 2016 at 12:59 PM, Boris Zbarsky <bzbar...@mit.edu> wrote: >> On 2/19/16 3:50 PM, Coroutines wrote: >>> Side discussion: Why does Javascript have this limitation? - w

Re: es7 proposal/polyfill?: base Map/WeakMap off Proxy + Weak References

2016-02-19 Thread Coroutines
On Fri, Feb 19, 2016 at 4:40 AM, Thomas Foster wrote: > Not sure where you got that idea, but aren't the objects just being converted > to string property names? Huh. I was so certain Node allowed that - I guess I just never made use of it. I knew that 'legally'

es7 proposal/polyfill?: base Map/WeakMap off Proxy + Weak References

2016-02-19 Thread Coroutines
Hi - I hope I am not suggesting something that has been said before ~ Having Proxy and eventual Weak References makes it possible to build Map/WeakMap in plain JS - nothing in hidden, 'native code' (C++). I'd like to propose basing them off of these when Weak References are a 'thing'. Map's API

Re: How to modify the scope chain without `with` ?

2016-02-16 Thread Coroutines
On Tue, Feb 16, 2016 at 9:57 AM, /#!/JoePea wrote: > You could > > ```js > let {cos, PI} = Math > > console.log(cos(PI)) > ``` Oh I agree there - if you're only using a few functions from a module it makes sense to create local references to them. I just thought something like

Re: How to modify the scope chain without `with` ?

2016-02-16 Thread Coroutines
On Tue, Feb 16, 2016 at 9:38 AM, Garrett Smith <dhtmlkitc...@gmail.com> wrote: > On Mon, Feb 15, 2016 at 1:13 AM, Coroutines <corouti...@gmail.com> wrote: > >> This post might be overly wordy. Sorry. It relates to the >> functionality provided by the `with

Re: How to modify the scope chain without `with` ?

2016-02-16 Thread Coroutines
On Tue, Feb 16, 2016 at 9:16 AM, /#!/JoePea wrote: > /#!/JoePea > On Feb 16, 2016 9:13 AM, "/#!/JoePea" wrote: >> >> Seems like changing the global could lead to problems where a developer >> might assumes certain globals but hey > > I meant: "but have"

Re: Any reason why __proto__ is not a well known symbol?

2016-02-16 Thread Coroutines
On Tue, Feb 16, 2016 at 8:00 AM, Dean Landolt wrote: > Is it too late to remove support for dunder-__proto__ strictly within module > contexts? This might introduce a bit of a refactor hazard when pulling old > code into modules, but it's only the static `obj.__proto__`

Re: How to modify the scope chain without `with` ?

2016-02-16 Thread Coroutines
On Tue, Feb 16, 2016 at 7:45 AM, Michał Wadas <michalwa...@gmail.com> wrote: > > 2016-02-16 15:51 GMT+01:00 Coroutines <corouti...@gmail.com>: >> >> Having the ability to derive from "global" (only in Node) and >> prepare an Object to run an

Re: How to modify the scope chain without `with` ?

2016-02-16 Thread Coroutines
On Mon, Feb 15, 2016 at 11:51 PM, Andreas Rossberg wrote: > That would be a total and complete disaster for implementations, as it would > make scopes observable and mutable in a way that absolutely breaks all > conventional compilation and optimisation techniques for local

Re: Any reason why __proto__ is not a well known symbol?

2016-02-15 Thread Coroutines
On Mon, Feb 15, 2016 at 8:51 PM, Tab Atkins Jr. wrote: > It was specified before symbols existed, and all implementations do it > as a string property. If we were reinventing it today it would either > be a symbol or something in the MOP, but are hands are tied by legacy.

Re: How to modify the scope chain without `with` ?

2016-02-15 Thread Coroutines
On Mon, Feb 15, 2016 at 1:43 AM, Andreas Rossberg wrote: > Without wanting to say much on the overall viability of your plan, but > proxies do work with `with`. However, your code has at least two bugs: > > (1) It's not defining a custom `has` trap. That is needed for

How to modify the scope chain without `with` ?

2016-02-15 Thread Coroutines
This post might be overly wordy. Sorry. It relates to the functionality provided by the `with` keyword and why I think it's important in the future. I am currently rewriting a templating module that I think is very useful for it's ability to turn a function in coffeescript syntax into a sort of

Re: How should operator overloading work?

2015-12-30 Thread Coroutines
On Wed, Dec 30, 2015 at 8:31 AM, Nicolas B. Pierron wrote: > Note, do we want to distinguish the binary operator Symbol['_+_'] from > the unary operator Symbol['+_']. > Also, I am not sure how extendable the language is, especially if we > are looking for operators

How should operator overloading work?

2015-12-29 Thread Coroutines
How I imagined *binary* operator invocation would work is this: Our example: a + b If a or b is an object we try to look for an overloaded operator to call like so: (a[Symbol('+')] || b[Symbol('+')])(a, b) ^ disregard that I'm assuming both a and b are objects I can index safely Okay, so

Re: How should operator overloading work?

2015-12-29 Thread Coroutines
On Tue, Dec 29, 2015 at 11:15 AM, Andrea Giammarchi wrote: > I should probably read other threads too about this, but is `Symbol('+')` a > typo and it should be a property like any other well known `Symbol` so that > it's actually `Symbol['+']`, `Symbol['~']`, and

How should operator overloading work?

2015-12-29 Thread Coroutines
-- Forwarded message -- From: Coroutines <corouti...@gmail.com> Date: Tue, Dec 29, 2015 at 1:49 PM Subject: Re: How should operator overloading work? To: luoyongg...@gmail.com On Tue, Dec 29, 2015 at 11:34 AM, 罗勇刚(Yonggang Luo) <luoyongg...@gmail.com> wrote: >

Re: Re[2]: Operators overriding

2015-12-28 Thread Coroutines
On Mon, Dec 28, 2015 at 9:55 AM, Bradley Meck wrote: > Who would think not knowing what `a+b` could do as a pitfall? /s > > I am not a big fan of overloading though, since it presents more mental > complexity as they map to functions without looking like function calls.

Is it planned to support operator overloading in ES7 with Symbols? or reserved prototype identifiers?

2015-12-21 Thread Coroutines
Subject says it - I was just curious if this was planned and if so, in what way :> Symbols or reserved identifying method names on the prototype? Also I don't understand anything about (@@species?) - does anyone have a link explaining that? ___

Re: es-discuss Digest, Vol 106, Issue 46

2015-12-16 Thread Coroutines
On Wed, Dec 16, 2015 at 4:14 AM, John Gardner wrote: > I do fully agree with the notion that enums should generate Symbols by > default... however, it seems unreasonable to prevent users from assigning > other types as well. > > Should enums also offer programmers the

Re: Propose simpler string constant

2015-12-16 Thread Coroutines
On Wed, Dec 16, 2015 at 3:20 AM, Thomas wrote: > IMHO it'd be a huge mistake to not use symbols for enums. > > In my head this: > > const colours = enum { > Red, > Yellow, > Green, > Blue > } > > should 'desugar' to something like this in ES6: > > const

Re: The "Pipeline" Operator - Making multiple function calls look great

2015-12-14 Thread Coroutines
On Sun, Dec 13, 2015 at 10:32 PM, Kevin Smith wrote: > (someArray > .filter(...) > .map(...) > |> someOtherArrayOp > ).forEach(...) > > Note the extra parens before the "forEach" invocation. For the record I think a pipe operator is silly - I wish | were available

Re: Could String internalize an ArrayBuffer?

2015-12-06 Thread Coroutines
On Sat, Dec 5, 2015 at 9:19 PM, Boris Zbarsky wrote: > For example, strings typically have a complicated representation that > involves multiple fragments, ropes, etc, to make string concatenation fast. Ahh, I'm not sure why I didn't think of that... I come from Lua and they

Could String internalize an ArrayBuffer?

2015-12-05 Thread Coroutines
I'm not sure what I'm asking for/looking for. What I want is to be able to view a String through a typed array without duplicating the memory/contents of that string. As I understand it, typed arrays operate over an ArrayBuffer, not Strings. Does anyone know of a way to do this? If it's not

Re: String.prototype.padLeft / String.prototype.padRight

2015-11-17 Thread Coroutines
On Tue, Nov 17, 2015 at 4:54 PM, Bergi wrote: > I could not disagree more with that. Iterators don't have a "left" or > "right" side, they have a start and an end? The former would be much more > confusing. > So when you `padStart` or `trimStart` an iterator you can be sure it

Re: String.prototype.padLeft / String.prototype.padRight

2015-11-17 Thread Coroutines
On Tue, Nov 17, 2015 at 1:13 PM, Jeremy Darling wrote: > Just as an aside, I think padLeft/padRight should still be added in addition > to padStart/padEnd. There are times (token generation, identity padding, > etc) where you would want to specify the handedness of the

Re: String.prototype.padLeft / String.prototype.padRight

2015-11-17 Thread Coroutines
In my opinion, if you understand that your script renders right-to-left, you would understand that it is encoded/parsed left-to-right :> On Tue, Nov 17, 2015 at 2:13 PM, Claude Pache <claude.pa...@gmail.com> wrote: > >> Le 17 nov. 2015 à 22:29, Coroutines <corouti.

Re: Is \u006eew a valid Identifier?

2015-11-09 Thread Coroutines
On Mon, Nov 9, 2015 at 10:10 AM, Isiah Meadows wrote: > Is there a reason why escapes like that in the title shouldn't evaluate to > keywords? To be honest, it's bad style, but I don't get how it would be > breaking the Web. This. I do not understand this either. If you

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Coroutines
On Wed, Nov 4, 2015 at 2:36 PM, Rick Waldron <waldron.r...@gmail.com> wrote: > On Wed, Nov 4, 2015 at 8:16 AM Coroutines <corouti...@gmail.com> wrote: >> obj[Symbol.weakValues] = true; >> obj[Symbol.weakProperties] = true; > 2. For security purposes, only code

Re: Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-04 Thread Coroutines
On Wed, Nov 4, 2015 at 4:56 AM, Romuald Quantin <r...@soundstep.com> wrote: > As an aside and as Coroutines, > > I never understood why there is this inability to enumerate WeakMap keys. > If I had it my way there would be no WeakMap or WeakSet. I'd have a Symbol.mode simil

Re: An update on Object.observe

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 1:24 PM, Adam Klein wrote: > Note that O.o didn't help for the "as they happen" case anyway, as callbacks > were delayed until the end of the turn (same timing as Promise resolution). > Proxies are required to do synchronous interception. Would this be

Re: An update on Object.observe

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 3:26 AM, Alexander Jones wrote: > In my opinion, the fundamental record type we build our JS on should be > getting dumber, not smarter. It feels inappropriate to be piling more > difficult-to-reason-about mechanisms on top before reeling in exotic host >

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 12:20 AM, Tom Van Cutsem wrote: > What O.o would provide beyond Proxy is the ability to observe changes to > already pre-existing objects. I think I missed something important here. You can watch for events with both Proxy and Object.observe() - but

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 3:22 PM, Coroutines <corouti...@gmail.com> wrote: > But because of what Object.observe() can do to see into closures, I'd > relegate it to privileged code :> It is incredibly useful for > debugging. I really need to make sure my thoughts are comp

Re: Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 7:33 PM, Isiah Meadows wrote: > There's a reason Object.observe is async: it prevents you from changing how > the value is first assigned, so it can't work like a proxy. And question: > how does it let you see hidden closures? In JS it is common to

Re: An update on Object.observe

2015-11-03 Thread Coroutines
Okay, so I've been making a lot of noise on this list in the last few days about Proxy and Object.observe(). I thought I would try to put up some example code to show why both should stay, but Object.observe() usage should be restricted so it's not web-accessible (debug use only). var target =

Re: An update on Object.observe

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 10:08 PM, Isiah Meadows wrote: > Proxies can do a better, more thorough job of breaking encapsulation. > > ```js > var log = []; > String = new Proxy(String, { > construct(target, newTarget, args) { > log.push(args); > return

Re: An update on Object.observe

2015-11-03 Thread Coroutines
On Tue, Nov 3, 2015 at 2:25 PM, Adam Klein wrote: > Yes, similar to nextTick() (and I agree that's better than polling, > conceptually). But Proxies are strictly more powerful. I agree as well - I had skipped over learning about Proxies until someone told me about them last

Save Object.observe()! (please) + make WeakMap/WeakSet observable.

2015-11-02 Thread Coroutines
I was referred to es-discuss after filing a feature request here to support observing WeakMaps and WeakSets. ( https://bugzilla.mozilla.org/show_bug.cgi?id=1206584 ) I was linked this message: https://mail.mozilla.org/pipermail/es-discuss/2015-November/044684.html Please save Object.observe().