On 9/25/13 6:32 AM, Alexander Sun wrote:
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.
This is contrary to the design goals of Rust. Go is a fully garbage
collected language and provides neither optional GC nor explicit control
over allocation on the heap or stack, both of which are important Rust
features.
Slice?
Provide first class support of array, slice(not borrowed pointer to
vector). And support slice operation, like a[0:5].
How is a slice different from a borrowed pointer to a vector? Note that
you can take a borrowed pointer to a subrange of a vector.
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.
This was on the roadmap at least at one point, but I'm not sure it works
due to some issues regarding method lookup. strcat knows more.
Improve the function declare:
fn foo(x : int, y : int, z: int) to fn foo(x, y, z: int)
This would be somewhat ad-hoc when we move to arbitrary type ascription
in patterns (e.g. `fn foo(MyStruct { x: int, y: 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.
This would conflict with the warn-unused-result warning I would like to
add, and would also cause a lot of spurious type errors in match arms.
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);
If we did this, we wouldn't know whether to parse a pattern or an
expression when starting a statement. This isn't fixable without trying
to define some sort of cover grammar that covers both expressions and
patterns, like ECMAScript 6 does. I don't know if this would work in Rust.
Embedded anonymous structure?
Embedded anonymous structure in Go is good idea, I think.
Not the way Go does it, where you can have method conflicts like C++
multiple inheritance and it can be surprising which method gets called
when two anonymous fields have a method with the same name. I'm not
necessarily opposed to anonymous fields, but we should tread carefully.
And at last: could support default parameter in function/method?
This has been discussed and the consensus, at least for now, is that
statics plus functional record update syntax is enough.
English is not my native language, so sorry for the grammar mistake.
No problem, thanks for your input!
Patrick
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev