Reputation: 3063
I am a Swift developer and am trying to adopt a functional / reactive style in my code. I have been using ReactiveCocoa
in all my projects and I have started giving RAC 3.0
a try. One thing I have seen is that in project, there is heavy use of curried functions that have a global scope (i.e. not tied to an instance).
What I am keen to understand is why global functions is a good idea?
Is this something that is unique to curried functions or is it a general functional programming attribute?
Upvotes: 2
Views: 179
Reputation: 498
for my experience with haskell (which do not have mutable varibles),i usually write all functions (and auxiliary ones) globally,which is convenient for testing.After debugging i usually move then from global-level to local one,but for library development,we can simply choose not to expose the helper functions to external usage.
Global function definition just means that you can access it any where (not strictly) within this module/file,or export it.
Upvotes: 0