Home

elsecannot

Elsecannot is a hypothetical keyword or operator proposed in programming language theory to express that the else-branch of a conditional statement is unreachable under the given preconditions or invariants. It is not part of mainstream programming languages, and its exact syntax and behavior have varied in theoretical discussions.

Semantics and usage of elsecannot are not standardized. In static models, elsecannot signals that, for all valid

Examples in pseudo-code can illustrate the idea. For instance: if (user_is_admin) { grant_access(); } else cannot { deny_access(); }. In

History and reception: elsecannot has appeared mainly in theoretical discussions and design drafts about dead code

See also: unreachable code, exhaustive pattern matching, contract programming.

inputs,
the
else
branch
cannot
be
executed,
allowing
compilers
to
optimize
away
the
else-block
or
to
issue
compile-time
checks
that
guarantee
exhaustiveness.
In
dynamic
or
runtime
models,
elsecannot
may
require
a
proof
or
contract
that
the
else
path
cannot
occur;
if
reached,
it
can
trigger
an
explicit
assertion
or
a
runtime
error.
Some
proposals
envision
elsecannot
as
a
refinement
of
exhaustive
pattern
matching,
where
every
possible
case
has
a
proven
counterpart
in
prior
branches.
this
sense,
the
else
path
is
treated
as
unreachable,
and
the
language
or
toolchain
may
optimize
or
verify
that
the
else
block
is
never
taken.
Another
variant
appears
in
switch-like
constructs:
switch
(state)
{
case
A:
handleA();
case
B:
handleB();
else
cannot
{
handleError();
}
}.
elimination
and
exhaustive
case
analysis.
It
remains
uncommon
in
practical
languages,
with
limited
tool
support
and
potential
ambiguity
around
guarantees
and
error
handling.