Re: New Proposal: Placeholder syntax

2018-12-07 Thread Waldemar Horwat

On 11/28/2018 10:17 AM, Andrew Kaiser wrote:

Hi all,

I have created a short proposal to introduce syntactic sugar for anonymous 
functions in a 'scala-like' manner, linked here 
https://github.com/andykais/proposal-placeholder-syntax.

I am hoping to hear feedback on whether or not this is interesting to people, 
as well as feedback on the proposal itself (e.g. is there a better operator to 
use than ` * `)


This is error-prone:

  const sum = numbers.reduce(? + ?)
transforms into
  const sum = numbers.reduce((x, y) => x + y)

but then:

  const identity = numbers.reduce(?)
transforms into
  const identity = (x) => numbers.reduce(x)
instead of the analogous
  const identity = numbers.reduce((x) => x)

And what would
  const z = numbers.reduce(? + ? > 0)
or
  const z = numbers.reduce(2*(? + ?))
or
  const z = numbers.reduce(foo(? + ?))
transform into?

Waldemar
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: [Feature Request] Built-in `deepCopy/deepClone` (based on the structured cloning algorithm)

2018-12-07 Thread Jordan Harband
You may be interested to read some previous discussions around this topic:
 - https://esdiscuss.org/topic/structured-clones
 - https://esdiscuss.org/topic/the-structured-clone-wars
 - https://esdiscuss.org/topic/object-clone-not-quite-a-proposal
 - https://esdiscuss.org/topic/object-equals-and-object-clone

On Fri, Dec 7, 2018 at 6:00 AM Harry Manchanda 
wrote:

> Heya, I tried before to write this but seems like I wasn't subscribed. Now
> seems like I subscribed so posting it again...
>
> So here we go,
>
> I am posting this after an aftermath of a Github Issue. See =>
> https://github.com/tc39/proposals/issues/150
>
> I would like the JavaScript (ECMAScript) Spec to include built-in
> `deepCopy/deepClone` feature.
>
> Please note that based on the response at Github Issue and also
> considering that the top 3 npm packages for cloning have over 100k weekly
> downloads I am very positive on this and should be really considered.
>
> I think we have two approaches to consider for same
>
> 1. Object Oriented approach
>
> ```js
> // Object.prototype.deepCopy(), Array.prototype.deepCopy(), etc
>
> const harry = {
>   name: 'Harry Manchanda',
>   age: 25,
>   social: [
> {
>   website: 'twitter',
>   username: '@harmanmanchanda',
> },
> {
>   website: 'facebook',
>   username: 'IamManchanda',
> },
>   ],
> };
>
> const dev = harry.deepCopy();
> dev.social[1].website = 'github';
> ```
>
> 2. Functional Programming approach
>
> ```js
> // Object.deepCopy(value)
> // Value expects array, objects and primitives
>
> const harry = {
>   name: 'Harry Manchanda',
>   age: 25,
>   social: [
> {
>   website: 'twitter',
>   username: '@harmanmanchanda',
> },
> {
>   website: 'facebook',
>   username: 'IamManchanda',
> },
>   ],
> };
>
> const dev = Object.deepCopy(harry);
> dev.social[1].website = 'github';
> ```
>
>
> Reason why I think so strongly that everyone in javascript community needs
> this is this
>
> => https://gist.github.com/search?l=JavaScript=deepcopy
> => https://gist.github.com/search?l=JavaScript=deepclone
> => https://github.com/search?l=JavaScript=deepcopy=Repositories
> => https://github.com/search?l=JavaScript=deepclone=Repositories
>
>
> *Thanks,*
>
> *Harman Singh Manchanda ( Harry )*
> *Open Source Team Member - Zurb Foundation
> *
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


[Feature Request] Built-in `deepCopy/deepClone` (based on the structured cloning algorithm)

2018-12-07 Thread Harry Manchanda
Heya, I tried before to write this but seems like I wasn't subscribed. Now
seems like I subscribed so posting it again...

So here we go,

I am posting this after an aftermath of a Github Issue. See =>
https://github.com/tc39/proposals/issues/150

I would like the JavaScript (ECMAScript) Spec to include built-in
`deepCopy/deepClone` feature.

Please note that based on the response at Github Issue and also considering
that the top 3 npm packages for cloning have over 100k weekly downloads I
am very positive on this and should be really considered.

I think we have two approaches to consider for same

1. Object Oriented approach

```js
// Object.prototype.deepCopy(), Array.prototype.deepCopy(), etc

const harry = {
  name: 'Harry Manchanda',
  age: 25,
  social: [
{
  website: 'twitter',
  username: '@harmanmanchanda',
},
{
  website: 'facebook',
  username: 'IamManchanda',
},
  ],
};

const dev = harry.deepCopy();
dev.social[1].website = 'github';
```

2. Functional Programming approach

```js
// Object.deepCopy(value)
// Value expects array, objects and primitives

const harry = {
  name: 'Harry Manchanda',
  age: 25,
  social: [
{
  website: 'twitter',
  username: '@harmanmanchanda',
},
{
  website: 'facebook',
  username: 'IamManchanda',
},
  ],
};

const dev = Object.deepCopy(harry);
dev.social[1].website = 'github';
```


Reason why I think so strongly that everyone in javascript community needs
this is this

=> https://gist.github.com/search?l=JavaScript=deepcopy
=> https://gist.github.com/search?l=JavaScript=deepclone
=> https://github.com/search?l=JavaScript=deepcopy=Repositories
=> https://github.com/search?l=JavaScript=deepclone=Repositories


*Thanks,*

*Harman Singh Manchanda ( Harry )*
*Open Source Team Member - Zurb Foundation
*
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Proposal for faster this assignments in constructor functions

2018-12-07 Thread dante federici
I can see that, although I'm struggling to come to that conclusion if I saw
that block of code fresh. I don't think it would be immediately clear,
though. In your interpretation of "this has 5 arguments", what would you
expect them to be? `constructor(x, y, a, b, c)`? Just prepend them?

I'm trying to work with the idea of the existing constructor function and a
possible shorthand. Another problem with almost any suggestion is how it
may interact with destructuring and expectations (with any additions of
"bind these").

I am highly suspect that any solution that is both ergonomic and concise
could pass.

What about making an explicit `constructor` function invalid in the case of
the shorthand syntax?

```js
class Point(x, y) {
   ...
}

// As shorthand for:
class Point {
  constructor(x, y){
this.x = x;
this.y = y;
  }
}
```

If this kind of syntax can't fly, that's fine, but I feel there isn't going
to be an ergonomic way to have a simple way to bind constructor arguments.
Although that makes things like super calls potentially awkward, we can
also assume that if you extend a class that it calls super in the generated
constructor. I'm not offended by a short hand as my last post, as the
transition is quite natural if you need a more complex use case:

```js
class Point(x, y) {
  toString() { ... }
}

// Oh no, now I have complex logic!
class Point {
  constructor(x, y) {
Object.assign(this, {x, y});
...
  }

  toString() { ... }
}
```
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss