[rust-dev] Suggestions

Brian Anderson banderson at mozilla.com
Sat Feb 4 13:14:29 PST 2012

----- Original Message -----
> From: "Arne Döring" <krux02 at googlemail.com>
> To: rust-dev at mozilla.org
> Sent: Saturday, February 4, 2012 6:21:58 AM
> Subject: [rust-dev] Suggestions
> Hi

Hi, Arne.
> Maybe I should introduce myself first. I am Arne a Computer Science
> student and my bachelor degree is not far away anymore. I am very
> interested in new programming languages and lately I found out about
> Rust. Because of the fact, that in the last time my most used
> language
> is Scala I was kind of interested weather there is something that
> behaves to C++ similar as Scala behaves to Java. And rust seems in my
> opinion to be tho closest to Scala. Now I would like to share my
> experience with Scala, so that Rust can make things right, that were
> also right in Scala. Normally I really prefer Forums and other less
> direct forms of communication to introduce my Suggestions, because
> then more people are able to read them, but Rust doesn't have an
> official discussion forum (I would really like that).

> First of all, generic Types with angle brackets. We all know generic
> types from C++, Java, C# etc, and they all use angle brackets for
> generic types. at least they call it angle brackets, but in fact they
> are the less and greater sign <> angle brackets are these ⟨⟩. This
> leads to many probles if you also want to use the < sign as an actual
> less sign. We all know that in C++ it was long time not possible to
> have >> as two closing angle brackets of templates, because it was
> parsed as a right shift operator. And there are a lot of ambiguous
> situations, for example if you want to use < within generic types
> (Scala does if for definition of inheritance ). html forbids to use
> <,> at all. The D programming language had an article about it, but I
> cant find it anymore. Scala uses those [] (array index is with normal
> braces ()). Afer a little while were it was different to me, I really
> liked it, because they are real brackets. I would really like to see
> those brackets it Rust.

We don't have the same problems as C++ here because we made a compromise that wherever there would be a potential ambiguity the angle brackets have to be proceeded with a double colon. So for function calls, for example you have to write `do_something::<int>(0)`. In most cases this ugliness is ameliorated because type inference will figure out the type parameters and they don't have to be written at all.

That said, this is one of my nits with the language as well. In an earlier version we did use square brackets for type parameters, and i was ok with it (but then there was an ambiguity between array indexing with () and function calls).
> The second suggestion is concerning tho #fmt macro. #fmt works like
> printf, but its string is parsed at compile time, so that errors
> might
> be thrown when the string is incorrect. So when you unwind this
> format
> string at compile time, you know also all variable names and their
> types from scope. So it might be more natural to directly import
> variable names from the scope inside of the String, like it is done
> in
> many scripting languages. This is also done in tho Programming
> language Nemerle.

I would be interested in seeing an extension that explores other ways to do string formatting. I think #fmt uses a printf style because it is well-known and was an obvious early approach to take. It is a bit unwieldy though and other languages have done this in a nicer way.

More information about the Rust-dev mailing list