I would be sorry to see this so elegant functional aspect of Julia
return to the void. It fits well with the
expression-rather-than-statement feel of Julia.
Regarding the annoyance of having to explicitly "return nothing" for
"procedures" (functions which are called only for side-effects): I
would find annoying to having to return explicitly something in
"functional functions", and I like the explicit "return nothing" to
indicate a procedure.
I don't agree that long form functions are inherently non-functional.
First, as Jeff mentioned, the lisp languages (considered functional)
have such features (e.g. "begin" in scheme), to return implicitly the
last expression in a block a mixed imperative/functional code.
This is true also in Haskell in do blocks (which implement side-effect
computations):

greet :: Int -> IO String
greet intensity = do
  name <- getLine
  return $ "Hello " ++ name ++ (take intensity $ repeat '!')

haskell> greet 3
Julia
"Hello Julia!!!"

It should be noted that the return here may be misleading: it's a
standard function which computes a value, which is then *implicitly*
returned to the caller of greet because it's the last expression of
the do block.

Second, a whole bunch a functions are "pure" (non-mutating) and can be
seen as implicit let forms:

function f(x)
    y = 2*x
    z = x^2
    x + y - z
end

which corresponds e.g. in Haskell to

f x = let
          y = 2*x
          z = x*x
        in x+y-z

I don't like to argue too much, but the status-quo camp is
under-represented in this thread!

I genuinely don't understand how annotating the function as ::Void or
::Nothing is preferable to "return nothing". And why not a new keyword
"procedure" then?

Reply via email to