3 ms·
Yeah, this is the OOP perspective on getters and setters. Andre talks from the FP perspective.
by azangru 8y ago
Yeah, this is the OOP perspective on getters and setters. Andre talks from the FP perspective.
- masswerk 8y agoHowever, in JS they have a specific [read, established] meaning, in the OOP sense. [It's a term established in the language specification.]
- ponyfleisch 8y ago> [It's a term established in the language specification.] I'd say JS getters/setters are syntactic sugar for the OOP concept the author is talking about.
- masswerk 8y agoIt's the main mechanism in JS to define functional accessors, at least since ECMA-Script 3. Before this, the terms have been used loosely, as well, for explicit accessor methods (like in Java). [Edit] Correction: should have been, at least since ECMA-262 5th Ed.
- amelius 8y agoSetters have no equivalent in (pure) FP.
- com2kid 8y agoSaying console.log is a setter seems horrifically wrong, console.log abstracts out IO and doesn't necessarily mutate any state that is within the program. It leaves the happy confines of the program's abstraction/memory model and puts data out into The Real World. That all said, within the model being established by the author, everything does make sense, eventually, and the difference between IO output functions and setters, for the sake of the abstractions that the author builds, is non-existent.
- AzzieElbab 8y agoState monad?