11 ms·
Not being able to pass functions as values is a show stopper - it's arguably the single most important tenet of functional languages.
by efnx 11y ago
Not being able to pass functions as values is a show stopper - it's arguably the single most important tenet of functional languages.
- kungfooguru 11y agoYou can pass functions. The article was saying not to nest function calls.
- nathancahill 11y agoI understand her point to be about passing called functions. Surely passing functions as values (partials, etc) is fine? final_function(maybe_function(X)) vs final_function(maybe_function)(x) Disclaimer, not familiar with Erlang syntax, so the above example is psuedo-code. "If you need more than 3 levels of indentation, you're screwed anyway, and should fix your program." --Linus
- kungfooguru 11y agoRight, you can pass a function: final_function(fun() -> maybe_function(X) end) or final_function(maybe_function, X) if final_function does: final_function(Function, X) -> Function(X).
- oinksoft 11y agoSmall thing, but `final_function` here needs to be passed `fun maybe_function/1`, not the atom `maybe_function` alone.
- kungfooguru 11y agoOops, yup. Meant to make it explicit since you can also do: ?MODULE:Function(X)
- querulous 11y agoi believe she was talking specifically about `foo(bar(baz(X)))` and not passing functions themselves as arguments
- nathancahill 11y ago*she When in doubt, 'they' is a safe bet too.
- efnx 11y agoAhh - that makes more sense. Still, this practice wouldn't make much sense for the ML family of languages.
- rdtsc 11y agoYou can't, where? You mean in general in some functional languages? Sorry I don't see how your comment fits with the gp's comment.