[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: another take on hackers and painters



Michael Vanier wrote:

> I can't say I agree with your views on static typing, although
> many on this list will.  Have you ever used a really *nice*
> static type system like in ocaml or haskell?  They're not
> perfect, but they're miles ahead of what most people think
> of when they think "static typing".

Along these lines, PreScheme was mentioned here again recently, in the
"Language Implementation Languages" thread.  PreScheme looks like ordinary
dynamically typed Scheme, and in fact is valid Scheme which can be executed
by a full Scheme implementation.  However, PreScheme is statically typed,
via type inferencing.  All types are determined at compile time, it doesn't
do any runtime type discrimination.  The PreScheme compiler will object if
it detects a type error during compilation.

PreScheme compiles to C, and its types map directly to native C types,
without the use of e.g. a union type which can hold any Scheme value.  So,
here you have a fully statically typed language whose code looks exactly
like (a subset of) Scheme, usually a shining example of a dynamically typed
language.

I assume there are caveats to this - things you can't do in PreScheme which
you can do in full Scheme, specifically because of the type system (although
perhaps not as many as one might imagine, since the PreScheme compiler is
quite sophisticated).  Still, I think PreScheme highlights the fact that
static typing doesn't have to be what many people think it is, based on
their experiences with languages like C, C++ and Java.

Anton