From: slash dot on
lisp is famous for is reflection capabilities, and,
indeed, a function like '10+' is reported to be

#<FUNCTION 10+ (NUMBER) (DECLARE (SYSTEM::IN-DEFUN 10+))
(BLOCK 10+ (+ 10 NUMBER))>

in clisp.

(Disturbingly, this only works if I bind #'10+ to a variable and
evaluate
the variable, but that's a clisp implementation detail, right? RIGHT?)

So my question is: how can I inspect functions to find out how
many arguments it has, for example?

From: Andre Ramaciotti on
slash dot <tyntyfax(a)gmail.com> writes:

> lisp is famous for is reflection capabilities, and,
> indeed, a function like '10+' is reported to be
>
> #<FUNCTION 10+ (NUMBER) (DECLARE (SYSTEM::IN-DEFUN 10+))
> (BLOCK 10+ (+ 10 NUMBER))>
>
> in clisp.
>
> (Disturbingly, this only works if I bind #'10+ to a variable and
> evaluate
> the variable, but that's a clisp implementation detail, right? RIGHT?)
>
> So my question is: how can I inspect functions to find out how
> many arguments it has, for example?

You say like this?

* (defun sum (x y)
(+ x y))

SUM
* (describe #'sum)

#<FUNCTION SUM>
[compiled function]

Lambda-list: (X Y)
Derived type: (FUNCTION (T T) (VALUES NUMBER &OPTIONAL))
Source form:
(LAMBDA ()
(DECLARE (MUFFLE-CONDITIONS COMPILER-NOTE))
(PROGN
(SB-INT:NAMED-LAMBDA SUM
(X Y)
(BLOCK SUM (+ X Y)))))
From: slash dot on
On 1 Feb., 00:38, Andre Ramaciotti <andre.ramacio...(a)gmail.com> wrote:
> slash dot <tynty...(a)gmail.com> writes:
> > lisp is famous for is reflection capabilities, and,
> > indeed, a function like '10+' is reported to be
>
> >     #<FUNCTION 10+ (NUMBER) (DECLARE (SYSTEM::IN-DEFUN 10+))
> >     (BLOCK 10+ (+ 10 NUMBER))>
>
> > in clisp.
>
> > (Disturbingly, this only works if I bind #'10+ to a variable and
> > evaluate
> > the variable, but that's a clisp implementation detail, right? RIGHT?)
>
> > So my question is: how can I inspect functions to find out how
> > many arguments it has, for example?
>
> You say like this?
>
> * (defun sum (x y)
> (+ x y))
>
> SUM
> * (describe #'sum)
>
> #<FUNCTION SUM>
>   [compiled function]
>
> Lambda-list: (X Y)
> Derived type: (FUNCTION (T T) (VALUES NUMBER &OPTIONAL))
> Source form:
>   (LAMBDA ()
>     (DECLARE (MUFFLE-CONDITIONS COMPILER-NOTE))
>     (PROGN
>      (SB-INT:NAMED-LAMBDA SUM
>          (X Y)
>        (BLOCK SUM (+ X Y)))))

Thanks for your prompt reply, but this is not what I meant.
What I meant is: how can my program inspect lisp functions?
'describe' is more a documentation facility. (Or so I've learned.)

From: Zach Beane on
slash dot <tyntyfax(a)gmail.com> writes:

> lisp is famous for is reflection capabilities

No, it's not.

Zach
From: slash dot on
On 1 Feb., 00:52, Zach Beane <x...(a)xach.com> wrote:
> slash dot <tynty...(a)gmail.com> writes:
> > lisp is famous for is reflection capabilities
>
> No, it's not.
>
> Zach

So one cannot inspect a function, is that what's you're
saying, Zach? Have I fallen for an April fool's joke?
No dice?

 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: Do as the Romans do
Next: managing large table of data