f(x) interface

f(x) = {
      return x+1

This could be possibility for JavaScript becoming good language for math, and going more towards being universal. Mathematics would for sure like idea of writing function definitions like this.

It doesn't collide with anything else, because assign to return case doesn't happen in language, so it can be easily distinguished in tokenizer. I'm sure it could make language more attractive on the first looks along with other proposals could do JavaScript really nice name, I think it could be wonderful in mathematics due to abundance of data visualization libraries and even support for access to WebGL and WebCL which bundled as sandboxed application is ideal to share the computation or even to make distributed computing that use spare resources totally sandboxed, therefore with no fear of using of other's software or getting infected while contributing by computing power.

I'm sure it could help JavaScript.

I'm just not sure if use this spare space as pure function, maybe with keyword "use" inside to import something from the outside, to encourage more pure functions in the programming.

It would require engines to not know if it’s an object literal until they hit the return statement - something not all functions even have.

I’m not sure why adding this syntax complexity is complex than function f(x) { or const f = (x) => {

1 Like

I highly doubt it would require...

It requires engine to do not execute left side of assign statement, nothing more nothing less.
How many times you executed left side of assign statement?

On right side there are brackets. Brackets can be parsed as ()=>{} and left side of assign can be parsed to token and arguments. Right side wouldn't have to be just brackets, but it could be statement like f(x) = x + 1

Then, because left side of assign is function definition, whole assign statement would be defined as function.

get(user) = api.fetch({
     username: user

get is is not resolved, it's function, therefore

var get = (user)=>{
     return api.fetch({
          username: user

it will also make functions that begin with return statement more dense.

I highly doubt that it is function syntax that prevents javascript from being attractive or suitable for mathematics.

1 Like

JavaScript is no way prevented against mathematics, once somebody will adjust numbers so that 2+7 will equal 9 and it's beautiful way of expressing maths.

Then why would we need yet another function syntax? Arrow functions are fine already.

const f = x => x+1;

const get = username => api.fetch({username});

It's not quite need, it's about first impression.