On Thu, Sep 23, 2010 at 7:22 PM, Graydon Hoare <[email protected]> wrote:
>
> With the current rule, '?red' binds a new slot whereas 'red' matches the
> constant tag constructor. I'm happy to reconsider syntax here; it was a
> change made in order to facilitate disambiguation, not because I am
> particularly wedded to the ?foo syntax.


I'm sure you're already aware, but in case you're not, Haskell solves this
ambiguity by requiring that types and constructors start with an upper case
character, whereas everything else must start with a lower case character.
This has downsides (mainly cosmetic), but does lead to very light weight
syntax in plenty of cases...

So you'd end up with something like:

alt(x) {
  case Red {
  }
  case green {
     // green is a variable, may actually be blue!
  }
}

Or if you don't like that, you could always just use slot declaration syntax
to indicate that it's a slot and not a constructor (what you're doing is
related, after all, and saves a symbol):

alt(x) {
  case red {
    // matches constructor
  }
  case auto green {
     // green is a variable, may actually be blue!
  }
}

While we're bike-shedding, I'm not sure why the "auto" keyword is needed at
all. Type inference is never dangerous (i.e. affects performance/semantics)
right? So why not just make the type specifier in the "let" statement
optional?

-- 
Sebastian Sylvan
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to