num-complex
num-complex copied to clipboard
num_complex users should be allowed to write let mut x = (1.0, 2,0)_c64
...
It sounds like you want something like C++ user-defined literals, but there's no such mechanism in Rust.
?? let x= 5.4_f64; is a legit Rust stmt and not a C++ statement .. what I'm suggesting is that crate num_complex should expand this statement to include complex number literals represented by real and imag values
On Wed, Feb 24, 2021 at 5:58 PM Josh Stone [email protected] wrote:
It sounds like you want something like C++ user-defined literals https://en.cppreference.com/w/cpp/language/user_literal, but there's no such mechanism in Rust.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-num/num-complex/issues/88#issuecomment-785440194, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ6BCZHNZEUYG24SIEGUKLTAV775ANCNFSM4YFLZP7A .
Rust's f64 is a primitive language-defined type, with built-in support for parsing with the _f64 suffix. Complex is an external type that the Rust compiler knows nothing about when it is parsing your code.
I mentioned C++ only for comparison, because that feature does allow C++ users to define new suffixes like _c64. Rust does not have a feature like that, so I can't define any custom suffixes for num-complex.
We could possibly create shorter constructors, c64(1.0, 2.0), as discussed in #21, but you would have to use num_complex::c64; first to import that function into scope.
shorter constructors like c64(1.0, 2.0) would help a bunch..The use stmt
is no major obstacle
On Wed, Feb 24, 2021 at 9:50 PM Josh Stone [email protected] wrote:
Rust's f64 is a primitive language-defined type, with built-in support for parsing with the _f64 suffix. Complex is an external type that the Rust compiler knows nothing about when it is parsing your code.
I mentioned C++ only for comparison, because that feature does allow C++ users to define new suffixes like _c64. Rust does not have a feature like that, so I can't define any custom suffixes for num-complex.
We could possibly create shorter constructors, c64(1.0, 2.0), as discussed in #21 https://github.com/rust-num/num-complex/issues/21, but you would have to use num_complex::c64; first to import that function into scope.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rust-num/num-complex/issues/88#issuecomment-785536951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHJ6BCZNOHK76QXP6NYYTLLTAW3IFANCNFSM4YFLZP7A .