From: Marcin Tustin
Subject: Introspection: A newbie asks
Date: 
Message-ID: <9k6pn6$3fb$1@newsg1.svr.pol.co.uk>
    Having looked through the HyperSpec, and other literature, I can't see
any features that give lisp it's much-touted introspective quality. Whither
these features, my Comrades ?

From: Barry Margolin
Subject: Re: Introspection: A newbie asks
Date: 
Message-ID: <5GC97.18$TO3.166@burlma1-snr2>
In article <············@newsg1.svr.pol.co.uk>,
Marcin Tustin <·······@GUeswhatthisbitisfor.mindless.com> wrote:
>    Having looked through the HyperSpec, and other literature, I can't see
>any features that give lisp it's much-touted introspective quality. Whither
>these features, my Comrades ?

Some of these features are implementation-dependent, but just about every
implementation has a form of them.  In the case of CLOS, most of the
introspective features are in the MOP, which is not part of the ANSI
standard.

But the base CL language has: EVAL, which allows you to construct code to
execute on the fly; FUNCTION-LAMBDA-EXPRESSION, which allows you to get the
source code to a function (if it's available -- the file compiler typically
doesn't include it in its output); and a few functions for examining CLOS
generic functions, like FIND-METHOD.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Coby Beck
Subject: Re: Introspection: A newbie asks
Date: 
Message-ID: <xXC97.57648$Gh1.8743318@typhoon.tampabay.rr.com>
"Marcin Tustin" <·······@GUeswhatthisbitisfor.mindless.com> wrote in message
·················@newsg1.svr.pol.co.uk...
>     Having looked through the HyperSpec, and other literature, I can't see
> any features that give lisp it's much-touted introspective quality.
Whither
> these features, my Comrades ?
>

CL-USER 35 > (defclass foo ()
              (fee fie fum))
#<STANDARD-CLASS FOO 20DDC5A4>

CL-USER 36 > (defmethod what-am-i? (obj)
               (format t "~&I am a ~A object.  I have the following
slots:~%~%" (type-of obj))
               (let ((class (class-of obj)))
                 (loop for slot in (class-slots class)
                       do (format t "slot: ~A - ~A~%" (slot-definition-name
slot)
                                  (if (slot-boundp obj (slot-definition-name
slot))
                                      (slot-value slot)
                                    "unbound")))))
#<STANDARD-METHOD WHAT-AM-I? NIL (T) 20400D04>

CL-USER 37 > (what-am-i? (make-instance 'foo))
I am a FOO object.  I have the following slots:

slot: FEE - unbound
slot: FIE - unbound
slot: FUM - unbound
NIL

That seems pretty introspective....?

Here's an even better what-am-i? definition:

(defun what-am-i? (&rest args)
    (describe args))

Coby

--
(remove #\space "coby . beck @ opentechgroup . com")
From: Kent M Pitman
Subject: Re: Introspection: A newbie asks
Date: 
Message-ID: <sfw66c86dn2.fsf@world.std.com>
"Marcin Tustin" <·······@GUeswhatthisbitisfor.mindless.com> writes:

>     Having looked through the HyperSpec, and other literature, I can't see
> any features that give lisp it's much-touted introspective quality. Whither
> these features, my Comrades ?

Ability to ask what definitions are present
 LIST-ALL-PACKAGES
 FIND-SYMBOL
 DO-EXTERNAL-SYMBOLS
 DO-SYMBOLS

Ability to promote data to the status of code
 EVAL, COMPILE, COMPILE-FILE

Ability to run code that decides how to handle errors rather than 
just to imperatively transfer to the one and only one matching handler
 HANDLER-BIND
 Ability to have those handlers select programmatically among their options
   FIND-RESTART

Ability to reflect on the type system
 TYPEP, CLASS-OF, FIND-CLASS

Access to program self-documentation
 DOCUMENTATION

Ability to pick apart data
 Common things like "slot" accesses (SYMBOL-NAME, etc.)
 Odd things like FLOAT-RADIX, FLOAT-PRECISION, FLOAT-DIGITS, etc.
  or ability to introspect array types (ARRAY-DIMENSIONS, 
    ARRAY-DISPLACEMENT, etc.)

Ability to browse data under program control
 DESCRIBE