3 ms·
I haven't the faintest clue what point you're trying to make but I'm sure it's very clever.
by na85 6y ago
I haven't the faintest clue what point you're trying to make but I'm sure it's very clever.
- bcrosby95 6y agoThe point is the graph of data dependencies in an FP system doesn't necessarily look any different than in an OO one.
- andi999 6y agoClosures and internal state of objects are basically the same thing.
- throwaway894345 6y agoI don't usually deal with stateful closures. In OO we often have file objects, and if you call Close() on said object, subsequent Read() invocations fail because the encapsulated state has changed. What's the closure analog for this?
- lostcolony 6y agoYou've never worked with a generator before? That's a stateful function. For throwing after a file handle is closed, something like - const read = (fileHandle) => { return () => { if io:isOpen(fileHandle) && io:hasNext(fileHandle) => { return io:readNext(fileHandle) } else if io:isOpen(fileHandle) {return undefined } else {throw "File is closed"} } }(myFile) read() read() io:close(myFile) read() //throws