[erlang-questions] Type inference in Erlang [WAS: Re: The compiler "eats" structures which are not separated by commas]
Kostis Sagonas
kostis@REDACTED
Mon Apr 23 08:25:50 CEST 2012
On 04/23/2012 04:39 AM, Robert Virding wrote:
>
> ----- Original Message -----
>> Richard O'Keefe schrieb:
>>> Expr#Name{Field1 := Expr1, ..., Fieldn := Exprn}
>>> ^ ^
>> You still have the clutter of the Name (= RecordType),
>> which a language with type inference doesn't need.
>
> Type inferencing in erlang doesn't work. Unfortunately. There are too many places where it breaks down to be useful, for example message passing and code loading. There were attempts in the 90's by people much more knowledgeable than we were on this.
OMG!
If so, what exactly is the technique that dialyzer is using if not type
inference? Magic?
Just because some people in the 90's, who were supposedly knowledgeable
in the area, took (what I would claim is) the wrong approach to the
problem, this does not mean that one cannot come up with some useful
type inference algorithms tailored to Erlang. Actually I would claim
very useful and effective ones.
Also, since I've heard the (wrong) argument about code reloading being a
big stopper for type inference, what exactly is the fundamental problem
that makes type inference break in its presence? Really none. Type
inference takes a set of modules M1,..,Mj,..,Mk and calculates types for
their functions. Code reloading just means that the types which have
been previously inferred for these modules have to be (incrementally)
recalculated when a module Mj is reloaded. If, say the compiler, has
performed some optimizations based on the previously inferred types, it
just means that it has to have some way of undoing these optimizations,
possibly reapplying new ones, or simply telling the loader that the new
version of the module cannot be reloaded because it is incompatible with
the rest of the application. (*) In any case, it is as simple as that.
The issues with code reloading seem to me purely engineering ones, and
not something which disallows type inference in its presence.
Please think before you write statement that look authoritative but are
plainly wrong.
Kostis
(*) Note that prohibiting code reloading in some cases is an action
which actually might be a good idea even in Erlang as it is today! I
really fail to see how the current practice of allowing reloading of
single modules that are clearly incompatible with the rest of the system
is a safe thing to do or a good idea. But that's a different topic...
More information about the erlang-questions
mailing list