typing
Sean Hinde
Sean.Hinde@REDACTED
Wed Aug 23 15:04:16 CEST 2000
It may be useful to share some of our findings here at One2One on using
Erlang for some reasonably complex jobs..
Most common causes of bugs not found until runtime:
1. Referring to a non existent external function.
2. Mistyping (i.e. fingers not Type!) of atoms used as tags in either
receive clauses or case clauses.
3. Printing Strings. The io[_lib]:format commands require you to know that a
string is a string type before using %s to print it without double quotes,
otherwise it crashes. In a weakly typed language with no efficient
is_string/1 this is a royal PITA.
These cause problems most in weird error capture cases which may have not
been executed during testing (surely not). My personal favourite is
error_report:format("Aargh").
We have not tended to have problems with adding Integers to Atoms or other
such things which type systems protect against.
One could think of possible solutions to these three which do not involve a
full type system.
1. A tool to go through a system and root out external reference problems
(admittedly difficult to deal with apply(M,F,A)) would help. It would also
be nice when loading a piece of code into a running system to get a result
which included some indication of whether all the external references were
resolved, or even an option which would only load the new code if this was
true.
2. I guess any solution to finger trouble in atoms is getting towards a
proper type system. Maybe something which could be declared at the start of
a module which restricted the set of atoms which could be defined in the
source for that file would do 80% of the job. Language Guru help needed!
3. Well, a string type would help!! Barring that to implement something like
in Java (ironically strongly typed) where you can send any rubbish into a
System.out.println and it will do its best to format it in a nice readable
form without adding extraneous " for example. The current C derived mini
typed language %d%s is to me something of an anachronism.
Having said all that we have had two large systems in service now for
several months and not had a single outage.
Thoughts?
Sean
> -----Original Message-----
> From: Thomas Arts [mailto:thomas@REDACTED]
> Sent: 23 August 2000 07:44
> To: James Hague
> Cc: erlang-questions@REDACTED
> Subject: Re: typing
>
>
> James Hague wrote:
> >
> > >are there already some feedback on that approach ? is it
> "academic" or
> > frozen ?
> > >used in projects?
> >
> > I asked this not too long ago. The response was that the
> type system was a
> > cancelled project.
>
> Well, the projects that tried the typesystem were canceled,
> that's what I
> wrote. The typesystem self is more in a frozen phase. Some experiments
> are going on, but on a low priority level. The problem is
> that Erlang has
> not been designed with a type system in mind. Adding one
> later is possible,
> but at a certain cost w.r.t. the freedom of programming. We
> are investigating
> whether we can find an acceptable compromise for things to give up.
>
> However, I can recommend everyone to start using teh SpecWeb
> software in
> order to make the datatype specifications. This is useful even without
> a checking program.
>
> Regards
> Thomas
>
NOTICE AND DISCLAIMER:
This email (including attachments) is confidential. If you have received
this email in error please notify the sender immediately and delete this
email from your system without copying or disseminating it or placing any
reliance upon its contents. We cannot accept liability for any breaches of
confidence arising through use of email. Any opinions expressed in this
email (including attachments) are those of the author and do not necessarily
reflect our opinions. We will not accept responsibility for any commitments
made by our employees outside the scope of our business. We do not warrant
the accuracy or completeness of such information.
More information about the erlang-questions
mailing list