From: Bill McDonald
Subject: Upper boundry on lexical bindings
Date: 
Message-ID: <oH%I7.100815$R9.26982310@typhoon.we.rr.com>
Its been awhile for me so please help.
What is the upper boundary on lexical bindings?
Is it just the function within the file or can it
extend to any place in the same file?

Also, when working with defstruct, the make
functions generated all have lexical bindings.
But lexical to what?  Just the symbols within
the defstruct?

Thanks,

Bill McDonald

P.S.  Its sure is nice to have a decent language to
program in again.   Too bad CL doesn't have
a grep/within-grep functions built-in.  Ok, regexp
would probably be a better built-in tool.

Bill
From: Gabe Garza
Subject: Re: Upper boundry on lexical bindings
Date: 
Message-ID: <k7wrqsur.fsf@kynopolis.org>
"Bill McDonald" <·········@mediaone.net> writes:

> Its been awhile for me so please help.
> What is the upper boundary on lexical bindings?
> Is it just the function within the file or can it
> extend to any place in the same file?

If I understand your question right, the latter. It's perfectly legal
(and often useful) to do stuff like:

(let ((count 0))

  (defun reset-tag-counter ()
    (setf count 0))

  (defun gen-tag ()
    (prog1 count (incf count))))             

> Also, when working with defstruct, the make
> functions generated all have lexical bindings.
> But lexical to what?  Just the symbols within
> the defstruct?

The only reference I find to the word "lexical" in the hyperspec entry
on defstruct is in regards the constructor.  If I understand it
correctly (big IF), all that passage is saying is that the initforms
supplied to defstruct are evaluated in the same lexical environment as
the defstruct itself.  In other words, if you have this:

(let ((foo 3))
 (defstruct thing
   (x foo)))

Then this:

(thing-x (let ((foo 5))
           (make-thing)))

will evaluate to 3 because the FOO that is the initform to X is
evaluated in the lexical environment of the defstruct (where it is
bound to 3).

> P.S.  Its sure is nice to have a decent language to program in
> again.  Too bad CL doesn't have a grep/within-grep functions
> built-in.  Ok, regexp would probably be a better built-in tool.

Everyone and his great-grandma's pet ferret has written a Common Lisp
regular expression library.  Here are a few:

  http://www.cs.rice.edu/~dorai/pregexp/pregexp.html
  ftp://ftp.digitool.com/pub/mcl/contrib/nregex.lisp
  http://www2.worldpbx.com/regexp/

Gabe Garza