Hacker News new | ask | show | jobs
by trhway 3886 days ago
i want it! it will increase my job security with features like this :

==

String name => firstName + " " + lastName;

And an assignment:

String name = firstName + " " + lastName;

In the first example, the expression is recomputed every time name is evaluated. In the second example, the expression is computed once and the result assigned to name.

==

A function which looks like just a variable and recomputed each time! Happy debugging my code, suckers!

2 comments

i've been using fat arrows for function definitions in es6, and haven't had a problem. I think the confusion in your code has more to do with poor code than fat arrows.
Speaking as someone who has done quite a lot of work using languages with terse lambda syntax...

...that's just not ever an issue.

i think the poster thinks that with the fat arrow definition, name becomes an implicitly called function wherever it is used. I wouldn't like that either.

but, I dont know if thats really the case though (I dont know ceylon). I think that fat arrow line would just become a no op instead, creating a lambda and throwing it away immediately ("name" being the param name in the lambda and nothing more).

It's just a getter. Lots of languages have getters.
Ah that makes sense, thanks. I missed the implicit "we're in a class definition" in the original post.