From 994ccd30a09f57fb0055cf987f006fa19206902d Mon Sep 17 00:00:00 2001 From: Ingo Blechschmidt Date: Fri, 6 Feb 2015 23:14:51 +0100 Subject: [PATCH] Note that types do not have to be declared in closures Without such a clarification, people who know and love closures (for instance programmers with a Haskell background) might fear that types would have to be declared in closures and that therefore using closures would be much more unwieldy. --- src/doc/trpl/functions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/trpl/functions.md b/src/doc/trpl/functions.md index d0ecb6067955..c8b79232aa90 100644 --- a/src/doc/trpl/functions.md +++ b/src/doc/trpl/functions.md @@ -75,7 +75,8 @@ This is a deliberate design decision. While full-program inference is possible, languages which have it, like Haskell, often suggest that documenting your types explicitly is a best-practice. We agree that forcing functions to declare types while allowing for inference inside of function bodies is a wonderful -sweet spot between full inference and no inference. +sweet spot between full inference and no inference. (For closures, i.e. unnamed +functions, types do not have to be declared.) What about returning a value? Here's a function that adds one to an integer: