es-discuss@mozilla.org

2021-03-04 Thread Ron Buckton
This was mentioned up-thread, but I wrote up this proposal several years ago (https://github.com/rbuckton/proposal-refs) and am still considering bringing it to committee at some point. However, there are a larger set of cross-cutting concerns for refs in the context of a proposal like https://

Re: Optional Curly Braces in JavaScript

2019-11-03 Thread Ron Buckton
The '_' isn't necessary for chaining expressions, as ',' would already suffice: ``` if (foo==2) bar(), bar2(); ``` Also, '_' is already a valid expression/identifier. While I'm not generally a fan of eliding braces from everything, I have expressed interest in evaluating something like C#'s

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-17 Thread Ron Buckton
2f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636963465244040592&sdata=ncNlzUB9%2FRJmg7%2Bt1vAM4UtxeAMm62ditqH%2BJh2f2kQ%3D&reserved=0> On Sun, Jun 16, 2019 at 12:00 AM guest271314 mailto:guest271...@gmail.com>> wrote: > > ``` > const x = nameof y > const y = 1; > ```

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-17 Thread Ron Buckton
> How is VSCode related to JavaScript? You have ignored the context from Jordan’s email (emphasis added): >> again, `Object.keys({ y })[0]` will give you the string `y`, and will >> survive refactoring tools. you can even do `function nameof(obj) { return >> Object.keys(obj)[0]; }` and then `na

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-16 Thread Ron Buckton
d011db47%7C1%7C0%7C636963465244040592&sdata=ncNlzUB9%2FRJmg7%2Bt1vAM4UtxeAMm62ditqH%2BJh2f2kQ%3D&reserved=0> On Sun, Jun 16, 2019 at 12:00 AM guest271314 mailto:guest271...@gmail.com>> wrote: > > ``` > const x = nameof y > const y = 1; > ``` > > At

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
tore a value) while in this TDZ is what results in the ReferenceError. At no point does the `nameof` operator *dereference* the variable, so no error need be thrown. From: guest271314 Sent: Saturday, June 15, 4:29 PM Subject: Re: Re: What do you think about a C# 6 like nameof() expression for To: Ron B

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
ree cases you are accessing the *binding* of `y`, not the *value* of `y`. Even in the `() => y` case, you don’t access the *value* of `y` until you execute the function. From: guest271314 Sent: Saturday, June 15, 2019 3:57 PM To: Ron Buckton Cc: es-discuss@mozilla.org Subject: Re: Re: What

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
Sorry, I meant to say “not entirely correct”. From: Ron Buckton Sent: Saturday, June 15, 2019 3:03 PM To: guest271314 Cc: es-discuss@mozilla.org Subject: RE: Re: What do you think about a C# 6 like nameof() expression for > At that point in the example code the identifer ```y``` does not ex

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
ec’d and nice-to-have capability. From: guest271314 Sent: Saturday, June 15, 2019 2:50 PM To: Ron Buckton Cc: es-discuss@mozilla.org Subject: Re: Re: What do you think about a C# 6 like nameof() expression for > It doesn’t matter what the value of ‘y’ is, just what the lexical name of `y` > is. `

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-15 Thread Ron Buckton
It doesn’t matter what the value of ‘y’ is, just what the lexical name of `y` is. `nameof` wouldn’t refer to `y` as an expression, its just pointing to the identifier. From: guest271314 Sent: Friday, June 14, 2019 10:03 PM To: Ron Buckton Cc: es-discuss@mozilla.org Subject: Re: Re: What do

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
quot;value" /*4*/] = value /*5*/; } ``` If you rename the parameter `value` of the function `setValue` in an editor with a rename refactoring, you want to rename the symbols at 1, 2, 3, and 5, but not the string at 4. Ron From: guest271314 Sent: Friday, June 14, 2019 2:43 PM To: Ron Buc

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
> `nameof whatever` → `Object.keys({ whatever })[0]`, but I'm a bit confused > why it'd be better to type `nameof foo` in code, rather than `'foo'` - if you > change `foo` to `bar`, you have to change both of them anyways. If you are using an editor that supports rename refactoring, its generall

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
> Interesting. ```y``` would be able to be evaluated before ```y``` is defined? I very explicitly stated that `nameof y` would *not* evaluate its operand. Evaluation of `nameof` would merely result in a string containing the name of the binding referenced by the operand. From: es-discuss On B

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
Since `nameof` does not actually evaluate anything, the following would be legal: ``` const x = nameof y; // "y" const y = 1; ``` However, the shorthand property name workaround is not legal due to TDZ: ``` const x = Object.keys({y})[0]; // error due to TDZ const y = 1; ``` With the shortand p

RE: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
foo.bar` were allowed `nameof` would not actually evaluate `foo.bar`, but merely result in `”bar”`. `nameof` does not evaluate anything, it is merely a syntactic transformation by the runtime that becomes a string. Ron From: guest271314 Sent: Friday, June 14, 2019 10:07 AM To: Ron Buckton Cc: es

Re: Re: What do you think about a C# 6 like nameof() expression for

2019-06-14 Thread Ron Buckton
The 'nameof' operator provides the string name of a static symbol (in compiler/linker terms, not an ECMAScript 'Symbol'). This is often useful for diagnostics (logging and errors), and gives developers a way to reduce repetition. It is also extremely helpful in editors that support symbolic "re

RE: Proposal: Duration

2019-03-04 Thread Ron Buckton
Personally, I’d love to see something like this included as part of the temporal proposal (https://github.com/tc39/proposal-temporal), as I’ve been experimenting with something very much like this here: https://github.com/rbuckton/temporal/blob/master/src/Duration.ts. I think a Duration type th

RE: Proposal: Default object method

2019-01-27 Thread Ron Buckton
There’s nothing in that proposal says that an object with a `Symbol.apply` has to have a different `typeof`. It *would* mean that any Call might require additional dispatch which could have performance implications. It could also be an approach to support “callable” classes: ```js class Foo {

RE: Proposal for faster this assignments in constructor functions

2018-11-28 Thread Ron Buckton
Dart has something like this: https://www.dartlang.org/guides/language/language-tour#constructors ```dart class Point { num x, y; // Syntactic sugar for setting x and y // before the constructor body runs. Point(this.x, this.y); } ``` I could see a form of BindingElement (et al) that al

RE: New Proposal: Placeholder syntax

2018-11-28 Thread Ron Buckton
Partial application chose to limit the scope of `?` to argument positions in an argument list for a number of reasons. The primary being this case (assuming arbitrary expressions were allowed): ```js let i = 0; const g = f({ x: i++, y: ? }); ``` The goal of partial application was to “fix” non-

RE: Arrow methods

2018-11-18 Thread Ron Buckton
C# has a similar syntax for shorthand expression bodies (https://github.com/dotnet/roslyn/wiki/New-Language-Features-in-C%23-6#expression-bodies-on-method-like-members): ```cs class Point { private int x; private int y; … // expression bodied getters (read-only) public int X => x; p

RE: Array.prototype.remove(item)

2018-10-10 Thread Ron Buckton
That depends entirely on what the return value means. Returning Boolean from `add` doesn’t mean, “does the value now exist in the set”, but rather means “was the set modified as a result of this operation”. To avoid any possible performance cost for calling `has` before `add`, I usually have to

RE: Proposal: Add Map.prototype.putIfAbsent

2018-10-10 Thread Ron Buckton
I have seen this in other languages as `getOrCreate(key, valueFactory)`. Dictionaries in .NET have a `TryGetValue(key, out value)` method that returns a boolean and has an ‘out’ parameter used to assign the value if it exists. The performance issue regarding keys is one of my common concerns wit

RE: Pointers

2018-03-19 Thread Ron Buckton
> -Original Message- > From: Pier Bover > Sent: Monday, March 19, 2018 5:06 PM > To: Isiah Meadows > Cc: Ron Buckton ; es-discuss disc...@mozilla.org> > Subject: Re: Pointers > > So the proposal is basically having references to primitives like strings,

RE: Pointers

2018-03-19 Thread Ron Buckton
> -Original Message- > From: es-discuss On Behalf Of Isiah > Meadows > Sent: Monday, March 19, 2018 3:21 PM > To: Michael J. Ryan > Cc: es-discuss > Subject: Re: Pointers > > And even if we *could* get pointers into JS, I'd *strongly* not want it to be > like what's proposed here. Inste

RE: Picking (deconstructing) properties into object literals

2017-08-22 Thread Ron Buckton
As a alternative, consider https://github.com/rbuckton/proposal-shorthand-improvements. From: kai zhu Sent: Tuesday, August 22, 2017 9:45 PM To: Isiah Meadows Cc: es-discuss@mozilla.org Subject: Re: Picking

RE: Stream + async await

2017-07-29 Thread Ron Buckton
One option might be something like https://github.com/rbuckton/prex/blob/master/docs/scheduling.md#class-asyncqueue. It allows you to put items on the queue as soon as they are available. Ron From: Naveen Chawla Sent: Saturday, July 29, 2017 3:54 AM To: Domenic Den

RE: Re: Functional Operators

2017-07-16 Thread Ron Buckton
.reduce(Math.add)`\*. Assuming it is and I’m just failing to see it, is the benefit significant enough to merit new syntax? (On further consideration, maybe `Reflect.add`, since `+` is not specific to numeric values...) On Sun, Jul 16, 2017 at 2:19 AM, Ron Buckton mailto:ron.buck...@microsoft

RE: Re: Functional Operators

2017-07-15 Thread Ron Buckton
I have been looking into functional operators while working on a proposal for pipeline and partial application. I’ve found that a sigil like `{+}` is just as ergonomic as `(+)`, but has fewer lookahead issues with respect to regular expression parsing. While `(/)` is ambiguous as to whether it w

RE: Allowing object field name shorthand

2017-06-25 Thread Ron Buckton
There is one place where I could see this syntax being useful, though with different semantics, is a feature from C# that I seen used to good effect: Dotted names for shorthand property assignments. For example: ``` const results = books.map(x => ({ x.isbn, x.title, x.category.categoryNam

RE: Array pointer getter?

2017-06-02 Thread Ron Buckton
I recently put together https://github.com/rbuckton/ecmascript-ref which is somewhat similar to this. From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Alex Falcon Sent: Friday, June 2, 2017 9:06 AM To: es-discuss@mozilla.org Subject: Array pointer getter? Hello. I heard abo

RE: throwif operator

2017-04-11 Thread Ron Buckton
I’d much rather see something more like C# 7’s throw expressions: https://docs.microsoft.com/en-us/dotnet/articles/csharp/whats-new/csharp-7#throw-expressions ```js // original example fs.writeFile("message.txt", "Hello Node.js", err => err ? throw err : console.log("The file has been saved.");

RE: Resource management

2016-12-31 Thread Ron Buckton
> -Original Message- > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Isiah > Meadows > Sent: Saturday, December 31, 2016 8:34 AM > To: J Decker > Cc: Raul-Sebastian Mihăilă ; es-discuss disc...@mozilla.org> > Subject: Re: Resource management > > Not enough. Not lo

RE: expanding comments proposal

2016-10-21 Thread Ron Buckton
> From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Gert > Cuykens > Sent: Friday, October 21, 2016 4:56 PM > To: Tab Atkins Jr. > Cc: Bruno Jouhier ; es-discuss disc...@mozilla.org> > Subject: Re: expanding comments proposal > > There are two reasons for that, one is am not

RE: Promises as Cancelation Tokens

2016-01-04 Thread Ron Buckton
This gist contains the TypeScript declarations for the version of CancellationToken I’ve been using for a number of small projects. The basic API shape is: ```ts class CancellationTokenSource { constructor(linkedTokens?: CancellationToken

RE: Re: Propose simpler string constant

2015-12-16 Thread Ron Buckton
In C#, an enum is a declaration that defines a distinct type consisting of a set of named constant values of that type. The distinct type of the enum has an underlying numeric base type, such as byte, int, long, etc. By default, each constant value is assigned an incrementing integer value start

RE: Reflection to know if executed within a generator/async ?

2015-12-03 Thread Ron Buckton
I agree with Bradley, and kindly refer you to this oft referenced blog post regarding synchronous and asynchronous APIs: http://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/ Ron From: Bradley Meck Sent: Thursday, December 3, 2015 8:57 AM To: Andrea Giammarchi Cc: es-dis

RE: Decorators for functions

2015-10-22 Thread Ron Buckton
> -Original Message- > From: Andrea Giammarchi [mailto:andrea.giammar...@gmail.com] > Sent: Thursday, October 22, 2015 12:53 PM > Ron, there's **no way** you can distinguish a class from a generic function > in current specifications. Yes, this is true. However, decorators aren't in the

RE: Decorators for functions

2015-10-22 Thread Ron Buckton
Andrea, Is your concern about disambiguating the usage of a decorator at the call site or within the body of the decorator? In the current proposal, you can decorate a class member, or the class itself. When decorating a class member, three arguments are passed to the decorator: The target, th

RE: Decorators for functions

2015-10-20 Thread Ron Buckton
I can think of numerous examples of how decorators could apply to functions, and I’ve added them to a gist [1] for easier consumption. It’s true that simple decorators for functions can work as simply as function calls, but this becomes a b

RE: Exporting Symbols

2015-10-15 Thread Ron Buckton
Wouldn’t this work? our-symbols.js: ```js export const SpecialSymbol = Symbol("SpecialSymbol"); ``` their-consumer.js ```js import { SpecialSymbol } from "our-symbols"; export const features = { [SpecialSymbol]: true }; ``` our-features.js ```js import { SpecialSymbol } from "our-symbols"; impo

RE: Template strings as a template language.

2015-09-13 Thread Ron Buckton
This is theoretically possible: ``` let t = $template` ${$item.permalink} ${$each($item.comments)` ${$parent.permalink} ${$if($item.title)` ${$parent.permalink} `} `} `; let s = t(data); ``` ...given an adequate implementation using proxies (to create bindings for e.g. `$

RE: What do you think about a C# 6 like nameof() expression for JavaScript.

2015-08-09 Thread Ron Buckton
om my Windows Phone From: Isiah Meadows<mailto:isiahmead...@gmail.com> Sent: ‎8/‎8/‎2015 8:57 PM To: Ron Buckton<mailto:ron.buck...@microsoft.com>; Behrang Saeedzadeh<mailto:behran...@gmail.com>; EcmaScript Discuss Mailing List<mailto:es-discus

RE: What do you think about a C# 6 like nameof() expression for JavaScript.

2015-08-08 Thread Ron Buckton
One of the main purposes of the `nameof` operator is to provide the string value of a symbol, so that if you perform a "Rename" refactoring of that symbol that the change is also reflected. This is primarily for cases where you perform precondition assertions tied to an argument: ``` ... st

RE: let function

2015-05-14 Thread Ron Buckton
I proposed something similar to this among the folks investigating decorators for ES7: https://github.com/jonathandturner/decorators/issues/17 In this case, it was for a `const function`, as a means to allow a decorator on a function declaration, as adding the `const` (or `let`) would introduce

RE: Existential Operator / Null Propagation Operator

2015-04-07 Thread Ron Buckton
Oops, was think in batch for a minute there. Sent from my Windows Phone From: Brendan Eich<mailto:bren...@mozilla.org> Sent: ‎4/‎7/‎2015 6:23 PM To: Ron Buckton<mailto:ron.buck...@microsoft.com> Cc: Caitlin Potter<mailto:caitpotte...@gmail.co

RE: Existential Operator / Null Propagation Operator

2015-04-07 Thread Ron Buckton
Brendan Eich wrote: > Brendan Eich wrote: > > Caitlin Potter wrote: > >> 6, 2015 at 5:42 PM, Brendan Eich >> > wrote: > >> > > >> >>/ Did you keep backward compatibility? `x?.1:y` must continue to > >> work. > >> /> > >> > > >> >​This is why I sugge

RE: Array.prototype.find - Proposal for (breaking) change of API

2015-04-07 Thread Ron Buckton
Even more off-topic, I’m sure, but with http://github.com/rbuckton/queryjs (a query library over iterables) and ES6 you can do: ``` import { Query } from './query'; let files = ["main.md", "backup.md"]; let base = "/my/root"; let found = Query .from(files) .map(file => path.resolve(base, file

RE: Existential Operator / Null Propagation Operator

2015-04-06 Thread Ron Buckton
Wouldn't `.?` as an infix operator be unambiguous, compared to `?.`? There's no place other than decimal literals where this would be legal today, and decimal literals already require either parenthesis or an extra dot to perform a property access in any event. With that lexeme, `x.?1:y` would b

RE: Forwarding `return()` in generators

2015-03-24 Thread Ron Buckton
Is your goal to wrap a generator, as it seems you are propagating the exception of the caller by calling iterator.throw(). However, you do not seem to be propagating the sent value, so the protocol here isn’t fully implmeneted. If you just want to iterate values (and don’t really care about the

RE: Cancellation architectural observations

2015-03-04 Thread Ron Buckton
> new Promise(resolve => doLater(resolve, cts.token)).then(handleResult); > setImmediate(() => cts.cancel()); > > In this scenario cancel would be called right after the resolve method > is called, but before handlerResult is called. For this to work with a > cancellation token you would need t

Re: Cancellation architectural observations

2015-03-02 Thread Ron Buckton
The upside of having a separate abstraction for cancellation, is that it composes well with async functions: ```js async function runStockTicker(receiveSymbol, cancellationToken) { while (!cancellationToken.canceled) { var symbols = await fetchSymbols(cancellationToken); if (!cancellati

Re: Cancellation architectural observations

2015-03-02 Thread Ron Buckton
operty. Ron From: Kevin Smith Sent: Monday, March 02, 2015 6:42 PM To: Ron Buckton Cc: public-script-co...@w3.org; es-discuss Subject: Re: Cancellation architectural observations Cancellation * Cancellation signals are produced by the caller and consumed

Re: Cancellation architectural observations

2015-03-02 Thread Ron Buckton
> Cancellations should "chain" > == > If you have a cancellable promise p1, and use .then() to produce a new > promise p2, p2 should also be cancelable, and in the default case, > should "chain up" to p1 and cause it to cancel as well. The CTS/Token approach can do this directl

Re: Cancellation architectural observations

2015-03-02 Thread Ron Buckton
ar cts = new CancellationTokenSource(); fetchPage(cts.token); cts.cancel(); // abort all requests fetchPage(); fetchPage(); root.cancel(); ``` Ron From: Andrea Giammarchi Sent: Monday, March 02, 2015 4:18 PM To: Ron Buckton Cc: Dean Tribble; Kevin Smith; p

Re: Cancellation architectural observations

2015-03-02 Thread Ron Buckton
​ In light of Async Functions in ES7, it may make sense to separate the abstractions between promises and cancellation. Promises and cancellation signals have different use cases: Promises * Promises are consumed by the caller and produced by the callee. * Observation a promise resolu

RE: Cancelable promises

2015-02-27 Thread Ron Buckton
AsyncJS (http://github.com/rbuckton/asyncjs) uses a separate abstraction for cancellation based on the .NET CancellationTokenSource/CancellationToken types. You can find more information about this abstraction in the MSDN documentation here: https://msdn.microsoft.com/en-us/library/dd997364(v=vs

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

2015-01-05 Thread Ron Buckton
For better or worse, C# avoids this ambiguity through the use of the `new` operator: ``` f = x => y => new { x, y }; ``` Of course, C# does not support creating an object literal (nee. "anonymous type") without `new`, but using `new` here would be generally unambiguous in ES7+. Although its le

RE: generator libraries

2015-01-03 Thread Ron Buckton
I wrote http://github.com/rbuckton/queryjs Sent from my Windows Phone From: Aaron Powell Sent: ‎1/‎3/‎2015 6:26 PM To: 'Mark Volkmann'; es-discuss@mozilla.org Subject: R

RE: Elegant way to generate string from tagged template?

2014-12-23 Thread Ron Buckton
For ES6 you could use http://github.com/rbuckton/QueryJS like this: ``` var a = [1,2,3]; var b = ["a", "b", "c"] var c = Query .from(a) .zip(b, (a, b) => [a, b]) .flatMap(a => a) .toArray() .join(""); ``` Ron Sent from my Windows Phone From: Brendan Eic

[ES7+] Promise cancellation (was: Re: Promise-returning delay function)

2014-10-28 Thread Ron Buckton
The direction I've taken around Promise cancellation given the API surface of the ES6 Promise has been to use a different object to handle cancellation. This approach is similar to the Cooperative Cancelation model used in .NET. The API for this looks something like the following (using TypeScri

Should `Set.prototype.add` return boolean instead of `this`?

2014-10-16 Thread Ron Buckton
??I recall from earlier discussions on this list that the reason `Set.prototype.add` returns `this` is to support chained calls to the set, to add multiple items, similar to how some libraries like jQuery operate, for example: ``` var s = new Set(); s.add(1).add(2).add(3); ``` I have foun

RE: Proposal: Promise.prototype.Finally

2014-08-18 Thread Ron Buckton
o a later revision). Ron From: Domenic Denicola Sent: Monday, August 18, 2014 3:20 PM To: Ron Buckton; EcmaScript Subject: RE: Proposal: Promise.prototype.Finally Here is the current design for Promise.prototype.finally. I agree it is a useful feature. https://github.com/domenic/prom

Proposal: Promise.prototype.Finally

2014-08-18 Thread Ron Buckton
I created the following gist as a proposal for the addition of a `finally` method to the prototype of the Promise constructor, either for ES6 (if such a thing is considered valuable and could be fast tracked at this date), or for ES7. This method would take in a single callback that would be exe

RE: Overriding Map/etc with get/set hooks?

2014-08-11 Thread Ron Buckton
rototype tricks. Ton Sent from my Windows Phone ____ From: Ron Buckton<mailto:rbuck...@chronicles.org> Sent: ‎8/‎11/‎2014 6:45 PM To: Tab Atkins Jr.<mailto:jackalm...@gmail.com>; Allen Wirfs-Brock<mailto:al...@wirfs-brock.com> Cc: Brendan Eich<mail

RE: Overriding Map/etc with get/set hooks?

2014-08-11 Thread Ron Buckton
Sorry for the short reply here, as I'm not at my PC. Would having an @@isValue (Map) and @@isKey (Set/Map) work? Set.prototype[@@isValue] = value => true; // default Built -in Set operations would check values against @@isValue and throw. You can then override it in your subclass and make it no

RE: ModuleImport

2014-06-24 Thread Ron Buckton
If it is considered legal, then I'd say maybe the default export should be named @@default (or a similar symbol) instead. Ron Sent from my Windows Phone From: Calvin Metcalf Sent: ‎6/‎24/‎2014 5:47 PM To: Kevin Smith

RE: ModuleImport

2014-06-20 Thread Ron Buckton
> From: John Barton [mailto:johnjbar...@google.com] > Sent: Friday, June 20, 2014 3:48 PM > > ES6 already has what you want: > > _Named Exports_: > > export var foo = 1; > > _Single Export Object_: > > export var moduleName = { > foo: 1, > bar: function() {} > }; > > _Single Export Functi

RE: ModuleImport

2014-06-20 Thread Ron Buckton
> -Original Message- > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of > Sébastien Cevey > Sent: Friday, June 20, 2014 3:46 AM > To: Axel Rauschmayer > Cc: es-discuss list > Subject: Re: ModuleImport > > On 20 June 2014 11:39, Axel Rauschmayer wrote: > > > Th

RE: Decorators vs Annotations (was April 10 2014 Meeting Notes)

2014-04-15 Thread Ron Buckton
> -Original Message- > From: Erik Arvidsson [mailto:erik.arvids...@gmail.com] > Sent: Tuesday, April 15, 2014 8:38 AM > To: waldron.r...@gmail.com; es-discuss@mozilla.org; Yehuda Katz > Cc: Ron Buckton > Subject: Decorators vs Annotations (was April 10 2014 Meeting Note

RE: Promise.cast and Promise.resolve

2014-02-05 Thread Ron Buckton
Perhaps the unwrapping behavior of .then could be specified as an optional argument in the Promise constructor and .resolve methods. The default behavior is the current standard (i.e. .then auto-unwraps), but a different behavior could be specified: ``` var unwrapPromise1 = Promise.resolve(1);

RE: transpiling ES6 generator functions to ES5: what next?

2014-01-14 Thread Ron Buckton
I haven't had the opportunity to look at the transpiler, but I did something similar in a fork of TypeScript 0.8.3 on CodePlex a little over a year ago (back when StopIteration was part of the spec.) I've been meaning to update it to the current version, so I'll run it through the test suite bel

RE: Promises: final steps

2013-09-05 Thread Ron Buckton
Tasks in C# throw the recorded exception when the Task is finalized by the GC if it hasn't been handled by user code, though I don't know if something similar could be supported for ES7 Promises nor whether or not that makes sense for ES7 promises either. Having Promise rejections hold on to un

RE: Letting RegExp method return something iterable?

2013-08-28 Thread Ron Buckton
The advantage of a lazy execAll, is the ability to break out of the for..of loop without the need to continue to traverse the input string looking for matches. This is the same advantage that the `while(m = re.exec())` has going for it. You can always be greedy by using Array.from or an array co

RE: Killing `Promise.fulfill`

2013-08-19 Thread Ron Buckton
Promise.fulfill/PromiseSource#fulfill made sense when there was no unwrap on the input side of Promise#then: *then:* ```js var foreverPending = new Promise(() => {}); Promise.fulfill(foreverPending).then(x => assert(x === foreverPending)) Promise.resolve(foreverPending).then(() => { /* never reac

RE: setImmediate

2013-08-09 Thread Ron Buckton
For promises using microtasks, one possibility I've been experimenting with in my polyfill is a Promise.yield() method that returns a Promise that resolves after the next time the UI thread gets a chance to drain its event queue (either through requestAnimationFrame or setTimeout). While it wor

RE: generators vs forEach

2013-07-15 Thread Ron Buckton
I assume you are referring to something like Q.async/Q.spawn to turn the generator into an async function using promises? Sent from my Windows Phone From: Ron Buckton<mailto:rbuck...@chronicles.org> Sent: ‎7/‎15/‎2013 5:02 PM To: Bruno Jouhier<mai

RE: generators vs forEach

2013-07-15 Thread Ron Buckton
Bruno, wouldn't yield* work here to delegate the inner yields? Sent from my Windows Phone From: Bruno Jouhier Sent: ‎7/‎15/‎2013 4:12 PM To: es-discuss Subject: Re: generators vs forEach There is no need to

RE: Why does Array.from also take a mapFn?

2013-06-30 Thread Ron Buckton
Couldn't you just do: var squaredSmalls = Int16Array.from((v*v for v of smalls)); Or is the allocation of a generator expensive enough to warrant the mapFn argument? Alternatively, is it the need to support a map on a non-iterable "array-like"? Ron Sent from my Windows Phone

Re: Where'd Promise#done go?

2013-06-18 Thread Ron Buckton
I've often looked at Promise#then() as sugar over Promise#done() for something like: ```js Promise.prototype.then = function(resolve, reject) { return new Promise(resolver => { this.done( value => { try { resolver.resolve(resolve ? resolve(value) : value); }

Re: The Paradox of Partial Parametricity

2013-05-27 Thread Ron Buckton
My apologies, I've seen three use cases. The third use case being the ability to send progress notifications. Sent from Windows Mail From: Ron Buckton Sent: ‎Monday‎, ‎May‎ ‎27‎, ‎2013 ‎12‎:‎47‎ ‎PM To: Andreas Rossberg, Tom Van Cutsem Cc: Mark S. Miller, Brendan Eich, es-discuss Are th

Re: The Paradox of Partial Parametricity

2013-05-27 Thread Ron Buckton
Are there a fixed number of use cases for promise subclasses? I've seen discussions about two possibilities referred to on this list, specifically a lazy-promise and a cancellable promise. I wonder if these two capabilities should instead be part of the Promise/Future API and not have subclasses

RE: Non-generic traps for non-generic objects (was: Overriding Map/etc with get/set hooks?)

2013-05-24 Thread Ron Buckton
Another way to look at this is that there is no way to prevent a caller from using methods from the superclass on a subclass. In other OO languages, its much harder (or nearly impossible depending on the language) to forcibly call a superclass method against a subclass that has been overridden b

Re: Overriding Map/etc with get/set hooks?

2013-05-21 Thread Ron Buckton
What if the default Map prototype had a configurable but non-writable data property for a @@coerceKey symbol that pointed to a default coercion function. You could subclass Map and provide your own @@coerceKey implementation. Then Map.prototype.set.call() would be forced to run the custom coerci

RE: The Paradox of Partial Parametricity

2013-05-10 Thread Ron Buckton
Following Tab's comments on the a Promise monad, I prototyped a Future library based on DOM Future using TypeScript. Since TS has no concept of a union type, I'm using TS overloads to approximate the Ref union type example. It has roughly the following API: ```ts class FutureResolver { accept

RE: Future cancellation

2013-05-01 Thread Ron Buckton
This is where something like an external cancellation source could be more effective: ```js function getUser1(cancelToken) { return doXHR("/user.json", cancelToken); } function getUser2(cancelToken) { // immediate result, no need for cancellation return { "name": "domenic" }; } function g

RE: Future cancellation

2013-04-30 Thread Ron Buckton
> -Original Message- > From: Domenic Denicola [mailto:dome...@domenicdenicola.com] > Sent: Tuesday, April 30, 2013 9:25 PM > To: Jonas Sicking; Ron Buckton > Cc: public-script-co...@w3.org; es-discuss > Subject: RE: Future cancellation > > From: es-discuss-boun..

RE: Future cancellation

2013-04-30 Thread Ron Buckton
Tuesday, April 30, 2013 4:47 PM > To: Ron Buckton > Cc: es-discuss; public-script-co...@w3.org; Tab Atkins Jr. > Subject: Re: Future cancellation > > On Mon, Apr 29, 2013 at 6:57 PM, Ron Buckton > wrote: > > I've created separate gists for three different ways that I a

Re: Future cancellation

2013-04-30 Thread Ron Buckton
catalogue each approach as I’ve come across them specifically to gather this kind of feedback. Best regards, Ron Sent from Windows Mail From: Alex Russell Sent: ‎Tuesday‎, ‎April‎ ‎30‎, ‎2013 ‎2‎:‎54‎ ‎AM To: Ron Buckton Cc: es-discuss, public-script-co...@w3.org, Tab Atkins Jr. These are horribly

Future cancellation

2013-04-29 Thread Ron Buckton
I've created separate gists for three different ways that I am currently investigating as a means to support the cancellation of a Future. These can be found here: 1. Cancellation using Future: https://gist.github.com/rbuckton/5486149 2. Cancellation using Future.cancelable: https

RE: A Challenge Problem for Promise Designers

2013-04-29 Thread Ron Buckton
> -Original Message- > From: Tab Atkins Jr. [mailto:jackalm...@gmail.com] > Sent: Monday, April 29, 2013 1:20 PM > To: Ron Buckton > Cc: Mark Miller; David Sheets; Mark S. Miller; es-discuss; public-script- > co...@w3.org; David Bruant; Dean Tribble > Subject: Re: A

RE: A Challenge Problem for Promise Designers

2013-04-29 Thread Ron Buckton
> -Original Message- > From: Tab Atkins Jr. [mailto:jackalm...@gmail.com] > Sent: Monday, April 29, 2013 11:21 AM > To: Ron Buckton > Cc: Mark Miller; David Sheets; Mark S. Miller; es-discuss; public-script- > co...@w3.org; David Bruant; Dean Tribble > Subject: Re: A

RE: yield* desugaring

2013-04-29 Thread Ron Buckton
> -Original Message- > From: Andy Wingo [mailto:wi...@igalia.com] > Sent: Monday, April 29, 2013 11:56 AM > To: Ron Buckton > Cc: Brendan Eich; es-discuss > Subject: Re: yield* desugaring > > On Mon 29 Apr 2013 19:25, Ron Buckton writes: > > > The des

RE: A Challenge Problem for Promise Designers

2013-04-29 Thread Ron Buckton
; From: Tab Atkins Jr. [mailto:jackalm...@gmail.com] > Sent: Saturday, April 27, 2013 8:32 PM > To: Mark Miller > Cc: David Sheets; Mark S. Miller; es-discuss; public-script-co...@w3.org; Ron > Buckton; David Bruant; Dean Tribble > Subject: Re: A Challenge Problem for Promise Designe

RE: yield* desugaring

2013-04-29 Thread Ron Buckton
Was there consensus on the return value of the various generator methods being { value?, done? } for next/send/throw? Is it needed for close? The desugaring for yield* in the face of using { value?, done? } is more likely (without refutable matching or let expressions for the moment): ```js l

Re: A Challenge Problem for Promise Designers

2013-04-27 Thread Ron Buckton
Here is a case where flattening helps: function executeAndWaitForComplete(command) { return getJSON(commandUrl + command) .then(function (commandResult) { if (commandResult.complete) { return commandResult.model; } var statusUrl = commmandResult.statusUrl; ret

RE: Futures

2013-04-26 Thread Ron Buckton
I have an implementation in Typescript/ES5 at https://github.com/rbuckton/promisejs/tree/master/Variations with a test suite that can be run from node. Ron Sent from my Windows Phone From: Kevin Smith Sent: ‎4/‎26/‎2013 11:47 AM To:

Re: A Challenge Problem for Promise Designers (was: Re: Futures)

2013-04-25 Thread Ron Buckton
I’m not sure I fully grok the use cases for FutureResolver#accept and having Future>. Having to call an Unwrap extension method on a Task> in .NET is an unfortunate necessity. Also, since Future#then implicitly resolves a future it is difficult to return a Future> from a then. In every case w

RE: Futures (was: Request for JSON-LD API review)

2013-04-24 Thread Ron Buckton
Be it Promise or Future, instanceof won't work across frames. It would likely still require a Future.isFuture/Promise.isPromise just as we need to have Array.isArray now. That is, of course, unless we can use symbols for branding in a fashion that library authors could use without forking their

RE: Futures (was: Request for JSON-LD API review)

2013-04-24 Thread Ron Buckton
Resending due to a mail error. > -Original Message- > From: es-discuss-boun...@mozilla.org [mailto:es-discuss- > boun...@mozilla.org] On Behalf Of Tab Atkins Jr. > Sent: Wednesday, April 24, 2013 11:18 AM > To: Domenic Denicola > Cc: Mark S. Miller; es-discuss > Subject: Re: Futures (was:

  1   2   >