New Proposal: Placeholder syntax

Andrew Kaiser kaisea.rpi at gmail.com
Wed Nov 28 19:56:37 UTC 2018


This proposal also works with simple math operations and for accessing
fields on objects. The partial application lists these expressions as
invalid.

```js
// invalid
f(x + ?)          // `?` not in top-level Arguments of call
x + ?             // `?` not in top-level Arguments of call
?.f()             // `?` not in top-level Arguments of call
```
Admittedly they chose not to include these operations because of the
complexity it would add to the transpilation, but the placeholder proposal
is simpler in nature. The partial application proposal alters what is
returned by a function call, the placeholder proposal replaces an argument
inline, and the value a called function returns does not change.

On Wed, Nov 28, 2018 at 2:35 PM Jordan Harband <ljharb at gmail.com> wrote:

> It seems like the partial application proposal covers all of the use cases
> of yours, at a first glance. What does yours offer that partial application
> does not?
>
> On Wed, Nov 28, 2018 at 11:23 AM Andrew Kaiser <kaisea.rpi at gmail.com>
> wrote:
>
>> Do you see a way these proposals can work together? I believe they are
>> solving different needs. Both proposals produce a new anonymous function,
>> but partial application deals with currying, while the placeholder proposal
>> tries to prevent writing a function at all. I can actually see the two
>> working together:
>>
>> ```js
>> const filenames = ['file1.txt', 'file2.txt' 'output.log' ]
>> const fileContainsContent = (filename, content) =>
>> fs.readFileSync(filename).toString().includes(content)
>>
>> const fileSearchers = filenames.map(fileContainsContent(*, ?))
>> const filesContainingSearch = fileSearchers.filter(searcher =>
>> searcher('foobar'))
>> ```
>>
>> This isn't a very useful example, but you can see how the proposals
>> differ accomplish different things
>>
>> On Wed, Nov 28, 2018 at 1:30 PM Jordan Harband <ljharb at gmail.com> wrote:
>>
>>> You may be interested in the partial application proposal:
>>> https://github.com/tc39/proposal-partial-application
>>>
>>> On Wed, Nov 28, 2018 at 10:17 AM Andrew Kaiser <kaisea.rpi at gmail.com>
>>> 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 ` * `)
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> es-discuss at mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20181128/a4ff5855/attachment-0001.html>


More information about the es-discuss mailing list