Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Anders Rundgren
On 2018-05-20 05:48, Hikaru Nakashima wrote: Sorry for lack of words. What I am talking about is a new proposal to modify `JSON.parse()`. Then I understand :-) I'm not entirely convinced that this is a workable approach because it breaks if you don't use a reviver but I leave that to the ES

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread J Decker
On Sat, May 19, 2018 at 8:48 PM, Hikaru Nakashima wrote: > Sorry for lack of words. > What I am talking about is a new proposal to modify `JSON.parse()`. > There is json5 (json5.org; github.com/json5/json5; npmjs.com/package/json5) or I would entertain such things for

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Hikaru Nakashima
Sorry for lack of words. What I am talking about is a new proposal to modify `JSON.parse()`. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Anders Rundgren
On 2018-05-20 05:25, Hikaru Nakashima wrote: I would like to be called and interpreted like `BigInt("465456456465465465465465464646")` when first parsing the numeric string. This means that all numerical values passed to the `reviver` function and all numerical values contained in the

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Hikaru Nakashima
I would like to be called and interpreted like `BigInt("465456456465465465465465464646")` when first parsing the numeric string. This means that all numerical values passed to the `reviver` function and all numerical values contained in the post-analysis object are `BigInt`.

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-19 Thread kdex
To me, what you're actually seeking to discuss looks less related to physics and more like an extension to ECMAScript's `import` syntax. Would you please describe it a little more? A good conversation starter, preferably without any domain-specific context (i.e. physics), would entail: - the

Re: Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-19 Thread Abdul Shabazz
jsol files can be seen as distilled Reductions which are confluent and semi well-founded. -- Abdul S. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Proposal: Phase-Invariant Einno Soliton Templates

2018-05-19 Thread Jordan Harband
What exactly are you proposing? Do you have a userland library that implements whatever you're proposing? Why are the states of matter in any way relevant to a programming language? On Sat, May 19, 2018 at 6:12 PM, Abdul Shabazz wrote: > > Of the five (5) known forms of

Proposal: Phase-Invariant Einno Soliton Templates

2018-05-19 Thread Abdul Shabazz
Of the five (5) known forms of matter: 1. Solid (well-structured arrangement of tightly bound atoms, found in ice) 2. Liquid (unstructured arrangement of tightly-bound atoms) 3. Gas (loose arrangement of atoms) 4. Plasma (Properties of liquid, electricity, and magnetism found @

Re: Array.prototype.repeat

2018-05-19 Thread Jordan Harband
perhaps http://array.build On Sat, May 19, 2018 at 1:26 AM, Cyril Auburtin wrote: > pro: I think it's quite frequent to need `Array.from({length: .. }, () => > ...)` > con: you can't generate dynamic data (like an array of random values) > > I think in the end this

Re: Overload str.replace to take a Map?

2018-05-19 Thread Mathias Bynens
Hey Kai, you’re oversimplifying. Your solution works for a single Unicode symbol (corresponding to a single code point) but falls apart as soon as you need to match multiple symbols of possibly varying length, like in the `escapeHtml` example. On Sat, May 19, 2018 at 8:43 AM, kai zhu

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Anders Rundgren
On 2018-05-19 14:48, Hikaru Nakashima wrote: Is it better to be able to pass the option object as the second argument like this? ``` let option = { number: BigInt, reviver: conversion_function } JSON.parse( json_string, option ) ``` All JSON numbers are interpreted as follows ```

Re: "Stupid" JSON Number Serialization Question

2018-05-19 Thread Hikaru Nakashima
Is it better to be able to pass the option object as the second argument like this? ``` let option = { number: BigInt, reviver: conversion_function } JSON.parse( json_string, option ) ``` All JSON numbers are interpreted as follows ``` option.number( number_string ) ```

Re: Overload str.replace to take a Map?

2018-05-19 Thread kai zhu
again, you backend-engineers are making something more complicated than needs be, when simple, throwaway glue-code will suffice. agree with jordan, this feature is a needless cross-cut of String.prototype.replace. ``` /*jslint node: true */ 'use strict'; var dict; dict = { '$': '^',

Re: Adaptive Notation for JSON

2018-05-19 Thread Andrea Giammarchi
My 2 cents. For classes with a reachable namespace from the window / global and serializable arguments, you could use an ad-hoc structure to define complex values: ```js // the converter const toJSONStruct = value => Object.defineProperty( { "arguments": Symbol.iterator in value ?

Re: Array.prototype.repeat

2018-05-19 Thread Cyril Auburtin
pro: I think it's quite frequent to need `Array.from({length: .. }, () => ...)` con: you can't generate dynamic data (like an array of random values) I think in the end this `Array.prototype.repeat` is not a good idea, but there should be something easier/less verbose than `Array.from({length:

Re: Overload str.replace to take a Map?

2018-05-19 Thread Cyril Auburtin
You can also have a ```js var replacer = replacements => { const re = new RegExp(replacements.map(([k,_,escaped=k]) => escaped).join('|'), 'gu'); const replaceMap = new Map(replacements); return s => s.replace(re, w => replaceMap.get(w)); } var replace = replacer([['$', '^',

Re: Overload str.replace to take a Map?

2018-05-19 Thread Isiah Meadows
Here's what I'd prefer instead: overload `String.prototype.replace` to take non-callable objects, as sugar for this: ```js const old = Function.call.bind(Function.call, String.prototype.replace) String.prototype.replace = function (regexp, object) { if (object == null && regexp != null &&

Adaptive Notation for JSON

2018-05-19 Thread Anders Rundgren
Trying again... It turned out that the Oracle/Java JSON API actually is I-JSON compatible by default through a method which I have coined "Adaptive Notation": {   "BigDecimal.large": "1E+999",   "BigDecimal.small": 1,   "BigInteger.large": "240777489003222785532321",   "BigInteger.small":