Why are people so concerned about anonymous functions? The facts that you ca Defoe a function inside a function, and that they are object make named functions as good as anonymous ones.
> Anonymous functions are vital to any modern high level language.
I don’t think you’re wrong, but I am also not experienced enough to know why this would be the case. What is the virtue of having an anonymous function? I get that it makes code somewhat easier to read and write if you’re only using the function once and it’s short, but that seems like an edge case. What am I missing?
Can you not `func(foo){}`? Because that is what would bother me.
`func(foo){}` and `(foo) ->` seem too similar, for my taste at least. Sure, the difference is that one is always anonymous, where as one is sometimes anonymous.. but we've been using `function` as both named and anonymous for ages
This is the silliest thing I see paroted. Anonymous functions are there for one offs. Sometimes a one-off is two lines. Breaking it out into a separate function is ridiculous.
You end up seeing functions declared within functions so that people can work around this limitation and it is grotesque.
Honest question: If you are making an anonymous function longer than one line, shouldn't you just make a normal function? What are the use cases for large anonymous functions?
Fair, but seems inconsistent to have `fn` instead of `function` like we use for anonymous functions - unless `fn` acts like an alias to `function` now (which doesn't sound like is the case) which wouldn't be as ambiguous for the compiler to figure out
Anonymous functions as an expression do have their purpose, unlike the author has stated, especially when you want to isolate different blocks of code from each other by putting them each in a different scope.
I see what you meant now. Though it seems you are mixing notions of anonymous function and function as an argument of higher order functions (it doesn't have to be anonymous).
reply