throwing/breaking inside a for-of loop does not call iterator.throw()

2017-08-23 Thread Marius Gundersen
This is something I stumbled across while looking into the for-of-with (aka continue-with/break-with). It seems like throwing inside a for-of loop does not call the iterators throw method, it calls the return method and it seems to disregard the result of the method. For eample: ```js var gen = ()

Re: Re: Proposal: for-of-withas a way to provide a value to the generator

2017-08-23 Thread Marius Gundersen
.com > > > On Tue, Aug 22, 2017 at 12:30 PM, Isiah Meadows > wrote: > > Inline: > > > > > > On Tue, Aug 22, 2017 at 3:36 AM, Marius Gundersen > wrote: > >> One of the reasons I think for-of should handle this is because of the > error &

Re: Re: Proposal: for-of-withas a way to provide a value to the generator

2017-08-22 Thread Marius Gundersen
One of the reasons I think for-of should handle this is because of the error handling. [Closing an iterator]( http://raganwald.com/2017/07/22/closing-iterables-is-a-leaky-abstraction.html) is not trivial, and so having to write that code yourself is error prone. I originally considered `continue x

Re: Proposal: for-of-withas a way to provide a value to the generator

2017-08-21 Thread Marius Gundersen
e or more variables outside the scope of the >> generator function during iteration, which the generator function can read. >> Is this so bad? >> >> On Mon, 21 Aug 2017 at 15:24 Marius Gundersen >> wrote: >> >>> Generators today can both "send"

Proposal: for-of-withas a way to provide a value to the generator

2017-08-21 Thread Marius Gundersen
true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator.return) { _iterator.return(); } } finally { if (_didIteratorError) { throw _iteratorError; } } } ``` Marius Gundersen __

Infer name of anonymous callback function based on argument name

2017-06-04 Thread Marius Gundersen
useful if it could take the name of the flatmap argument (mapFunc). Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Would it be possible to add “await on first use” to the language?

2017-02-24 Thread Marius Gundersen
wait sauce); (await dough).add(await cheese); return (await dough); } Now the variables will be awaited on first use Marius Gundersen On 24 Feb 2017 03:36, "Šime Vidas" wrote: Daniel Brain from PayPal has written a post about async/await: https://medium.com/@bluepnume/even-

Re: Function#toString revision: JSDoc comments?

2016-04-16 Thread Marius Gundersen
Would it not be better to expose the names (and default values, destructurings, etc) of the function arguments using reflection? For example, Reflection.arguments(Math.max).then this method can return any JSDoc it is able to parse. On 16 Apr 2016 16:53, "Caitlin Potter" wrote: > How would that in

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

2015-12-14 Thread Marius Gundersen
Do we really need to add support for await in a pipeline syntax sugar when there already is a piping support in `.then()`? If you need to await something in that chain, then just use `.then()`. ```js let result = await fs.readFile('index.txt') .then(aSingleParamFunction) .then(anotherSinglePar

Re: Re: Additional Math functions

2015-10-05 Thread Marius Gundersen
from "iterator-math"; [1,2,3,4]::sum(); //10 [1,2,3,4]::mean(); //2.5 [{a:1}, {a:2}, {a:3}, {a:4}].map(x => x.a)::sum(); //10 ``` [1] https://github.com/zenparsing/es-function-bind Marius Gundersen On Mon, Oct 5, 2015 at 3:54 PM, Eli Perelman wrote: > We aren't really arguin

Re: Exponentiation operator precedence

2015-09-24 Thread Marius Gundersen
One advantage of #4 is that it will make it possible to introduce either #2 or #3 in the future, if we change our minds. This way we can use real world use cases to decide if we should go for #2 or #3. Marius Gundersen On Fri, Sep 25, 2015 at 1:23 AM, Waldemar Horwat wrote: > My preference

Re: Should "const" be favored over "let"?

2015-04-17 Thread Marius Gundersen
let > var foo=...;`. > > let and mut? Oh well, too late for that now. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Cancellation architectural observations

2015-03-03 Thread Marius Gundersen
ss the token to every step in the chain to both stop work being done and to ignore the result/prevent a handler from being called. Wouldn't it be better if the promise chain took care of this for the programmer? Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Cancellation architectural observations

2015-03-02 Thread Marius Gundersen
ove callback is never run p2.ignore(); ``` Maybe calling ignore on a rejected or resolved promise should throw. Marius Gundersen On Mon, Mar 2, 2015 at 8:59 AM, Salvador de la Puente González < sa...@unoyunodiez.com> wrote: > I think this did not reach the mailing list to the W3: &

Re: extends null

2015-02-15 Thread Marius Gundersen
) {} >>> NullBase.prototype = Object.create(null); >>> >>> class C extends NullBase {} >>> Can't this be solved by returning a null object from the constructor? ```js class Null{ constructor() { return Object.create(null); } } class

Re: Handling error in Promises

2015-01-13 Thread Marius Gundersen
reason for the exception to travel up the stack. Either the exception must be handled as a rejected promise or it must be handled in something like `window.onerror`. Marius Gundersen On Tue, Jan 13, 2015 at 12:35 PM, Boopathi Rajaa wrote: > ``` > Promise > .resolve() > .then(functi

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

2015-01-06 Thread Marius Gundersen
derstand and not ambiguous for machines is to wrap or prefix the block, but not the object, for example with do: x => do { let a = 5; return a*x; } AFAIK do expressions are not in ES6, but might be in ES7. Marius Gundersen On 6 Jan 2015 19:42, "Brendan Eich" wrote: > Sorry,

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

2015-01-05 Thread Marius Gundersen
One scenario where arrow functions are likely to return objects is in the map function of arrays and the pipe function for streams. For example: [1,2,3] .map(x => {value: x, double:2*x}) .filter(x => x.double < 5) Marius Gundersen On 5 Jan 2015 21:16, "Kevin Smith" wrote: &

Re: Array.forEach() et al with additional parameters

2014-12-22 Thread Marius Gundersen
doesn't fat-arrow solve this? It's not that verbose, and you can put the arguments in any order you want ```js [1,2,3].forEach(element => myCallback("something else", element)); ``` Marius Gundersen ___ es-discuss mailing list

Re: Why is "export default var a = 1;" invalid syntax?

2014-12-15 Thread Marius Gundersen
So are all of these legal? ```js var a = 1; export a; var b = 1; export default b; export var c = 1; export var d = 1, e = 2, f = 3; ``` What about: ```js var default = 1; export default; var b = 1; export default b; ``` Sorry for not being very good at reading EBNF Marius Gundersen On Mon

Re: Importing modules that don't exist

2014-11-21 Thread Marius Gundersen
to guess through message parsing otherwise > ;-) > > As always I believe the properties should be machine readable and therefore be exposed on the Error object instead of having to parse the message. Marius Gundersen ___ es-discuss mailing

Re: Importing modules that don't exist

2014-11-21 Thread Marius Gundersen
ing similar) sounds like a good solution to me. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: async/await improvements

2014-11-14 Thread Marius Gundersen
it should be possible for one window to handle the errors in child windows (taking same origin and CSP into consideration ofcourse). This should probably be generalized to realms, so that one realm can catch all the errors in another realm. Marius Gundersen ___

Re: Maximally minimal stack trace standardization

2014-09-28 Thread Marius Gundersen
ne number/character number is not yet available. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: dynamic synchronous import

2014-09-26 Thread Marius Gundersen
): ```js var moduleName = 'foo'; Loader.import(moduleName).then(function(foo){ //use foo here }); ``` Marius Gundersen On Fri, Sep 26, 2014 at 5:29 PM, John Barton wrote: > no. > > On Fri, Sep 26, 2014 at 8:12 AM, Konstantin Ikonnikov > wrote: > >> Can I

Re: Multiline template strings that don't break indentation

2014-09-12 Thread Marius Gundersen
array is the values to be inserted. That would let you do: ```js var query = sql(...String.noIndent` select * from myDB where username='${user}' and password='${password}' `); ``` Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Bundling vs sending serialized dependency graph

2014-08-22 Thread Marius Gundersen
nd the entire dependency graph as a JSON file to the client (for example using bloom filters and a slightly smarter server), and I'm sure the community will find the best pre-fetching strategy with the tools already available to them. Marius Gundersen [1]: https://developer.mozilla.org/en-US/d

Re: Single import from modules without default export

2014-08-06 Thread Marius Gundersen
On Wed, Aug 6, 2014 at 2:10 PM, Kevin Smith wrote: > >> Completely agree, the default should be removed. This is simply a >> proposal of how we can still have a simple import statement (`import $ from >> "jQuery";`) without needing `default`. >> >> > You know, I hate even suggesting any syntax ch

Re: Single import from modules without default export

2014-08-06 Thread Marius Gundersen
On Wed, Aug 6, 2014 at 1:04 PM, Kevin Smith wrote: > >> It would be great if we could have single export modules without using >> the `default` keyword to mark the exported binding as being special. One >> way to do this is for method A (import without curly braces) to import the >> first exporte

Re: Single import from modules without default export

2014-08-06 Thread Marius Gundersen
On Wed, Aug 6, 2014 at 1:02 PM, Kevin Smith wrote: > >> * The name of the imported binding is decided by the user of the module, >> not the author >> * The user of the module does not need to know the name of the exported >> binding, set by the author of the module. >> > > If you seriously want

Single import from modules without default export

2014-08-06 Thread Marius Gundersen
ject (which is available using `module theModuleObject from "moduleThatExportsSeveralBindings"`) is iterable, so the first entry can be accessed. I therefore want to propose that the default keyword is removed, that only named bindings are allowed when exporting in a module, and that method A

Re: Re: Quantifying Default Exports

2014-07-22 Thread Marius Gundersen
r to use than a named export. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: ModuleImport

2014-07-01 Thread Marius Gundersen
dy has proposed it yet. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Math.TAU

2014-06-28 Thread Marius Gundersen
I propose the tau constant be added to the Math object and be defined as 2*Math.PI, as described in the tau manifesto: http://tauday.com/tau-manifesto (I couldn't find any discussion about this when searching esdiscuss.org, so sorry if this has been discussed before) Marius Gund

Re: ModuleImport

2014-06-27 Thread Marius Gundersen
t to the default export. If the default export is an object with properties (or a function with properties, which I quite common in npm) then there is no static checking of those properties. So with today's spec there is one way to get static checking and one ways (default) to not get sta

Re: Default exports, without explicit syntactic support

2014-06-26 Thread Marius Gundersen
lection of exports (the bag) and named values from the bag: ```js import _, {map, reduce, filter} from "underscore"; assert(_.fiilter === filter); ``` Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: ModuleImport

2014-06-26 Thread Marius Gundersen
to the module. The only downside to this is the (apparently mandatory) curly braces around the imported object. If single export/import becomes the convention with ES6 modules then users will be forced to type an extra pair of {} several times in most of their fil

Re: ModuleImport

2014-06-20 Thread Marius Gundersen
is syntax could work without deviating very far from the current spec. It seems easier to get the spec to favor multiple export (which, to me, it looks like it was originally designed to favor). I don't have any preference either way, I just want it to favor one, both on the export and import

Re: Rationale for dropping ModuleImport syntax?

2014-06-10 Thread Marius Gundersen
On Tue, Jun 10, 2014 at 9:06 AM, Domenic Denicola < dome...@domenicdenicola.com> wrote: > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of > Marius Gundersen > > > This will likely lead to a lot of confusion, not only for module makers > but a

Re: Rationale for dropping ModuleImport syntax?

2014-06-10 Thread Marius Gundersen
t the two exports are the same object (which for underscore will likely lead to bugs): ```js export default = 5; export {1 as a}; //in another module import {a} from "sillyModule";//a is 1 import a from "sillyModule"; //a is 5 ``` This will likely lead to a lot of confu

Re: `this` inside modules

2014-06-09 Thread Marius Gundersen
What is an arrow function bound to in a module? ```js export var a = () => this; ``` On Mon, Jun 9, 2014 at 7:08 PM, Caridy Patino wrote: > My point: if 'this' is not global in modules, then ES6 must have an >> alternative way to name the global object. >> > > Yes, we covered that last week. `

Re: Rationale for dropping ModuleImport syntax?

2014-06-09 Thread Marius Gundersen
On Mon, Jun 9, 2014 at 7:40 PM, Karolis Narkevičius wrote: > Why can't we have both with the same syntax? > > ```js > // imports a function which is the default export > import mkdirp from "mkdirp"; > ``` > > and > > ```js > // imports all named exports, like module used to > import fs from "fs";

Re: typed objects and value types

2014-04-03 Thread Marius Gundersen
created. This would unfortunately add an extra step in passing uvalues between realms, but it might just be a minor inconvenience. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: multiple modules with the same name

2014-01-27 Thread Marius Gundersen
On Tue, Jan 28, 2014 at 2:13 AM, James Burke wrote: > On Mon, Jan 27, 2014 at 3:14 PM, John Barton > wrote: > > On Mon, Jan 27, 2014 at 2:50 PM, Sam Tobin-Hochstadt < > sa...@cs.indiana.edu> > > wrote: > >> Imagine that some browser has an ok-but-not-complete implementation of > >> the X library

Re: multiple modules with the same name

2014-01-27 Thread Marius Gundersen
ould probably be thrown, or the promise could be rejected. But I don't think that would be good for DOM manipulation. If innerHTML is used to add a lot of markup and an existing module to the DOM, should an error be thrown? Should none of the other markup be added to the DOM? What would the er

Re: multiple modules with the same name

2014-01-27 Thread Marius Gundersen
On Mon, Jan 27, 2014 at 11:08 PM, Jason Orendorff wrote: > On Mon, Jan 27, 2014 at 1:54 PM, Marius Gundersen > wrote: > > I didn't find anything in the spec on handling multiple modules with the > > same name [...] > > What should happen in such a scenari

multiple modules with the same name

2014-01-27 Thread Marius Gundersen
the DOM? Should it be a no-op, with no feedback to the user? Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Reserving await within Arrow Functions

2013-12-12 Thread Marius Gundersen
b; var async = (a, b) ~> (await a) + (await b); Marius Gundersen On Thu, Dec 12, 2013 at 11:49 AM, Forbes Lindesay wrote: > I always want the * to be mandatory for full generator functions as a > visual cue. I suspect I would want something similar for async functions > but I can

Re: Weak callbacks?

2013-11-07 Thread Marius Gundersen
On Nov 8, 2013 1:46 AM, "Mark Miller" wrote: > > On Thu, Nov 7, 2013 at 4:27 PM, Marius Gundersen wrote: >> >> It seems that every (real) usecase for weakRefs, weakMaps and weakSets is to implement a weak event listener system. > > > Not true. Even silly.

Re: Weak callbacks?

2013-11-07 Thread Marius Gundersen
dispatcher has a hidden iterable weakSet of listeners. It iterates over this weakSet and notifys each entry of the event which has occured. But it does not expose this iterable set. Does it sound like weak event listeners could solve the challenges you face? Is there a problem which can be i

Re: Creating top-level scopes in ES6 and do blocks

2013-11-04 Thread Marius Gundersen
eak myBlock; myGlobal = 10; } console.log(myGlobal); //50% of the times it will be 5, 50% of the times it will be 10. ``` This all works today (except for the let declaration), so not sure if anything is needed to replace this. Marius Gundersen On Mon, Nov 4, 2013 at 12:36 PM, Axel Rauschmayer wr

Re: what kind of problem is this fat arrow feature trying to solve ?

2013-10-02 Thread Marius Gundersen
any native dom event handlers, so your trick with the eventHandler method won't work. And we use pubsub, which affect observables on the `this` object, and Ajax is handled through Promises, which also needs access to the `this` object. Marius Gundersen On Oct 2, 2013 11:35 PM, "Andre

Re: what kind of problem is this fat arrow feature trying to solve ?

2013-10-02 Thread Marius Gundersen
a single line, it takes care of the this variable, which is used in a lot more places than DOM event handlers. Marius Gundersen On Wed, Oct 2, 2013 at 8:14 PM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > If you cannot use fat arrow to define prototypes than you cannot recycle >

Re: Logical operators don't use valueOf()

2013-09-08 Thread Marius Gundersen
something which stores the truthyness of obj in a register, until the expression is completely evaluated? Thanks for the detailed information you can provide on this subject btw. Marius Gundersen Den 8. sep. 2013 21:43 skrev "Brendan Eich" følgende: > Did you read my reply o

Re: Logical operators don't use valueOf()

2013-09-08 Thread Marius Gundersen
So how about implementing toBoolean as an overridable method, which is called whenever !, || or && are used. This way an objec has three method for converting it into a primitive; toString, toValue and toBoolean. Marius Gundersen On Sun, Sep 8, 2013 at 2:19 AM, Till Schneidereit wrot

Re: Logical operators don't use valueOf()

2013-09-07 Thread Marius Gundersen
> That's the way ToBoolean has always been defined http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.1.2 . All objects are considered to be Boolean true values. So does this mean I can override toBoolean to change the way ! behaves on an object? Marius G

Logical operators don't use valueOf()

2013-09-07 Thread Marius Gundersen
he same way as the other operators? Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Destructuring and default parameters in functions

2013-06-28 Thread Marius Gundersen
ES6 or the array in AMD): https://gist.github.com/mariusGundersen/5884450 Marius Gundersen On Thu, Jun 27, 2013 at 8:27 PM, Brandon Benvie wrote: > On 6/27/2013 3:19 AM, Marius Gundersen wrote: > >> Or maybe it just isn't implemented in Firefox? >> > &

Destructuring and default parameters in functions

2013-06-27 Thread Marius Gundersen
/Exception: missing ) after formal parameters (line 1) I haven't found this defined in the current grammar, but would be useful for something I'm currently working on. Or maybe it just isn't implemented in Firefox? Marius Gundersen ___ e

Re: Weak event listener

2013-04-03 Thread Marius Gundersen
else has weak references and so the widget (and all its children) are garbage collected and stop listening to events when the parent deletes it. Hopefully this is enough of a usecase to make WeakRefs (or one of the alternatives, for example, an iterable set of weak references to functions/obje

Re: memory safety and weak references

2013-04-01 Thread Marius Gundersen
em if the only allowed argument to a weak reference is a function. An iterable weak set of functions would not have this problem, would solve the suggested usecases for weak references (observables/events): Marius Gundersen On Mon, Apr 1, 2013 at 10:39 PM, Brendan Eich wrote: > Marius Gundersen w

Re: memory safety and weak references

2013-04-01 Thread Marius Gundersen
this seems less like a problem with weak references, and more like a problem with specific implementations of GCs. Marius Gundersen On Fri, Mar 29, 2013 at 3:47 AM, Oliver Hunt wrote: > > On Mar 29, 2013, at 7:36 AM, David Herman wrote: > > > On Mar 27, 2013, at 4:52 AM, Sam Tobi

Re: Weak event listener

2013-03-26 Thread Marius Gundersen
x27;m not sure of how big of a problem this would be; it might be an annoyance or it might break the application completely. Marius Gundersen On Tue, Mar 26, 2013 at 4:24 AM, Benoit Marchant wrote: > Very true, I'm wondering if based on usage today it could make sense to > have

Weak event listener

2013-03-25 Thread Marius Gundersen
ple the event system does not hold a strong reference to the listener/handler function, so if nothing else has a reference to the handler function, it is garbage collected. Any thoughts on this, as an alternative to the more general (and low level) weak references? Marius Gundersen __

Re: What is the status of Weak References?

2013-03-03 Thread Marius Gundersen
than (not) calling the addEventListener every time. The explicit reattaching of the rAF works because you know how long it is until the next animation frame, but it won't work in a system where the time until the next event is indeterminable. Marius Gundersen ___

Re: What is the status of Weak References?

2013-03-02 Thread Marius Gundersen
> I won't say it's absolutely better than WeakRefs and it may not apply to the data binding case (?), but it's an interesting pattern to keep in mind. I can't see how this would work in an observer/listener application. The listening object has no way of knowing if it will be deleted when the even

Re: Pure functions in EcmaScript

2012-11-28 Thread Marius Gundersen
ing as FP is a bit of a trend today (due, in part, to the popularity of JavaScript), it seems to me like a good idea to implementing features which help promote good FP patterns in a language that allows for both FP and OOP. David > > Le 28/11/2012 12:50, Marius Gundersen a écrit : >

Re: Pure functions in EcmaScript

2012-11-28 Thread Marius Gundersen
On Wed, Nov 28, 2012 at 1:20 PM, Andreas Rossberg wrote: > On 28 November 2012 12:50, Marius Gundersen wrote: > > Has there been any work done on pure functions in EcmaScript? The way I > > imagine it, there would be a way to indicate that a function should be > pure > >

Pure functions in EcmaScript

2012-11-28 Thread Marius Gundersen
on@(a, b){ return a+b; } Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: arrow function syntax simplified

2012-03-30 Thread Marius Gundersen
ry (and many other frameworks) do a lot of things with |this| behind the scenes, where it would be very nice to have |this| be set by the framework. Or is the consensus that the current way of doing this is not good, and should be discurraged? Marius Gundersen

Re: Consider extending JSON grammar to support objects with circular reference

2012-03-05 Thread Marius Gundersen
nces of objects/arrays? For example: var obj = {}; obj.b = {}; obj.a = obj.b; Would produce: { "b": {}, "a": path(/b) } and could be parsed so adding a member to either obj.b or ob.a would update the other one. This would therefore be more powerfull than simply cop

Re: Consider extending JSON grammar to support objects with circular reference

2012-03-05 Thread Marius Gundersen
avaScript object, and no way to recontstruct a JavaScript object from this json string. Therefore paths should only be able to refer to objects or arrays. Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss