Newsgroups: comp.lang.scheme,comp.lang.misc,gnu.misc.discuss
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!EU.net!julienas!news.fnet.fr!ilog!news
From: davis@ilog.fr (Harley Davis)
Subject: Re: Scheme requires '() to be a true value (was Re: GNU Extension
In-Reply-To: lux@rio.heidelbg.ibm.com's message of 3 Nov 1994 12:47:06 GMT
Message-ID: <DAVIS.94Nov3150954@passy.ilog.fr>
Lines: 49
Sender: news@ilog.fr
Nntp-Posting-Host: passy
Organization: Ilog SA, Gentilly, France
References: <9410190420.AA02904@mole.gnu.ai.mit.edu> <MDJ.94Oct23224108@sansca
	<SHOUMAN.94Oct31142257@goofy.cc.utexas.edu>
	<1994Nov1.231028.6677@rosevax.rosemount.com>
	<1994Nov3.030630.1930@kestrel.edu> <39am4a$mbj@kaa.heidelbg.ibm.com>
Date: 03 Nov 1994 14:09:54 GMT
Xref: glinda.oz.cs.cmu.edu comp.lang.scheme:10909 comp.lang.misc:18706 gnu.misc.discuss:19408


In article <39am4a$mbj@kaa.heidelbg.ibm.com> lux@rio.heidelbg.ibm.com (Wolfgang Lux) writes:

   From: lux@rio.heidelbg.ibm.com (Wolfgang Lux)

   In article <1994Nov3.030630.1930@kestrel.edu>, mcdonald@kestrel.edu (Jim McDonald) writes:
   |> Assume you have a function called LIST, for making a list.
   |> Also assume FROB returns a list.  Then it's very tempting to write
   |> 
   |>    (let ((list (frob y))) ... (fiddle-with list) ...)
   |> 

   So why not be tempted? Actually I often write things like your first
   example and it works perfectly well. It is not a question of separate
   namespaces but a question of static (or lexical) vs. dynamic
   scoping. The function FROB will *never* access the LIST variable
   locally bound to the let function (even if you a (LAMBDA (FOO) (LIST
   FOO)) in place of the FROB); it simply does not know anything about
   this variable due to Scheme's (and btw. Common Lisp's) scoping rules.

One problem is that you might sometime in the future change the name
of the variable "list" to something else.  Or you might mistype the
"list" in the "let".  The code will then not signal an error in the
correct place.  Even if you have some kind of static analysis tool, it
will not show the error until you get some kind of "#<procedure
@03af32> not a list" error in fiddle-with (if it checks) or even
further down the call chain.  (You might be lucky and get a "variable
lst unused" warning, but it's unlikely.)

Reducing the number of names in a namespace and their legal contexts
increases the possibilities for static analysis to find many errors
which would otherwise go undetected until runtime, in a way orthogonal
to static type checking.  This is the use to which we put multiple
namespaces in Talk's module system.  You can find out more about this
by reading our paper "Talking about Modules and Delivery", available
from Ilog's WWW server <a href="http://www.ilog.fr/">(click here if
you're using a Web browser)</a> or by writing to info@ilog.com.

-- Harley Davis
-- 

------------------------------------------------------------------------------
motto: Use an integrated object-oriented dynamic language today.
       Write to info@ilog.com and ask about Ilog Talk.
------------------------------------------------------------------------------
Harley Davis                            net: davis@ilog.fr
ILOG S.A.                               tel: +33 1 46 63 66 66
2 Avenue Gallini, BP 85                fax: +33 1 46 63 15 82
94253 Gentilly Cedex, France            url: http://www.ilog.fr/
