Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 8/2/12 7:05 PM, Patrick Walton wrote: On 8/2/12 7:04 PM, Kevin Cantu wrote: Why wouldn't that fit in? I'm missing something here. Because ordinarily a semicolon means that the value is returned, but in this case it wouldn't. Err, ordinarily a semicolon means that the value is *ignored*.

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 8/2/12 7:04 PM, Kevin Cantu wrote: Why wouldn't that fit in? I'm missing something here. Because ordinarily a semicolon means that the value is returned, but in this case it wouldn't. A clearer example would probably be: let x = match foo { 'a' => 1; 'b' => 2;

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Kevin Cantu
Why wouldn't that fit in? I'm missing something here. On Thu, Aug 2, 2012 at 6:20 PM, Patrick Walton wrote: > There is another issue I forgot to mention, which is the match clause > separator. > > Currently, "match" (formerly "alt") clauses must either be separated by a > closing brace '}' or

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
There is another issue I forgot to mention, which is the match clause separator. Currently, "match" (formerly "alt") clauses must either be separated by a closing brace '}' or a comma ','. We can't use '|' like ML because of bitwise-or. So we have: match foo { 'a' => 1,

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Ted Horst
I've hesitated to comment so far because I didn't understand what people were complaining about, but I like the current system better than any of these proposals. Coming from mostly C style languages, I didn't have any problem understanding it or using it. Ted ___

Re: [rust-dev] Polymorphism & default parameters in rust

2012-08-02 Thread Tim Chevalier
On Thu, Aug 2, 2012 at 12:51 PM, Emmanuel Surleau wrote: > Hi, > > I'm new to rust, and I'm struggling to find an elegant way to work with > default > parameters. > > I'm trying to implement in rust the equivalent of the following Python line: > > def flag(self, name, desc, short_name=None, max_c

[rust-dev] Polymorphism & default parameters in rust

2012-08-02 Thread Emmanuel Surleau
Hi, I'm new to rust, and I'm struggling to find an elegant way to work with default parameters. I'm trying to implement in rust the equivalent of the following Python line: def flag(self, name, desc, short_name=None, max_count=1, banner=None): ... The idea is to offer a "simple" API (with o

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 8/2/12 9:59 AM, Niko Matsakis wrote: My "official position" is unopposed. I personally like the rule about omitting the trailing semicolon, it makes it syntactically clearer when a value is being returned, but I understand some people have also complained about it. Your change seems to be a

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Daniel Patterson
I personally think the current/old rule is good; at least to me, it is completely clear what is going on - semicolon means terminate statement, and the last (unterminated) statement is returned, unless a short-circuit return exists. Mixing functional/imperative code is tricky, but I think this r

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 8/2/12 9:52 AM, Glenn Willen wrote: But now that I see that the new syntax is effectively the same one Perl uses, I'm not super worried about it, as long as we adopt the same house style that Perl programmers use: The semicolon is _always_ present, except in cases where it's too ugly (which i

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Niko Matsakis
On 8/2/12 10:07 AM, Erick Tryzelaar wrote: fn h() -> int { f(); // result ignored g(); // result returned } It's true, I feel like the current scheme does a better job of highlighting when a seemingly unused value is significant. I don't know, I always liked the current rule regarding

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Erick Tryzelaar
On Thu, Aug 2, 2012 at 10:03 AM, Niko Matsakis wrote: > > These all have unit (or bottom) return type. We could require semicolons > after these. At least you would not then be able to write: > > if cond { return } > > but rather > > if cond { return; } > > and not > > fn foo() -> in

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Glenn Willen
I think the ideal rule is one that can be easily learned by observation of existing code. I don't think this is such a rule. I think the current rule is such a rule, but it seems some people disagree. :-) The new rule has the disadvantage that it's hard to learn what the actual rule is, versus

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Erick Tryzelaar
I'm coming from functional-programming-land, so I'm quite fond of our current scheme. These seems a bit surprising to me: fn f() -> int { 3 } fn g() -> int { 4 } fn h() -> int { f(); // result ignored g(); // result returned } I'm probably pretty biased, but I don't think this is a complic

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Niko Matsakis
There is another option. Right now we have a number of "expressions" that can only really be used as statements: a = b a += b loop { } while cond { } return ... These all have unit (or bottom) return type. We could require semicolons after these. At least you would n

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Niko Matsakis
My "official position" is unopposed. I personally like the rule about omitting the trailing semicolon, it makes it syntactically clearer when a value is being returned, but I understand some people have also complained about it. Your change seems to be a relatively simple way to make the pres

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Glenn Willen
On Aug 2, 2012, at 9:13 AM, Patrick Walton wrote: > If the semicolon were mandatory at the end of blocks, you'd have to write: > >let x = if cond { 3; } else { 5; } > > Which would be a non-starter, IMHO. So looking at this example made me realize that I do know one language that uses an

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 08/02/2012 09:15 AM, Gareth Smith wrote: > Thus this is in practice a backwards-compatible change intended to eliminate a good deal of toe-stubbing. IMHO the source of the toe-stubbing may be that rust has so many different ways to return a value: I'm not sure. The complaints I've seen (s

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Donovan Preston
On Thu Aug 2 12:13:09 2012, Patrick Walton wrote: On 08/02/2012 09:10 AM, Donovan Preston wrote: I would be more in favor of this proposal if the semicolon was not optional. Having the ability to have code that is identical except for a semicolon just doesn't feel right to me. If the semicolo

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Gareth Smith
> Thus this is in practice a backwards-compatible change intended to eliminate a good deal of toe-stubbing. IMHO the source of the toe-stubbing may be that rust has so many different ways to return a value: fn f() -> int { 42 } or fn f() -> int { ret 42 } or fn f() -> int { ret 42; } And re

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 08/02/2012 09:10 AM, Donovan Preston wrote: I would be more in favor of this proposal if the semicolon was not optional. Having the ability to have code that is identical except for a semicolon just doesn't feel right to me. If the semicolon were mandatory at the end of blocks, you'd have to

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Donovan Preston
I would be more in favor of this proposal if the semicolon was not optional. Having the ability to have code that is identical except for a semicolon just doesn't feel right to me. On Thu Aug 2 11:58:03 2012, Patrick Walton wrote: On 08/02/2012 08:43 AM, Glenn Willen wrote: But blocks are no

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 08/02/2012 08:43 AM, Glenn Willen wrote: But blocks are now allowed to discard their values, where previously this was forbidden? That is, before, it was an error to say: fn foo() { 5 } But now it will be allowed? (I notice that in your first email you said that return values could alr

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 08/02/2012 08:31 AM, Benjamin Striegel wrote: Ah, so semicolons are absent by default? That seems like the right decision; making semicolons optional and yet canonicalizing their universal use almost certainly leads to contention down the road (cf Javascript). I think there's a bit of confus

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Glenn Willen
On Aug 1, 2012, at 8:47 PM, Patrick Walton wrote: > > Actually, the only parser change was to throw away semicolons before the end > of the block. > > To be more concrete, the rules are: > > 1. The last expression is the value of the block, regardless of whether > there's a semicolon after it.

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Benjamin Striegel
> Right now the official style is what is currently done; semicolons are only used when ignoring a value. Ah, so semicolons are absent by default? That seems like the right decision; making semicolons optional and yet canonicalizing their universal use almost certainly leads to contention down the

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Patrick Walton
On 08/02/2012 07:22 AM, Benjamin Striegel wrote: Questions: 1) Are there any complications with spanning multiple lines? No. This change doesn't make Rust whitespace sensitive in any way. 2) What is the official style? Right now the official style is what is currently done; semicolons are

Re: [rust-dev] RFC: Ignore trailing semicolons

2012-08-02 Thread Benjamin Striegel
Questions: 1) Are there any complications with spanning multiple lines? ``` let foo = bar + baz + "some long string literal that takes us out to 80 chars" + qux + "and continued on this line" do something_else { ... ``` 2) What is the official style? On Wed, Aug 1, 2012 at 11:47 PM, Pa