What is the return type of a tail-recursive function

by by@REDACTED
Thu Feb 13 08:49:59 CET 2020


Yes, no_return() should be the correct answer!

Kind Regards,
Yao

> 在 2020年2月13日,15:21,Loïc Hoguin <essen@REDACTED> 写道:
> 
> None, it doesn't return.
> 
> You can use no_return() for these cases.
> 
> -spec loop() -> no_return().
> 
> You would do the same for functions that always throw an exception since they don't return either.
> 
> Cheers,
> 
> On 13/02/2020 07:21, by wrote:
>> Hi,
>> What is the return type of a tail-recursive function?
>> I guess it is a fun(), am I right? (actually I doubt it, but have no idea what the type is)
>> A strange loop :-)
>> Please see example as below:
>> ====
>> -module(test).
>> -export([start/0]).
>> -export([loop/0]).
>> -specstart() ->pid().
>> start() ->
>> spawn(fun() ->loop() end).
>> -specloop() ->fun().
>> loop() ->
>> receive
>> Any->
>> Any,
>> loop()
>> end.
>> ====
>> Kind Regards,
>> Yao
> 
> -- 
> Loïc Hoguin
> https://ninenines.eu



More information about the erlang-questions mailing list