Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Constants and DEFCONSTANT

From: Tim Bradshaw <t...@tfeb.org>
Subject: Re: Constants and DEFCONSTANT
Date: 1999/03/25
Message-ID: <nkj7ls6xqm6.fsf@tfeb.org>#1/1
X-Deja-AN: 458760212
Cache-Post-Path: muck.dcs.ed.ac.uk!...@tardis.tardis.ed.ac.uk
References: <nkjpv5y244f.fsf@tfeb.org> <7dbhh3$con$1@spitting-spider.aracnet.com>
X-Complaints-To: abuse@dcs.ed.ac.uk
X-Trace: kane.dcs.ed.ac.uk 922328068 13446 129.215.160.15 (25 Mar 1999 02:14:28 GMT)
Organization: The Tardis Project
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
NNTP-Posting-Date: 25 Mar 1999 02:14:28 GMT
Newsgroups: comp.lang.lisp

mike...@mikemac.com (Mike McDonald) writes:

[I wrote]
> > But perhaps this is no good because it won't allow you to optimise things like:
> > 
> > 	(defconstant foo '(a b))
> > 
> > 	(defun blib ()
> > 	  (cdr foo))
> 
>   There's an old cliche about getting it right first, then worry about
> optimizations.
> 

Yes, and Lisp wins big time here!  Using the `fix it up at load time'
approach, you can obviously have the dangling constant reference
essentially be a *function* of the constant which will compute the
actual thing you want once, at load time (`link time').  The compiler
just has to work out the largest expression which depends on the
constant, convert it to a function (since it depends only on the
constant, there can be no variable capture, so it just amounts to
wrapping it in lambda, and arrange for the loader to call that
function, which will return the thing to splice in.

--tim