Tony wrote:

> At lines 234sqq of vim9.txt:
> 
>             When {return-type} is omitted the return type will be
>             decided upon by the first encountered `return`
>             statement in the function.  E.g., for: >
>                 return 'message'
> <            The return type will be "string".
> 
> At lines 290sqq:
> 
> A function defined with `:def` must declare the return type.  If there is no
> type then the function doesn't return anything.
> 
> Reminder: In functions defined with :function, ":return" is equivalent
> with ":return 0" and fall-through to ":endfunction" implies ":return".
> Unless the opposite were clearly said, I would expect the same to
> apply (mutatis mutandis s/endfunction/enddef/) to new-style function.
> 
> So I don't see how it is possible for a function not to declare a
> return type either explicitly (in the :def statement) or implicitly
> (in the first :return statement, or by fallback to integer if either
> the first return is just :return, or there is no explicit :return and
> the function returns only by falling through to its endpoint).

I should remove that text.  I first thought it would be OK to get the
return type from the first return statement, like the type of a variable
can be inferred from the initialization.  However, the return statement
can be anywhere, making it difficult to find the type.  I prefer to
require explicitly specifying the type.  It's also more in balance with
the argument types.

The new style functions do require a return statement, there is no
default.

-- 
hundred-and-one symptoms of being an internet addict:
35. Your husband tells you he's had that beard for 2 months.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202002061135.016BZO31004115%40masaka.moolenaar.net.

Raspunde prin e-mail lui