YATT (Yet Another Typing Thread)

Luke Gorrie <>
Wed Sep 24 10:38:15 CEST 2003


"Richard A. O'Keefe" <> writes:

> Luke Gorrie <> wrote
> 	[that he likes the Common Lisp type system]

On further thought though, it is not what I want in a "soft-typing"
system for Erlang. It seems that the class of type errors that can be
unambiguously detected in regular Erlang (or Common Lisp) code is
pretty small.

In general I'd estimate about 10% of my time is spent writing code
that manipulates fairly complex data structures and is somewhat
painful to get right. I'm quite interested in nifty (and simple and
reliable) tools to make that code easier to write. I admit I have been
waiting for someone else to say "hey, I tried <erlang type system X>
and it works great!" before seriously looking in to those.

(If the guys at work did a "cvs update" and found a static type
checker and a bunch of funky-looking declarations around the codebase,
I would be pelted with rotten fruit.)

> Henry Baker had a paper (available somewhere on the net)
> on how it could have been better (better suited to inference).

"The Nimble Type Inferencer" I presume? Thanks for the tip, I'll give
it a read.

> The really nasty thing about the Common Lisp type system is
> that (at least in certain compilation models) if you state that
> something has a certain type the compiler will believe you, and
> generate code that can crash or do insane things.
> 
> Does CMUCL fix that in any way?

Yes. In CMUCL type declarations are treated as assertions that must be
tested, just like guards in Erlang. It then uses type-inference both
to eliminate unnecessary type checks (like that adding two integers
will produce an integer, or adding two numbers between 0 and 255 won't
produce a bignum), and to generate fast type-specialised code. The
Erlang compiler apparently does a bit of this already to run Wings
fast, and I suppose it's really a compiler implementation issue at
heart.

NB: I've read on the CMUCL mailing list that their safety is not
absolutely perfect, but I believe it's very thorough. It's also
possible to explicitly disable type checking using the standard CL
"turn off safety" declaration, giving you fast code that will crash
horribly if it breaks promises about types.

Cheers,
Luke




More information about the erlang-questions mailing list