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

Quick question about lexically scoped defun...



    Date: Wed, 22 Jun 88 16:57 EDT
    From: miller@ACORN.CS.ROCHESTER.EDU (Brad Miller)

    Following the discussion in comp.lang.lisp and interested in playing with
    what X3J13 is likely to define as legal...

    If I do:

    (let ((foo 0))
      (defun FOO+ ()
	(INCF FOO))

      (DEFUN FOO? ()
	FOO))

    and compile it in the editor, it warns me about the non-null lexical env.
    and do I really want to do this?

    using the file compiler I just get warnings about DEFUN not at top level.

    In both cases, the global definitions of foo? and foo+ work exactly as you
    would expect: they understand that FOO is a reference to the lexical
    environment. This is a feature I'd like to take advantage of in my
    day-to-day programming.

    The question is: Since this REALLY IS what I want to be able to do, can I
    turn this sort of warning off, i.e. for the file, a system, or for my entire
    environment? I couldn't find any appropriate references in the document
    examiner, and from glancing at the definition of
    Enclose-Top-Level-Environment it looked like a change would be non-trivial.
    I'm hoping there's actually a switch somewhere I don't know about.

All the complexity in that function is to be able to ask an intelligent
question.  If you don't want the question asked, replace it with:

(DEFUN ENCLOSE-TOP-LEVEL (LAMBDA ENV NAME)
  ENV)

I agree that there should be a parameter to control this.