clarify a bit the I/O story
[web.git] / ralf / _posts / 2018-07-19-const.md
index f511b9f9da80797dd55855523cf005f1af616520..590763062154d9ead86e1f5afe76acba48c95fcd 100644 (file)
@@ -34,7 +34,10 @@ We say that the `3 + 4` above is in *const context* and hence subject to CTFE, b
 Not all operations can be used in const context.
 For example, it makes no sense to compute your array length as "please go read that file from disk and compute something" -- we can't know what will be on the disk when the program actually runs.
 We could use the disk of the machine compiling the program, but that does not sound very appearling either.
-In fact, it would also be grossly unsafe:
+Things get even worse when you consider letting the program send information to the network.
+Clearly, we don't want CTFE to have actually observable side-effects outside of compilation.
+
+In fact, just naively letting programs read files would also be grossly unsafe:
 When computing the length of an array twice, it is important that we obtain the same result.
 
 > *CTFE must be deterministic.*
@@ -233,5 +236,5 @@ In particular, I propose that *when type-checking safe code in const context, we
 There are still plenty of open questions, in particular around the interaction of [`const fn` and traits](https://github.com/rust-lang/rust/issues/24111#issuecomment-311029471), but I hope this terminology is useful when having those discussions.
 Let the type systems guide us :)
 
-Thanks to @oli-obk for feedback on a draft of this post.
+Thanks to @oli-obk for feedback on a draft of this post, and to @centril for interesting discussion in #rust-lang that triggered me into developing these ideas and terminology.
 If you have feedback or questions, [let's discuss in the internals forum](https://internals.rust-lang.org/t/thoughts-on-compile-time-function-evaluation-and-type-systems/8004)!