2
votes
Are there any functional approaches, to have variables that feel global (no need to pass them around explicitly), yet are local to an instance?
You are correct in that lots of languages, even OOP languages use tricks like this. eg HttpContext.Current in net framework.
You need to access a context for the current operation, but rarely, so you ...
2
votes
Are there any functional approaches, to have variables that feel global (no need to pass them around explicitly), yet are local to an instance?
As the experts in this community pointed out in the comment, the solution is obvious: use OOP, enclose the state in objects and live a happy life:
// myLibrary/index.ts
import {F} from './f';
export ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
javascript × 2128web-development × 177
node.js × 143
html × 142
jquery × 121
design-patterns × 111
php × 108
web-applications × 93
design × 81
architecture × 76
css × 76
java × 72
html5 × 66
ajax × 65
object-oriented × 61
angularjs × 61
c# × 56
python × 56
functional-programming × 50
unit-testing × 49
coding-style × 45
programming-practices × 42
programming-languages × 42
security × 42
performance × 42