Got it, that make sense. I like the motivation behind the proposal. If it moves forward, I could see people possibly not liking (and bikeshedding) on the bare dot syntax, especially as it adds a new form of defining a function. Although, personally, I got used to it in less than a minute.
On Fri, Jun 21, 2019 at 7:02 AM Simon Farrugia <simonfarrugi...@gmail.com> wrote: > Thanks for the feedback Scott, > > Regarding your concern about the array example, both expressions are valid > but different: > > This (what you wrote) would map the array of users to an array of emails > and declare getEmailsList as an array of emails. > ``` > const getEmailsList = users.map(.contacts.email); > ``` > > While this (my array example) would define getEmailsList as a function > that takes an array of users and returns an array of emails. > ``` > const getEmailsList = .map(.contacts.email); > > On Fri, Jun 21, 2019 at 3:27 PM Scott Rudiger <scottrudi...@gmail.com> > wrote: > >> I can appreciate the intent of the proposal. 👍 >> >> Minor nit with one of the examples: >> >> // user[] => email[] (With Arrays) >> >> const getEmailsList = users => users.map(user => user.contacts.email); >> >> const getEmailsList = .map(.contacts.email); >> >> ``` >> >> >> I would think with the proposal you'd still need to reference `users`. >> Otherwise what are we mapping? >> >> >> ``` >> >> const getEmailsList = users.map(.contacts.email); >> >> ``` >> >> On Fri, Jun 21, 2019, 4:49 AM Simon Farrugia <simonfarrugi...@gmail.com> >> wrote: >> >>> Selector/Select Expression >>> >>> >>> >>> Doing functional & reactive programming is currently really verbose in >>> JavaScript. >>> >>> Hopefully this issue will be alleviated with the addition of the pipe >>> operator in the near future. >>> >>> >>> >>> One things you end up doing most when doing fp is doing simple >>> selections (mappings) on objects & arrays. This unfortunately becomes >>> really verbose and repetitive. >>> >>> >>> >>> What I'm proposing is to be able to collapse/simplify selector arrow >>> function expressions like this: >>> >>> >>> >>> ``` >>> >>> // user => email >>> >>> const getEmail = user => user.contacts.email; >>> >>> ``` >>> >>> >>> >>> to something like this: >>> >>> >>> >>> ``` >>> >>> // user => email >>> >>> const getEmail = .contacts.email; >>> >>> ``` >>> >>> >>> >>> More examples: >>> >>> >>> >>> ``` >>> >>> // user[] => email[] (With Arrays) >>> >>> const getEmailsList = users => users.map(user => user.contacts.email); >>> >>> const getEmailsList = .map(.contacts.email); >>> >>> ``` >>> >>> >>> >>> ``` >>> >>> // Usage with pipeline operator >>> >>> pipe(user, map(user => user.contacts.email)) >>> >>> user |> .contacts.email >>> >>> ``` >>> >>> >>> >>> I think this would work really well, particularly in conjunction with >>> the pipeline operator, resulting in more concise and expressive code >>> improving readability. >>> >>> This is just syntactic sugar, but same as in the case of the pipeline >>> operator, selector functions are so intrinsic and commonplace to any >>> code base, that I would think it's worth considering. >>> >>> >>> >>> I would appreciate hearing your thoughts. Thanks. >>> _______________________________________________ >>> 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