Proposal: opt-out local scoping

Felix felix8a at gmail.com
Fri Aug 29 18:45:21 PDT 2008


ihab.awad at gmail.com wrote:
> Also, you seem to be asking for an explicit way to say, "this variable
> does not respect Tennent correspondence; I know I am doing this and I
> have a good reason" --
> 
>   http://gafter.blogspot.com/2006/08/tennents-correspondence-principle-and.html

I'm suspicious of Tennent correspondence, because I think simple 
variations of the statement do not match anyone's expectations.

if I understand correctly, Tennent correspondence says:

t1: any expr should be equivalent to
         (function() {expr}) ()

and one of the difficulties is, what if expr has control-flow 
statements, such as break or return.  another difficulty is, what if 
expr has lexically-scoped statements, such as local variable declarations.

assume N is a unique generated symbol.  Tennant correspondence could 
also be stated as

t2: any expr should be equivalent to a function in the same scope
        function N() {expr}
     and a call to that function
        N()

that isn't true in any practical language I know, and it seems unhelpful 
to say that function declaration is broken in all of them.  I don't 
think anyone expects that you can extract arbitrary pieces of code into 
a separate function without fixing up control-flow and scoping.

and part of the usefulness of functions is that they _do_ introduce a 
discontinuity, which lets you express things that are more difficult to 
express without it.


More information about the Es-discuss mailing list