Article View: comp.lang.misc
Article #6616Re: An Interesting View of "Strong" Vs. "Weak" Typing
From: lawrence.g.mayka
Date: Fri, 05 Jan 1990 23:25
Date: Fri, 05 Jan 1990 23:25
43 lines
2183 bytes
2183 bytes
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.
Technical Details
Message-ID:
<12608@cbnewsc.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!psuvax1!rutgers!att!cbnewsc!lgmReferences:
<1990Jan5.084746.17836@cs.eur.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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