I wonder whether a method in a functional programming language should receive all variables from the argument list, or whether it is ok to use variables from the outer scope?But let me explain the context firts: The enviroment where I'm working is focused on programming (or better: scripting) Scala in the Scala-REPL / Scala-Notebook. So all methods we define are just used within the REPL, so there is no outer scope. The methods we define are never used from outside as you would do in a normal OO environment. So by methods, we actually mean functions... Given this premise, I always try to define my functions (more precisely: methods) to be self-contained, i.e. that no variable is accessed from the outer scope. This has the advantage that I can re-arange my code, or even copy-paste my method to another script and re-use it. The disadvantage is that the method's argument-List is blown up and may become very long. In this case, I normally define dedicated data structures (e.g. for constants) and pass them in as 1 variable.So my question is: Should I always pass all variables excplicitly or (under what circumstances) is it fine to access the outer scope?
Should I pass all arguments to a method explicitly in functional programming?
functional programming;scala