On Nov 19, 2013, at 3:08 AM, Daniel Micay <danielmi...@gmail.com> wrote:
> I wouldn't mind not having `~T` in the language at all, but am not
> really opposed to including it because there's no harm. Choosing to
> special-case arbitrary non-trivial data structures like vectors and
> reference counted boxes *is* harmful because alternatives should *not*
> be second-class.
Alternatives aren’t second-class, they just aren’t special. Vectors in
particular are used so ubiquitously that having special syntax is extremely
convenient.
Anecdotally, Objective-C has moved in the opposite direction to the great
happiness of all Obj-C developers. NSArray* and NSDictionary* are the
ubiquitous vector/hashtable implementations that everybody uses, but they
didn’t have any special language support. Recently, special language support
was added so I can say @[@“yes”, @“no”, @“maybe”] instead of [NSArray
arrayWithObjects:@“yes”, @“no”, @“maybe”, nil] (and similar syntax for
dictionaries, as well as boxed NSNumbers) and it’s made programming in Obj-C
significantly nicer. There’s nothing stopping you from using other data
structures, but the special syntax for these particular ubiquitous ones just
makes everyone’s life easier.
So back to Rust. &[] and its variants are extremely commonly used. Removing the
special syntax for this will do nothing but make it more annoying to use them.
It doesn’t do anything to make alternative data structures any easier to use.
The one suggestion I’d make is maybe provide hooks for the &[] syntax to be
used for a different vector implementation on a per-crate basis, although this
would mean that &[] would actually be something like std::vector<T> and &[] is
just syntactic sugar. Which is generally fine, although it’s awfully nice to
have &[T] be the actual type name in type signatures, having to use
std::vector<T> in type signatures and then using [a, b, c] to construct the
value in code just feels a bit less nice than what we have in Rust today (but
certainly better than no syntactic sugar at all).
-Kevin
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev