Proposal: Property Accessor Function Shorthand

Michael Luder-Rosefield rosyatrandom at
Tue Dec 3 10:43:14 UTC 2019

At the cost of adding more code, but giving more power, perhaps what we
want is something akin to Kotlin's `it` keyword:

*it: implicit name of a single parameter*
*It's very common that a lambda expression has only one parameter.*
*If the compiler can figure the signature out itself, it is allowed not to
declare the only parameter and omit ->. The parameter will be implicitly
declared under the name it:*
ints.filter { it > 0 } // this literal is of type '(it: Int) -> Boolean'

What we'd want is something concise and non-ambiguous to fulfill the same
role; something that cannot currently be a valid identifier, maybe. This is
the point where I start scanning the keyboard for underutilised symbols...
I'm thinking the hash symbol would work. To re-use the original example:

const activeProducts = products.filter(;
const productNames =;
const sortedProducts = _.sortBy(products,;
const { true: activeProducts, false: inactiveProducts } =

It makes intuitive sense in 2 ways, I think; # makes you think of the
object hash you're extracting a property from, and also is familiar as
something's id from CSS selectors.

We could also extend it to represent multiple parameters: # is also aliased
as #0, the 2nd parameter is #1, etc.

Further, dynamic properties would work too: `const fooProducts =
Dammit babies, you've got to be kind.

On Mon, 2 Dec 2019 at 22:32, Waldemar Horwat <waldemar at> wrote:

> On 11/24/19 9:17 PM, Bob Myers wrote:
> > FWIW, the syntax `.propName` does appear to be syntactically unambiguous.
> It conflicts with contextual keywords such as `new . target`.
>      Waldemar
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list