Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion Lisp dinamism vs ML safety
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pascal Costanza  
View profile  
 More options Oct 12 2006, 3:09 am
Newsgroups: comp.lang.lisp
From: Pascal Costanza <p...@p-cos.net>
Date: Thu, 12 Oct 2006 09:09:17 +0200
Local: Thurs, Oct 12 2006 3:09 am
Subject: Re: Lisp dinamism vs ML safety

Henry Bigelow wrote:
> hi everyone,
>   just wanted to say thanks for the posts.  very enlightening!

> would it be possible to write a system of macros, say, to make
> available the abstract, recursive, inferred, variant etc. yet static
> typesystem of O'Caml in lisp?  say, in the way CLOS was an extension of
> lisp to objects.

> or is there a reason why this is impossible to do in lisp?

That's not related to Lisp per se. But in the general case, dynamic
typing and static typing are not compatible. In Common Lisp, there are a
lot of cases where you can very conveniently change types at runtime. So
a static check of types would be a great burden. Here is my standard
example for this:

(defclass person ()
   ((name :initarg :name)))

(let ((p (make-instance 'person :name "Pascal")))
   (eval (read))
   (setf (slot-value p 'address) "Brussels"))

There is no chance to see upfront whether this program will fail or not,
since the user can redefine the class person when (eval (read)) is
executed. At that time, the slot 'address could be added to the class
person. This is a contrived example, but similar things are indeed
actually quite useful in a certain class of programs. (Think of
frame-based knowledge representation systems, for example.)

On the other hand, in a statically typed language (with a sufficiently
interesting type system, like Hindley-Milner type systems), you can do
things like dispatch on the expected return type of a function. In a
dynamically typed language, you don't have any guarantees about future
computations, but in statically typed language, you can ensure that only
certain types (or a certain type) is returned from a function.

So in the extreme case, dynamically typed and statically typed languages
offer different kinds of expressiveness, and depending on what you want
to do, the one approach is indeed better suited for a problem at hand
than the other. If you don't want to take advantage of the specific
advantages, then it's rather just a matter of taste.

All other claims about static vs. dynamic types are bogus and unfounded,
and based on anecdotal evidence at best. Especially the typical claims
wrt efficiency and safety are unfounded. These claims are typically
demonstrated on small toy programs, and this doesn't prove anything.

> why is it not possible to 'turn off' static typechecking for individual
> functions while compiling o'caml?

Because this would change the semantics of the language.

Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google