The following would assign to the address foo in obj if and only if it has
not already been assigned.
var obj = {}
var foo = Math.random()
obj[foo] ?= 1
The same can be said for:
var undef
undef ?= 1
Which could both be transpired to
type obj[foo] === 'undefined' && obj[foo] = 1
or
type a
wrote:
>
>> This sounds like https://github.com/tc39/proposal-pattern-matching
>>
>> El 31/1/20 a les 10:57, Sultan ha escrit:
>>
>> For example, the following:
>>
>> switch (value) {
>> case 0...9: break
>> case 'a'...'z': break
&g
For example, the following:
switch (value) {
case 0...9: break
case 'a'...'z': break
}
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
Can you currently do this with the "super" keyword outside of classes?
On Fri, Sep 6, 2019 at 9:16 PM Jordan Harband wrote:
> `var itself = 3;` means that your choice of keyword wouldn't be an option;
> you'd be limited to something that was currently a syntax error.
>
> On Fri, Sep 6, 2019 at
Like Symbol.iterator, a Symbol.inspect symbol for use in implementing
cross-platform console display introspection.
Currently node has something akin to this with a magic inspect method on
objects.
This would pave a cow path for how different platforms can afford this
ability to consumers
Counter proposal: A uniform signature for types, denoted by:
const name: primitive-type?;
Where primitive types are denoted as:
const name: symbol;
const name: string;
const name: number;
const name: object;
const name: boolean;
const name: function;
And types can later be extended to afford
Afford array destructuring to Array-like objects.
const [a, b] = {0: a, 1: b, length: 2}
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
The following is currently possible with setTimeout from the browser
const i = setTimeout(() => {})
Where "i" is a number from 0 incrementing towards infinity.
This however has the issue that it is entirely global, and as the title of
the post suggests the idea is to strike a middle ground
For example given a set of values. A function that checks whether the values of
the object are equal could shallow compare the values of each property in the
object. However this heuristics falls short for inline/bound functions that
share the same target/backing but are only different with
A way to determine if two bound functions reference the same target
function.
For example:
function proto () {}
const a = proto.bind(null, 1)
const b = proto.bind(null, 2)
console.assert(Function.isSameTarget(a, b))
___
es-discuss mailing list
Where there any attempts to allow factory functions the ability to assume
the name of the binding they are assigned to?
Consider the following:
function factory () { return function () {} }
var foo = factory()
console.assert(foo.name === 'foo')
___
Was there any reason Promise.resolve was not afforded the ability to
dispatch outside of `this` pointing to the `Promise` constructor?
For example:
const {resolve} = Promise
resolve(1234)
This currently throws.
___
es-discuss mailing list
This is expected and by design. For example obj[‘#invalidPrivateSigil’] is also
not invalid. The affordances would be the same.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
That might have been the case, but the expectation that an unquoted form should
equally have a quoted form or vice-versa is not an issue in practice given the
presence of a similar but opposite semantic in the private sigil access
notation proposal: object.#validPrivateSigil ->
The former as the following is equally invalid syntax errors:
const font = 1
const size = 1
const a = {
font-size: 10
}
const b = {
font+size: 10
}
___
es-discuss mailing list
es-discuss@mozilla.org
Is there any reason that dash-case keys are not supported in the object
literal syntax.
For example:
const style = {
font-size: 10
}
Compared to what one needs to do today:
const style = {
'font-size': 10
}
___
es-discuss mailing list
Consider the following is not possible today:
function foo ([a, b] = [1, 2]) {}
foo([2, 3])
While the the following is outside of function arguments:
const arr = [1, 2]
const [a, b] = arr
Is there any reason for the current status quo?
___
The ability to both name and de-structure an argument.
Relying on the spread operator does not archive the same effect considering
that the spread operator "by design" has some short-comings related to
exotic objects when the objects in question have a rich prototype you want
to preserve.
t; },
>> prototype: {
>> configurable: true,
>> writable: true,
>> value: fn.prototype
>> }
>> });
>> }
>> ```
>>
>> This should apply your bound arguments before any arguments supplied by
>> the calle
Consider the following example:
var foo = (function(a) { console.assert(this === obj) }).bind(undefined, 1)
var obj = {foo: foo}
Calling foo from obj:
obj.foo(1)
Would result in an assertion. How does one go about preserving the this
reference of the caller. That is i want to use .bind to only
const [ , setState] = useState(0)
Thanks i forgot about that.
On Fri, Jan 11, 2019 at 5:31 PM Claude Pache wrote:
>
>
> > Le 11 janv. 2019 à 14:02, Sultan a écrit :
> >
> > Placeholder operator: !
> >
> > Use in function parameters(maintains arity without
Placeholder operator: !
Use in function parameters(maintains arity without creating a named
binding):
const foo = (a, b, !) => {}
Use in de-structuring(allows you to capture further along a tuple without
creating a named binding):
const [!, setState] = useState(0)
An operator syntax for the the "typeof" pattern used to detect if a
environment/object has a value:
if (typeof variable === 'undefined') {...}
if (typeof object.key === 'undefined') {...}
This could manifest in destructuring as the following
var fn = ({ key ||= 1 }) => {
}
And with variables
>what're the benefits over a object indexed by numbers `const o =
Object.create(null); o[0] = 12; ...`?
Better "optimisable" heuristics in a similar vain to `TypedArrays`. Most
engines have perf cliffs with indexed objects after a certain threshold,
Memory: at some point indexed objects have to
nes" or as close to a C-like:
a = malloc(sizeof(void*)*10)
as JavaScript could potentially get.
On Thu, Jan 10, 2019 at 11:54 AM Jordan Harband wrote:
> Why would this be better than `const a = []; Object.setPrototypeOf(a,
> null)`?
>
> On Thu, Jan 10, 2019 at 12:09 AM Sultan wro
on
> it; a function with no prototype wouldn't have .call/.bind/.apply - length
> and name are own properties of functions, and length is an own property of
> an array, so you'd get those regardless.
>
> (`Array.from({ length: 1000 })` already creates an array of length 1000
> withou
Identical to Object.create but for Arrays and Functions.
This method will allow you to create arrays with no prototype.
This would allow authors the ability to use array objects as state
containers without the need to resort to index-based objects with
Object.create(null, length)
When you want
>>> > },
>>> > }
>>> > function makeCallable(obj) { return new Proxy(obj, handler) }
>>> >
>>> > // Your example, ported
>>> > const obj = makeCallable({
>>> > [callable]: function (...args) { return th
Something along the lines of Symbol.iterator protocol for defining callback
objects i.e: Symbol.callable:
const obj = {
[Symbol.callable]: function (...args) { return
this[Symbol.for('value')] },
[Symbol.for(''value')]: 'value',
}
assert(obj() === 'value')
proposal.
>
> This leaves out self-binding, but you could always use a local variable if
> necessary. (It's like one extra line, maybe 3, and it's not common at all.)
> On Fri, Nov 16, 2018 at 15:09 Sultan wrote:
>
>> The missing colon ":" is intentional.
>>
>>
The missing colon ":" is intentional.
On Fri, Nov 16, 2018 at 10:57 PM J Decker wrote:
>
>
> On Fri, Nov 16, 2018 at 11:23 AM Sultan wrote:
>
>> As the name suggests; An update to the grammar related to methods on
>> objects/classes to support arrow method
As the name suggests; An update to the grammar related to methods on
objects/classes to support arrow methods:
today: {render() { return 'Hello' }}
proposed addition: {render() => 'Hello'}
This could be some-what linked to class fields in the class variant; That
is what does "this" refer to when
What stops you from doing this with try...finally?
function doSomeDbWork() {
try { return databasepool.getConnection(); } finally {
connection.release(); }
}
On Thu, Sep 20, 2018 at 1:01 PM, Ayush Gupta wrote:
> Apologies, I meant to use `async-await` in the example but I missed it.
>
>
is solved, does the below mean anything
> if (Math.random() < 0.5) {
> module School {
> export function getPersonType() {}
> }
> }
>
> If not, if inline modules are defined eagerly, what advantages, besides
> making life easier for transpiler writers, would inline mod
Are there any open proposals/discussions related to creating ES modules
inline? For example:
```
import getPersonType from School
module School {
export function getPersonType (person) {
switch (person) {
case 'Teacher': return 'A teacher'
case 'Director': return 'A director'
}
}
}
One of the use case for this is – given a function that is either one that
returns an instance or one that returns an explicit return value, but would
otherwise throw if invoked without the "new" keyword.
Always being able to safely invoke it with "new" is a nice guarantee to
have that wouldn't
om>
wrote:
> On 04/17/2018 02:26 PM, Sultan wrote:
>
>> In the transpilation you created the field using "registry.set(this, {id:
>>> 0})"
>>> in the constructor. If you then claim that any write to the field can
>>> also create it,
gle.com>
wrote:
> On 04/17/2018 01:50 PM, Sultan wrote:
>
>> >That would contradict your previous answer to the hijacking question.
>>
>> Can you point out the contradiction? The private field is still being
>> written to by the providing class.
>>
>
&g
an you provide an example of what this looks like with the current
public/private fields proposals?
On Tue, Apr 17, 2018 at 11:20 PM, Waldemar Horwat <walde...@google.com>
wrote:
> On 04/16/2018 05:47 PM, Sultan wrote:
>
>> >An instance has a fixed set of private fields whi
fields?
Not sure i understood what you mean by this?
On Tue, Apr 17, 2018 at 1:43 AM, Waldemar Horwat <walde...@google.com>
wrote:
> On 04/13/2018 09:41 PM, Sultan wrote:
>
>> >Writing your private field to an object that's not an instance of your
>> class.
>> &g
AM, Michael Theriot <
michael.lee.ther...@gmail.com> wrote:
> I'd imagine that would fail the same way proxies fail on typed arrays.
>
> > On Apr 13, 2018, at 6:26 PM, Waldemar Horwat <walde...@google.com>
> wrote:
> >
> >> On 04/13/2018 01:38 AM, Sultan wrote:
The proposal is an explainer with regards to an alternative sigil-less
syntax to back private fields/methods.
>What does private(this)[property] do?
"private(this)[property]" and alternatively "private[property]" or
"private.property" all invoke access of a private "property" on the "this"
03-21#10ivb-javascript-classes-11
>
> -
>
> Isiah Meadows
> m...@isiahmeadows.com
>
> Looking for web consulting? Or a new website?
> Send me an email and we can get started.
> www.isiahmeadows.com
>
>
> On Thu, Apr 12, 2018 at 2:11 PM, Sultan <
[Strawman] Private methods and fields for JavaScript: https://github.
com/thysultan/proposal-private-methods-and-fields
```js
class A {
private id = Symbol('unique')
equal(instance, property) {
return private(this)[property] == private(instance)[property]
}
}
const x = new A()
44 matches
Mail list logo