On Fri, 6 Sep 2024, at 03:01, Mike Schinkel wrote:
>> Block-scoping doesn't have to allow shadowing of names, 
>
> How exactly would that work?  Are you suggesting to restrict the use of 
> variable names to one per function but still allow for block scoping?

Yes. That's how C# works, for example - variables are scoped to the block where 
they're declared, but each name declared must be unique, not shadowing one 
that's currently in scope.


> Shadowing is not a feature that is added, it is the result 
> of block scoping, AFAIK.

Shadowing is absolutely a feature that has to be implemented: the compiler has 
to store some "backup" of the old name binding, so that it can be "restored" 
when the shadowing variable goes out of scope. Without shadowing, it's instead 
about tracking the "lifetime" of the variable, and refusing references to it 
outside of the block where it's "live". I'm sure the implementation of both 
versions varies wildly.


> It is ironic you say we should make sure it's possible before we 
> discuss if we want it. I know I have heard the opposite many times on 
> this list — make sure we even want it before we worry about how to 
> implement — although I cannot say for sure that it was ever you that 
> said that.

You're right, there is some value in letting people know that a feature would 
be popular if implemented. I'm just aware that threads like this can quickly 
grow into rambling discussions of wild ideas with little grounding in what's 
possible, or back-and-forth debates between two people about something 
completely hypothetical. When that happens, those with the experience to 
actually implement big new features tend to tune out. 

I will now try to practice what I preach, and not post further in this thread 
unless it moves onto something more concrete.

Regards,
-- 
Rowan Tommins
[IMSoP]

Reply via email to