> On 04 Apr 2014, at 12:30, Vadim Chugunov <vadi...@gmail.com> wrote:
> 
> Regarding the original idea:  Why use a whole bit, when you only need one 
> value out of all possible type's values?   For example, for floats, one of 
> the NaNs could be used for this purpose without any issues with overflow as 
> would happen in your proposal.

Yes, you're quite right.

> Regarding "which types?":  Perhaps this should be controlled via another 
> built-in trait, such as the following:
> trait Invalid {
>     fn invalid() -> Self;
> }
> The compiler could then perform option space optimization for any type 
> implementing 'Invalid'.

Again, that makes more sense than my proposal. But I do wonder if it would be 
necessary to make the restriction that only a compile-time constant would be 
allowed for the 'invalid' sentinel value. That would require type associated 
constants and also that traits would be able to require such a constant be 
defined by its implementor type. But I think those features are bound to land 
at some point.

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to