Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Isn't a closure a function that carries around state?

Well, that's the question, isn't it?

In our present context, to me "state" suggests something persistent and independent, something that could be read and possibly written by multiple paths.

Do you view creating a closure as customising an existing function with specific data, or as defining a whole new function? I think of it as the latter, and it just happens to be at run-time. The resulting function is still pure, and any customisation based on particular data is an integral part of it that isn't externally visible, which doesn't feel "stateful".



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

Search: