{{ ... }} -- Was: Re: Surprising semantics

# Ingvar von Schoultz (17 years ago)

With {{ }} there are only let declarations. Var becomes let. Hoisting to higher scopes disappears completely. The language only supports let.

There is only one type of scope. This is the {{ }} scope. Everything resides in a {{ }} scope, let-declared there.

When this is enabled, { } serve only to show which statements are affected by an if(), for() etc. They have nothing at all to do with any scoping. They don't affect any declaration in any way whatsoever. Regarding declarations, please consider the { } nonexistent.

For scoping, {{ }} completely replaces { }.

waldemar at google.com wrote:

I'm trying to keep the language relatively simple.

I agree wholeheartedly about simplicity.

What you're proposing is far too complicated.

Apparently my explanations have been complicated and confusing.

Keep in mind that function assignments hoist to the beginning of the scope in which the function is defined,

Yes, at the {{.

so your proposal won't work. You're trying to do a complex split-scope approach where each function definition has two scopes, one in which it is declared and one in which it is defined, but even that won't work with const, typed functions and variables, etc.

Is this about {{ }}? If so, I suppose you agree that the problem does not appear when every declaration is a let declaration.

See my previous email as to why. You'd then have to introduce extra rules about some definitions only being possible within {{}} blocks, which would then affect the behavior of existing definitions like var if one of the other definitions within the same block was a const or function, which would snowball into a complex mess.

You're mixing different problems that can never appear together.

The proposal that function hoist like var is completely unrelated to {{ }}. It doesn't apply when you use {{ }} and everything becomes let.

I'll reply about that in a separate email. And to avoid the above mixing and confusion, I'll put it aside for a while. Let's reduce the confusion.

Ingvar