# No subject

Sun Sep 19 15:01:13 UTC 2010

```is some confusion about type systems, in particular strict<br>
vs strong typing.<br>
<br>
Type systems can basically be mapped onto two axes;<br>
<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0strong<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 dynamic ----------+---------- static<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 weak<br>
<br>
Strong type systems prevent you from doing things that do not make<br>
sense like adding an integer and a list. For instance, in Python,<br>
<br>
=A0 =A0&gt;&gt;&gt; x =3D 1<br>
=A0 =A0&gt;&gt;&gt; y =3D [ 1 , 2 ]<br>
=A0 =A0&gt;&gt;&gt; x + y<br>
<br>
gives an error like &quot;unsupported operand type(s) for +: &#39;int&#39; =
and &#39;list&#39;&quot;.<br>
<br>
Weak type systems allow things that don&#39;t make sense (possibly with<br>
a user provided type cast). For instance in C:<br>
<br>
=A0 =A0 =A0 float test (GLIst *list)<br>
=A0 =A0 =A0 { =A0 =A0int x =3D 10 ;<br>
=A0 =A0 =A0 =A0 =A0 =A0return x + (int) list ;<br>
=A0 =A0 =A0 }<br>
<br>
the above makes no sense whatsoever, but the compiler accepts the<br>
programmers word that this is in fact what the programmer wants.<br>
<br>
Purely static type systems are ones where all the types are checked at<br>
compile time and the run time objects contain no type information<br>
and no type checking is done at run time.<br>
<br>
Purely dyanmic type systems are ones where every run time data<br>
object carries around its type and all the type checking is done<br>
at run time.<br>
<br>
With the above axes set up you can have languages like C with<br>
weak static types, Haskell with strong static types and Python<br>
with strong dynamic types. I don&#39;t know of any language that<br>
can really be said to have weak dynamic types.<br>
<br>
Furthermore, most dynamically types languages have a small amount<br>
of static type checking built in, but this is usually a by product<br>
of syntax checking.<br>
<br>
Similarly, in a statically typed langauge its possible to implement<br>
a library with an object type where the type checking for operations<br>
on those objects is carried out at run time.<br>
<br>
Finally, many people assume that all strictly typed languages<br>
require the programmer to explicitly define the types of everything.<br>
Fortunately, this is not the case. There are a whole family of<br>
languages that use Hindley-Milner type inference to infer the types<br>
of all objects from the context. These languages include Ocaml and<br>
<br>
<br>
HTH,<br>
Erik<br>
<font color=3D"#888888">--<br>
----------------------------------------------------------------------<br>
Erik de Castro Lopo<br>
<a href=3D"http://www.mega-nerd.com/" target=3D"_blank">http://www.mega-ner=
d.com/</a><br>
_______________________________________________<br>
Linux-audio-user mailing list<br>
<a href=3D"mailto:Linux-audio-user at lists.linuxaudio.org">Linux-audio-user at l=
ists.linuxaudio.org</a><br>
<a href=3D"http://lists.linuxaudio.org/listinfo/linux-audio-user" target=3D=
"_blank">http://lists.linuxaudio.org/listinfo/linux-audio-user</a><br>
</font></blockquote></div><br>

--0016363b8fbac4428f04929a53d8--
```