Brief Minutes [RE: ES3.1 WG phone conference 24 June 08:00 PT]

# Allen Wirfs-Brock (17 years ago)

Following up on the "Strict Mode" discussion...

As I advocated on the call, I think that by selecting "strict mode" a developer is really choosing to restrict themselves to using a subset of the complete language. The future-proofing issues of this relate to the possibility that there might be multiple such subsets that a developer might need to choose among. Should there be multiple named "strict modes" to choose among, how should they be named, can "strictness" of a mode increase in future versions, etc?

I think some of the controversy could be eliminated if we simply eliminate the term "Strict Mode". Instead I propose we have a "Use Subset" directive and that we name specific subsets in a meaningful and generally positive manner. For example, since the motivation of most of the proposed restrictions in ES3.1 strict mode is to provide a safer subset language I suggest that we call this subset "safety" (or perhaps "safety1" or "safetyA" or "safety2008" implying that in the future different safe subsets might be defined and we don't want to give undo importance to this initial one).

So, the first line of a "strict mode" compilation unit would now look like" "use subset safety"

I would suggest that we actually define "use subset" such that a comma separated list of subsets is allowed. So, if somebody decided to define a subset that only contained the features of ES3 you might see something like this: "use subset safety,ES3"

Since subsets are sets of restrictions, listing multiple subsets means to take the union of the restrictions imposed by all of the listed subsets. So "use subset safty,ES3" means that this compilation unit may only use those features defined by ECMA 262-3 and which are not excluded by the "safety" subset. So, assuming that "safety" excludes use of the with statement, such a compilation unit could not include use of the with statement nor could it include any use of a feature that is new in ES3.1 or ES4.

Future versions of ECMAScript may add exclusions to a subset defined by an earlier version as long as the added exclusions only restrict capabilities that didn't exist in the earlier version. For example, ES 4 in supporting the ES3.1 "safety" subset but add to it any features that are added in ES 4 but which are considered to be unsafe.

A future version may not add exclusion to an pre-existing subset that restricts features that existed when the original subset was defined. For example if ES3.14 or ES5 decided that the for-in statement was unsafe, it could not add that restriction to the "safety" subset. However, it could define a new subset named perhaps "safety2010" that includes all the restrictions of the "safety" subset and in addition disallows use of the "for" statement.

If a compilation unit specifies a subset that is not known to the implementation that is processing it, that subset restriction is simply ignored. The code in the unit is still either valid or invalid on its own merit just like is the case when no subset had been specified.