Hacker News new | past | comments | ask | show | jobs | submit login

Excellent heuristics for any functional language, not just Erlang.



Not being able to pass functions as values is a show stopper - it's arguably the single most important tenet of functional languages.


i believe she was talking specifically about `foo(bar(baz(X)))` and not passing functions themselves as arguments


Ahh - that makes more sense. Still, this practice wouldn't make much sense for the ML family of languages.


*she

When in doubt, 'they' is a safe bet too.


I 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


Right, 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).


Small thing, but `final_function` here needs to be passed `fun maybe_function/1`, not the atom `maybe_function` alone.


Oops, yup. Meant to make it explicit since you can also do: ?MODULE:Function(X)


You can pass functions. The article was saying not to nest function calls.


You 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: