[rust-dev] Compile-time function evaluation in Rust

liuyanghejerry liuyanghejerry at 126.com
Wed Jan 29 08:56:56 PST 2014


Hi,
I didn't read through the whole post, but I think maybe we could even 
let user add one more hint about max iteration time, since lib user 
should be aware of it?

于 2014/1/29 18:44, Pierre Talbot 写道:
> Well yes, due to the halting problem, we can't detect if a function 
> will diverge or not. It's on the behalf of the library user. However, 
> we could limit the number of iteration or recursion to an arbitrary 
> number.
>
> On 01/29/2014 11:39 AM, Gábor Lehel wrote:
>> Ah, so `fail!()` is not okay, but `loop { }` is okay.
>>
>>
>> On Wed, Jan 29, 2014 at 11:26 AM, Pierre Talbot <ptalbot at hyc.io 
>> <mailto:ptalbot at hyc.io>> wrote:
>>
>> It's a diverging function in the sense of the manual:
>> http://static.rust-lang.org/doc/master/rust.html#diverging-functions
>>
>> On 01/29/2014 11:21 AM, Gábor Lehel wrote:
>>
>> On Wed, Jan 29, 2014 at 10:19 AM, Pierre Talbot
>> <ptalbot at hyc.io <mailto:ptalbot at hyc.io> <mailto:ptalbot at hyc.io
>> <mailto:ptalbot at hyc.io>>> wrote:
>>
>> I add: a pure function can call extern code and diverges,
>> so the
>> pure requirements are a subset of the CTFE requirements.
>>
>>
>> How do you plan to enforce that a function won't diverge?
>>
>> Are there any systems which allow calling functions and
>> enforce convergence without using dependent types?
>>
>> (We could probably enforce it by prohibiting both mutual and
>> self-recursion as well as loops, but I'm guessing this would
>> be too restrictive to be acceptable.)
>>
>>
>> Pierre
>>
>> _______________________________________________
>> Rust-dev mailing list
>> Rust-dev at mozilla.org <mailto:Rust-dev at mozilla.org>
>> <mailto:Rust-dev at mozilla.org <mailto:Rust-dev at mozilla.org>>
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>>
>>
>>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev




More information about the Rust-dev mailing list