[erlang-questions] Typed records and erl_parse

Tobias Lindahl Tobias.Lindahl@REDACTED
Tue Dec 5 11:53:33 CET 2006

Christian S wrote:
> The changes as talked about in this thread I take it?
> http://www.erlang.org/pipermail/erlang-questions/2006-November/023930.html

Yes, this is correct.

> Is this something erl_parse will accept to parse but throw away? 

It will parse it and return a representation of the typed fields that 
include the declared type. For record fields not containing a type 
declaration, the type will be the any() type. This is what might casue 
trouble for people, if they pattern match on the actual field 

> Will these type annotations spread out in a future to be used in other
> places in the erlang language? Perhaps as shorthand for type-guards
> when pattern matching?

This is somewhat unrelated to what we are doing, but that doesn't 
prevent that we can make use of the type information in other ways in 
the future.

For now, our focus is to use this information to give better warnings 
from Dialyzer. You might look at it as a contract. The user states that 
this is how I intend to use this record, and if Dialyzer can find that 
this is not the case you can get a warning, and if Dialyzer cannot say 
exactly how the record is constructed, it can assume that the 
declarations can be trusted until it can prove otherwise.


More information about the erlang-questions mailing list