I am not a language developer, just an user. I like Rust, so could I
please to give some suggestions about improve Rust?
Recently, I try to use Rust to build a GUI library prototype. Just
like wxWidget or SWT, wrap the native API(win32 and gtk+, cocoa in
plan if possible). At the meantime, I am writing a Rust tutorial.
During the developing and writing, I got a some questions.
We all(at least I) hope Rust could get wildly use. I think readability
and learnability take emphatically considered. Rust does these well,
and could do better.
Here are my suggestions about Rust(based on 0.7). Note: Just a user
opinions, not a developer perspective. Forgive me if I was wrong.
Ownership, Owned Box, Managed Box
What about hide the ownership, owned box, managed box to users? Just a
borrowed pointer and a dereferencing pointer, like Go.
Slice?
Provide first class support of array, slice(not borrowed pointer to
vector). And support slice operation, like a[0:5].
Loop
Simplify the for loop:
Hide the complexity of iterator, use "for x in xx", like Python(I
think I saw it in 0.8 Manual).
for int:range(0, 10), for uint:range(0, 10), ... to "for range(0, 10)"
for int:range_step(0,10,2) are the same.
Improve the function declare:
fn foo(x : int, y : int, z: int) to fn foo(x, y, z: int)
And could make the expression valid?
(index = count % 2) == 0, Just like the meaning in C++. Currently
(index = count % 2) == () is valid, but it make no sense.
Multiple return values
if has a function like this:
fn addsub(x : int, y : int) -> (int, int) {
return (x+y,x-y);
}
them, this is valid:
let (b,c) = addsub(x, y);
but this is invalid;
let b:int =0;
let c:int =0;
(b,c) = addsub(x, y);
also invalid:
let (b,c) = (0, 0);
(b,c) = addsub(x, y);
Module: code module and file module?
I call module declare with mod keyword is "code module", and call rust
source file is "file module".
import a code module in other code module in same source file, we
should use keyword "use", but if we want to import file module, we
need to use keyword "mod". I know mod xxx means find xxx.rs, But could
we unify it?
According the official "Rust tutorial", a mod member is private by
default. But it seems that we can access submod in a accessible mod
directly.
Embedded anonymous structure?
Embedded anonymous structure in Go is good idea, I think.
And at last: could support default parameter in function/method?
English is not my native language, so sorry for the grammar mistake.
Best Regards
Sun
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev