Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!snorkelwacker!spdcc!merk!alliant!linus!luke.mitre.org!dsr From: dsr@luke.mitre.org (Douglas S. Rand) Newsgroups: comp.lang.lisp Subject: Re: Dumb Common Lisp question Message-ID: <112523@linus.mitre.org> Date: 5 Jul 90 14:30:49 GMT References: <4204@jato.Jpl.Nasa.Gov> <1990Jun29.162248.7846@Neon.Stanford.EDU> <1005@lehi3b15.csee.Lehigh.EDU> Sender: usenet@linus.mitre.org Reply-To: dsr@luke.mitre.org (Douglas S. Rand) Distribution: usa Lines: 62 In article <1005@lehi3b15.csee.Lehigh.EDU>, jearly@lehi3b15.csee.Lehigh.EDU (John Early) writes: |>In article <1990Jun29.162248.7846@Neon.Stanford.EDU> max@Neon.Stanford.EDU (Max Hailperin) writes: |> |> In article <4204@jato.Jpl.Nasa.Gov> brian@granite.Jpl.Nasa.Gov |> (Brian of ASTD-CP) writes: |> >[...] I have one pressing question about CL. What is the rationale |> >behind the (function ...) or #' construct? [...] |> >I'm most familiar with Scheme/T, where this kind of thing is |> >not necessary. All symbols are evaluated the same way [...] |> >Treating a function as just another data type |> >like integer or string seems very neat and clean. There must |> >be some reason it's not done this way in CL. |> |> It's done this way for the sake of people who like to call an argument |> that's a list "list" and still be able to use the "list" function, as in |> |> (defun foo (list) |> "Return a list of the sum of the list and the sum-of-squares of the list." |> (list (apply #'+ list) |> (apply #'+ (mapcar #'square list)))) |> |> instead of having to call it the-list like you would in scheme. |> [Of course, this applies to other names as well, list is just a common one.] |>Since this is bad programming (at best) I suspect that that is not the reason. |>I would guess that there is instead an historical/compatibility reason. |>John. |> For those unwilling to read Gabriel and Pitman's paper... First it is naive to simply claim 'bad programming'. The reason CL has both function and value cells to start with is that it is a derivative of the MacLISP/ZetaLISP school of LISP languages. The reason for having two cells is indeed to prevent problems where a name is used for both a function and variable. It is neither 'good' nor 'bad' programming practice. It is very easy to have this happen in real applications. CL is not Scheme. Scheme is a language where symbols have only one 'value'. You therefore need no special syntax to claim to access the function cell of a function over the value cell. But for those who believe collapsing the function and value cells together simplifies things alot, think again. There are not just two namespaces in CL. More like six or seven. Names are used for tags, types (and classes in CLOS), conditions, packages, as well as values and functions. Past this it's worth noting that the programmer can use the plist of the symbol to add indefinitely more interpretations of the symbol. There are many purist reasons for combining function and value namespaces not the least of which is greater simplicity of language. One can get rid of the duality of functions and contructs like flet, fmakeunbound, symbol-function and syntactic contstructs like #'. Douglas S. Rand Internet: Snail: MITRE, Burlington Road, Bedford, MA Disclaimer: MITRE might agree with me - then again...