Enhanced type guard syntax]
Martin J. Logan
mlogan@REDACTED
Fri Sep 19 22:53:06 CEST 2003
On Thu, 2003-09-18 at 17:24, Chris Pressey wrote:
> 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
How could this be done at compile time while still using run time
function call binding?
If I say erlc modfoo.erl and it uses a guard that references code in
modbar.erl erlc must be made aware of modbar.erl so it can look for a
"!" in that module.
> 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