Hello,
Well, I wonder if we could exchange those formats. Here is how they work:
fn main () {
struct P {i:uint, j:uint};
let (b, u, i, x, c, s, a, p) =
(false, 1u, -1, -1.11, 'c', "abc", [1,2,3], P{i:1,j:2});
let z : Option<uint> = None;
// Poly
println!("{:?} {:?} {:?} {:?} {:?} {:?} {:?} {:?} {:?}",
b, u, i, x, c, s, a, p, z);
// ==> false 1u -1 -1.11 'c' "abc" [1, 2, 3] main::P{i: 1u, j: 2u}
// Standard
println!("{} {} {} {} {} {}",
b, u, i, x, c, s);
// ==> false 1 -1 -1.11 c abc
}
The format 'Poly" {:?}:
* works for all types, including app defined, does not require trait definition
or declaration
* just does the right thing, telling the programmer all what is needed
in an exact and complete manner (except "main::" is too much maybe)
The format 'Standard' {}:
* requires definition of trait 'Standard' for complex types (arrays, structs,
enums), as well as its declaration for type variables
* is ambiguous about chars and strings, as well integers (signed?)
In other words, 'poly' gives us back the notation of data, as we (would) have
noted them in code. Also, its tells us the type, if implicitely, except for the
exact size of a number. This information is what we need in the general case for
all kinds of feedback in program testing, diagnosis, debugging... The standard
notation of data is not always the best possible form, but it always does the
job and we are used to it. I guess we'll constantly use it for our own feedback.
For this reason, I'd like to exchange the notations of these formats: have Poly
be {} so that we are less annoyed at typing it. And call with a meaningful name,
such as Notation, Literal or... Standard.
I have no idea what the other format (the one currently noted {} and called
Standard) is good for. I'd say it can be used as part of user output, but we
already have good type-specific formats for that. Maybe this format is a
polyvalent form of those specialised formats, so that we don't need to choose:
then call *this one* "poly"... Also, noting this one {:?} would make sense.
Denis
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev