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

static types in Lisp (Icon)

Michael Vanier wrote:
> ...
> Which leads me to something I've wondered about for a long time.  Why
> aren't there statically-typed dialects of lisp and scheme?  ... Is it because the
> s-expression syntax is too cumbersome to use with explicit type
> declarations?  I know Curl has optional static types, ...

For this purpose you can think of Curl as S-expression Scheme with curly
braces instead of parentheses.  

S-expression syntax doesn't impose any problems.  In Curl, types are
declared by following the name of a variable with :type-name in a
declaration.  The separate 'declare' syntax used in Common Lisp could
have been used instead, without causing semantic problems. We just feel
the colon syntax that puts the type near the variable name is easier to

More profound issues come from the nature of what is boxed and what
isn't.  Curl has an 'any' type that can box-up (type-tag) anything,
including "primitives" like numbers.  The compiler keeps track of
operator signatures and coerces to/from 'any' as needed.  As
implemented, this has consequences for overriding methods (a form of
contravariance is required) and redefining types or procedures (you
can't, for example, redefine these in the REPL).  For a cost of speed
and/or compiler complexity, different choices could have been made.