3 ms·
What if the cache involves IO? The behaviour is then assuredly not pure.
by Veedrac 12y ago
What if the cache involves IO? The behaviour is then assuredly not pure.
- asQuirreL 12y agoWhat sort of a cache would use IO? Not any cache I've heard of. (Genuinely interested)
- fyolnish 12y agoA cache too big to fit in memory
- Agathos 12y agoAny cache that is provided by an external process, or even by a remote machine, such as memcached.
- asQuirreL 12y agoI guess I should clarify and say "What sort of a cache would use IO and make a pure function impure?". Even if the cache is so large that it doesn't fit in memory, its behaviour would still be referentially transparent.
- Veedrac 12y agoThat's only if you don't count the IO itself as a side-effect. Does a language like Haskell give you the choice? If so,would it be idiomatic?
- peterfirefly 12y agoOne you want to keep around between invocations of the program?
- yummyfajitas 12y agoWhen you do this, the type system should reflect the fact that function has changed it's signature from `A => B` to `A => MaybeDoesntReturnOrHasLatency[B]`. Then the compiler will force downstream clients to take this into account, preventing weird hard to debug errors later on.
- Veedrac 12y agoFWIW, I'm not arguing about should or shouldn't - I'm just strengthening the original argument. That said, I don't think small bounded latency is a good thing to encode in a typesystem, much as I don't think runtimes should be encoded in a typesystem. It gives too much inflexibility for too little gain.
- SamReidHughes 12y agoI have wanted small bounded latency to be encoded before. (I'd also want the ability to ignore that information in most other programs I worked on. With the right sort of type system, you don't have inflexibility.)