reformed with

Brendan Eich brendan at
Mon Feb 5 17:38:20 PST 2007

On Feb 5, 2007, at 5:28 PM, P T Withington wrote:

> On 2007-02-05, at 20:06 EST, Brendan Eich wrote:
>>> Do you mean that in strict mode, |with(o)| would be translated to
>>> |with(o:typeOf(o))| where typeOf(o) is determined at compile- 
>>> time? If
>>> so, that would be nice.
>> Not sure what Lars meant, but I saw something like that and found  
>> it attractive at first. However, intrinsic::typeOf(o) is a runtime  
>> expression, as well as a call to an optional library function.  
>> Imputing it here in the case of with-under-strict-mode is unusual  
>> and something TG1 members seem to be against, but we're still  
>> debating.
> If I have:
>   var o:T = ...;
> (or the type of o is already declared in some other fashion in the  
> lexical context), do I still have to say:
>   with (o:T) ...

The two don't mean the same thing.  'var o:T = ...' first means  
convert '...' to T, then constrain any further values to be  
compatible with T. On the other hand, from the [reformed with] proposal:

For example, to use fields f1 and f2 of the given types from an  
object denoted by obj:

with (obj : {f1: T1, f2: T2}) {
      // f1 and f2 are unambiguous here ...

It is required that obj have fields of the given names and exact  
types. The actual field obj.f1 must not be of a subtype of T1, e.g.,  
because assignments to f1 in the with body could break the narrower  
type constraint on obj.f1. And obj.f1 must not be of a supertype of  
T1, because it could hold a value that is not of that subtype.


More information about the Es4-discuss mailing list