On Wed, Dec 1, 2010 at 3:05 PM, Graydon Hoare <[email protected]> wrote:
> "a + type b = int;"
>
> for example; decls only live at block-top level, not nested in exprs. This
> is mostly just to make the scope rules maximally obvious. A decl is in scope
> for the block it's declared in. I don't think it's much of a limitation
> since block is an expr; you could do "a + { type b = int; };" and mean the
> same thing; really it's just a rule about being unambiguous about decl
> scopes.
>
Ah, yes. My mind has been mostly in a dynamic mindset lately (where
definitions are just another thing you can do imperatively) so I didn't
think about that. Type definitions are definitely special, as are a couple
of other things I can think of like package management stuff ("import",
"#include", or whatever is appropriate) where it doesn't make sense to allow
them anywhere.
> I know Ocaml has it: note the 'definition' production in their AST :)
>
Thanks, that's a good reference. I was thinking about "let" being an
expression, but didn't think about "type" or other definitions.
- bob
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev