Pi types v2


It is now broken into 3 sub-RFCs:



Thank you for all the work you’re doing. I hope part of your work will produce fruits.

How are those ideas interacting with the syntax and semantics of variable length arrays (arrays where the length is a run-time argument)?

An example usage of integers as template arguments to increase the performance of D language programs can be seen here, you can add this to the movitation section, such kind of optimizations can’t currently be done in Rust and this is sad: http://www.fantascienza.net/leonardo/js/squares_problem.zip

In my opinion Ada-style Bounded Integers can be quite useful in Rust, if they are well implemented, they have a nice syntax and they are efficient. The Ada compiler is sometimes able to remove the bound tests of bounded integers if it statically sees they can’t go out of bounds. This is an important feature for Rust bounded integers too because it increases the performance of the code. Are your bounded integers able to do that? If they can’t do that, then perhaps it’s a good idea to improve the design of Pi types, or add Bounded Integers as separate native feature in Rust.

In Ada you can also define integral values that have a subset of the range of another bounded integer type, and the subtyping is handled correctly.

In Ada you can also add Dynamic_Predicate and Static_Predicate to types: http://www.ada-auth.org/standards/12rat/html/Rat12-2-5.html

Static_Predicate allows you to avoid some bugs statically, even in literals. I think well implemented Bounded Integers (and subtypes) in Rust should have such features.

closed #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.