Xref: utzoo comp.lang.misc:3826 comp.software-eng:2730 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!rutgers!att!cbnewsc!lgm From: lgm@cbnewsc.ATT.COM (lawrence.g.mayka) Newsgroups: comp.lang.misc,comp.software-eng Subject: Re: An Interesting View of "Strong" Vs. "Weak" Typing Keywords: typing, Ada, Lisp, definitions, evidence Message-ID: <12608@cbnewsc.ATT.COM> Date: 5 Jan 90 23:25:33 GMT References: <1990Jan5.084746.17836@cs.eur.nl> Reply-To: lgm@cbnewsc.ATT.COM (lawrence.g.mayka,ihp,) Organization: AT&T Bell Laboratories Lines: 43 In article <1990Jan5.084746.17836@cs.eur.nl> reino@cs.eur.nl (Reino de Boer) writes: >compile-time evaluation of possible types. Although something can be >said in favor of the statement > all interpreters (CL, Smalltalk, etc.) by definition do only > run-time checking (not being able to compile at all). Common Lisp programs are typically compiled into native machine instructions. For example, one typical implementation on the SPARC architecture compiles the following function (defun add (x y) (+ x y) ) into exactly 11 machine instructions. Such a function properly computes the sum of any two numbers - integers of any size, floating-point, rational, or complex. (Only 5 instructions are executed if each argument happens to be an integer that fits into a single machine word.) If one annotates this definition with optional type declarations thus: (defun add (x y) (declare (fixnum x y)) (the fixnum (+ x y)) ) the compiler emits exactly 4 machine instructions. If this latter function is passed arguments of unexpected types - e.g., rational numbers 4/5 and 7/8 - the run-time system traps the attempt and asks the user if it should proceed with the addition anyway. This exception handling behavior can of course be overridden by the programmer.) An interpreter is usually also available but most CL programmers use it primarily to execute top-level environment commands such as ED, COMPILE-FILE, LOAD, TRACE, DESCRIBE, INSPECT, and DISASSEMBLE. Lawrence G. Mayka AT&T Bell Laboratories lgm@ihlpf.att.com Standard disclaimer.