From: Gareth.McCaughan@... (Gareth McCaughan) Date: 2001-12-13T10:05:18+09:00 Subject: [ruby-talk:28377] Re: The benefits of dynamic typing? "Pixel" wrote: [someone else:] > > > it doesn't seem unreasonable that a language should support both > > > static and dynamic typing. then, if i knew at compile time what the > > > types would be, i could tell the compiler, and i could possibly > > > expose some problems at compile time. but if i didn't know the > > > types at compile time, that would be okay too. [me:] > > Take a look at Common Lisp, or Dylan. They have exactly > > that feature. Good compilers for CL and Dylan do sophisticated > > type inference, so that you don't have to declare all the > > types you know in order to get good compile-time checking [Pixel:] > any links showing what is achieved in those languages? (for the checking, not > the efficiency) Hmm. Not sure off the top of my head. You could try http://www.fun-o.com/ for Dylan and http://www.lisp.org/ for Common Lisp. Note that different implementations will have different type-inferencing abilities. Here's a brief and simplistic example in Common Lisp. If I say (defun f (x) (let ((y (1+ x))) (first y))) and then (compile 'f) to the CMU Common Lisp compiler, I get this warning message: In: LAMBDA (X) (FIRST Y) --> CAR ==> Y Warning: Result is a NUMBER, not a (VALUES &OPTIONAL LIST &REST T). which is liable to be obscure to non-Lispers, but means "You tried to do something that expected a list, but fed it something I know is a number.". Note that there are *no* explicit type declarations in that code. -- Gareth McCaughan Gareth.McCaughan@pobox.com ..sig under construc