ES4 draft: assert expression

Mark S. Miller erights at
Mon Apr 14 15:10:50 PDT 2008

2008/4/11 Lars Hansen <lhansen at>:
> We talked about debugging information and an assertion form on
>  es4-discuss a while ago, in a thread about the Error object.  As a
>  result of that discussion, I'm sending out a draft for an "assert"
>  expression form.

Hi Lars,

I missed the earlier discussion. From the draft spec you attached, it
seems like the first argument to assert is always evaluated, its value
is always checked, and if false, an error always thrown. While I like
this better than the behavior normally associated with the name
"assert", it is different, so I'm wondering if a different name is
called for?

In C, C++, Java, and IIRC Eiffel, the assert expressions (and in
Eiffel, the pre and post conditions as well) are not supposed to be
part of the meaning of the program. If P is a correct program in any
of these languages, then erasing P's assert statements (or turning
them off through other means) should be correctness preserving. E and
Caja have similar but mandatory checking functions, named "require"
and "enforce" respectively. A correct program can validly depend on
their arguments being executed, and can depend on these function
throwing when the argument evaluates to false.

Can a correct ES4 program depend of the assert expression to do its
thing? If so, then we should consider these expressions to be part of
the meaning of the program, not just descriptions of what the
program's meaning should be. If so, "assert" is a confusing name.


More information about the Es4-discuss mailing list