Enhanced type guard syntax]

Chris Pressey cpressey@REDACTED
Fri Sep 19 00:24:41 CEST 2003


On Thu, 18 Sep 2003 22:02:26 +0200
Joachim Durchholz <joachim.durchholz@REDACTED> wrote:

> Thomas Arts wrote:
> > [...] there was a philosophy that all guards should be executable in
> > constant time.
> 
> This philosophy doesn't work out IMHO.
> Either, the guard is used as a selector. Then, if the guard is
> disallowed, people are going to write the exactly same
> non-constant-time code into the condition of an "if" statement, and
> nothing is won. Or the guard is used as a precondition. In that case,
> it shouldn't be a guard (but an assert statement or something -
> particularly, something that can be switched off for production code).
> 
> Just my 2c.
> 
> Regards,
> Jo

Sing it, brother!

A much nicer world would be:

1) the programmer writes whatever code they want in the "when" test
2) the compiler analyzes that code
3) whatever parts of it that have side-effects are rejected
4) whatever parts of it are constant-time are used as the guard
5) whatever parts of it are non-constant-time are factored out into a
"case" statement

But that sort of requires that a) compiler-writers are well paid and b)
the language is optimized for maintainability over efficiency... which
only ever seem to hold true in my private little world.

-Chris



More information about the erlang-questions mailing list