type safety (was Re: FAQ terminology harmonisation)

Thomas Lindgren thomasl_erlang@REDACTED
Fri Apr 4 11:29:53 CEST 2003


Good points, both of them.

--- Chris Pressey <cpressey@REDACTED> wrote:
> On Thu, 3 Apr 2003 01:28:43 -0800 (PST)
> Thomas Lindgren <thomasl_erlang@REDACTED> wrote:
> 
> > * The main benefit of Erlang, Lisp, Prolog, SML
> and so
> > on is _type_safeness_: there is no way that you
> can
> > accidentally confuse one value's type with
> another.
> 
> Not in Erlang.
> Not if you consider tuples and records two different
> types.
> Which they should be.
> But aren't.

There are two problems with records IMO:

- Records of different record type can be confused
with each other (breaks type safeness in my eyes, but
I consider it a bug in the implementation rather than
something fundamental)

- The underlying tuples show through the record
implementation. Unfortunate choice, but here the
argument (not mine :-) seems to be that "records
really are just syntactic sugar for tuples".

(Oh yeah, a third, related problem is the dependence
on include files for record definitions.)

> We won't have type safety until we have truly opaque
> types.
> We have a warning not to let type information leak
> out of a module.
> But we currently *have* to implement types on top of
> existing types:
> usually tuples, or lists, or binaries could be used,
> or even refs or
> pids or atoms... but all of these can be confused
> with others of the
> same type, used in a different role.

It depends a bit on what you mean by type, I'd say --
you can have exactly the same problem in SML. But I
think you have a good point that it would sometimes be
useful to have support for user-defined data types
guaranteed to be distinct from all other types.

Also, SML:s abstypes are an admirable use of typing to
handle abstract data types; I should have mentioned
that in the original message.

Best,
Thomas


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com



More information about the erlang-questions mailing list