[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: little question



	
    Date: Tue, 07 Jun 88 09:57:40 MET
    From: ETSTMOL%HDETUD1.BITNET@cunyvm.cuny.edu
    From: Marcel Mol                +31 15 783644        ETSTMOL  at HDETUD1
    
    Here is my (little?) question:
    (... perhaps asked a hundred times :-?)
    
    Why does Common Lisp symbols have both a function and a value cell?
    Why not use one of them and use values and function as in Scheme.
    
    Marcel
    
To avoid name clashes.  For example,

(defun foo (cons)
  (cons (rest cons) (first cons)))

will not work in Scheme, since CONS will not have the correct value (the CONS
function).  An even worse case is the following:

Programmer A writes:

(defmacro rev-cons (cons-obj)
  `(cons (rest ,cons-obj) (first ,cons-obj)))

Programmer B writes:

(defun zap (cons)
  (frob (rev-cons cons)))

Programmer B is surprised!

The real problem is this second example is with the semantics of
macros (which Scheme does not "officially" condone (because of the
above problem)).  But since macros are such an important part of CL
and since "sanitizing" is complex, CL skirts the issue by putting
functional variables and 'normal' variables is two different namespaces.

CL progammers are used to dealing with lots of namespaces: functional,
normal variable, package, property-list, etc.

-- Nick