From: dc
Subject: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <73fb8c60-2939-4518-81cc-78d5d428f832@d2g2000pra.googlegroups.com>
Hi,

If I have something like

(defun blah (x y z)
  (let ((a 1) (b 2) (c 3))
    (print (local-vars))
    (print (+ a x))
    (print (+ b y))
    (print (+ c z))))

How would I write (local-vars) ?
It would return (a b c), a list of the local vars.

Would it be possible to write it without writing a some kind of
replacement for let ?

Any ideas, criticisms welcome.

Regards

PS Code above is 'lisp pseudo-code', freehand typed, not sure it
parses correctly.
David

From: Lars Rune Nøstdal
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <59dd5a05-4b48-4bf0-b54c-3071d208aef4@k2g2000yql.googlegroups.com>
On Jun 23, 6:14 am, dc <··············@gmail.com> wrote:
> Hi,
>
> If I have something like
>
> (defun blah (x y z)
>   (let ((a 1) (b 2) (c 3))
>     (print (local-vars))
>     (print (+ a x))
>     (print (+ b y))
>     (print (+ c z))))
>
> How would I write (local-vars) ?
> It would return (a b c), a list of the local vars.
>
> Would it be possible to write it without writing a some kind of
> replacement for let ?
>
> Any ideas, criticisms welcome.
>
> Regards
>
> PS Code above is 'lisp pseudo-code', freehand typed, not sure it
> parses correctly.
> David


This is probably not a very good idea, but:


CL-USER> (macrolet ((local-vars ()
                      (let ((lex sb-c:*lexenv*))
                        `'(,@(loop :for var :in (reverse (sb-c::lexenv-
vars lex))
                                :collect (car var))))))
           (flet ((blah (x y z)
                    (let ((a 1) (b 2) (c 3))
                      (print (local-vars))
                      (print (+ a x))
                      (print (+ b y))
                      (print (+ c z)))))
             (blah 4 5 6)))

(X Y Z A B C)
5
7
9

CL-USER> (lisp-implementation-type)
"SBCL"
CL-USER> (lisp-implementation-version)
"1.0.29.19"
From: Lars Rune Nøstdal
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <81f4cbcb-003d-48b3-b993-a35afa29bc2d@m19g2000yqk.googlegroups.com>
USENET sucks by the way. There is not a _single_ decent GUI or Web
client out there.
From: http://public.xdi.org/=pf
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <m2hby7fjaa.fsf@wyoming.home>
Lars Rune N�stdal <···········@gmail.com> writes:

> USENET sucks by the way. There is not a _single_ decent GUI or Web
> client out there.

Usenet sucks?  Perhaps, but it's infinitely preferable to the common
alternatives (web forums...like sticking needles in your eyes)

What's wrong with Gnus?
From: Lars Rune Nøstdal
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <c003a9d7-b0f9-4502-a090-cce9697d26d0@a36g2000yqc.googlegroups.com>
On Jun 23, 10:26 am, Paul Foley <····@below.invalid> (http://
public.xdi.org/=pf) wrote:
> Lars Rune Nøstdal <···········@gmail.com> writes:
>
> > USENET sucks by the way. There is not a _single_ decent GUI or Web
> > client out there.
>
> Usenet sucks?  Perhaps, but it's infinitely preferable to the common
> alternatives (web forums...like sticking needles in your eyes)
>
> What's wrong with Gnus?

It comes with a manual.
From: Kaz Kylheku
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <20090705230248.786@gmail.com>
On 2009-06-23, Lars Rune Nøstdal <···········@gmail.com> wrote:
> USENET sucks by the way. There is not a _single_ decent GUI or Web
> client out there.

And so your reaction is to use the worst? :)
From: David Golden
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <h1rs26$80d$1@aioe.org>
Lars Rune N�stdal wrote:
> USENET sucks by the way. There is not a _single_ decent GUI or Web
> client out there.

Shrug. Mozilla Thunderbird does nntp and AFAIK works on all major
platforms if you want click'n'drool.
From: budden
Subject: Re: Is it possible to get a list of local variables inside a defun?
Date: 
Message-ID: <c1ed092b-a787-4174-96f0-56b79bd5c441@x3g2000yqa.googlegroups.com>
> Hi,
>
> If I have something like
>
> (defun blah (x y z)
>   (let ((a 1) (b 2) (c 3))
>     (print (local-vars))
>     (print (+ a x))
>     (print (+ b y))
>     (print (+ c z))))
>
> How would I write (local-vars) ?
> It would return (a b c), a list of the local vars.
>
> Would it be possible to write it without writing a some kind of
> replacement for let ?
It looks like you need codewalker, redefine not let, but a defun
itself.
Or maybe define your own "hairy-defun". Good examples of codewalkers
are
iterate, ap5 and screamer.