Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
obtaining a package's functions
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
jakemiles  
View profile  
 More options Nov 22 2006, 10:48 pm
Newsgroups: comp.lang.lisp
From: "jakemiles" <jacob.mi...@gmail.com>
Date: 22 Nov 2006 19:48:23 -0800
Local: Wed, Nov 22 2006 10:48 pm
Subject: obtaining a package's functions
Hello all.  I'm completely confused no matter what I look at on the
internet or in Paul Graham's Ansi Common Lisp.  I just want to obtain a
list of all functions defined in a package.  Can someone show me a
clear example of how this is done?  For example, what code would list
all the functions defined in common-lisp?  Also, I'm not interested in
inherited functions, only those defined in the package itself.

Thanks for any help.

- Jake


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 12:30 am
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 22 Nov 2006 21:30:51 -0800
Local: Thurs, Nov 23 2006 12:30 am
Subject: Re: obtaining a package's functions

jakemiles wrote:
> Hello all.  I'm completely confused no matter what I look at on the
> internet or in Paul Graham's Ansi Common Lisp.  I just want to obtain a
> list of all functions defined in a package.  Can someone show me a
> clear example of how this is done?  For example, what code would list
> all the functions defined in common-lisp?  Also, I'm not interested in
> inherited functions, only those defined in the package itself.

I'm sure wiser heads will post better solutions, but here's a piecewise
one that might help:

(defun symbol-function-p (sym)
  "Is there a function associated with this symbol?"
  (handler-case (symbol-function sym)
    (undefined-function () nil)))

(defun defun-in-package-p (s p)
  "Is this symbol interned in this package, and is there a
  function asssociated with it?"
  (and (symbol-function-p s)
       (eq p (symbol-package s))))

(defun functions-in-package (pkg)
  "Return a list of functions defined in the package PKG."
  (loop for s being the symbols in pkg
     when (defun-in-package-p s pkg)
     collect s))

(defun document-package-functions (pkg)
  "Print documentation of all functions defined in the package."
  (loop for fnsym in (functions-in-package pkg)
       do (princ (format nil "~a~%~a~%~%" fnsym
                         (or (documentation fnsym 'function) "")))))

;; then give it a try:

CL-USER> (document-package-functions (find-package :common-lisp))
DEFPARAMETER
Define a parameter that is not normally changed by the program,
  but that may be changed without causing an error. Declare the
  variable special and sets its value to VAL, overwriting any
  previous value. The third argument is an optional documentation
  string for the parameter.

SETF
Takes pairs of arguments like SETQ. The first is a place and the second
  is the value that is supposed to go into that place. Returns the last
  value. The place argument may be any of the access forms for which
SETF
  knows a corresponding setting form.

CIS
Return cos(Theta) + i sin(Theta), i.e. exp(i Theta).

;;; etc

Graham


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Bourguignon  
View profile  
 More options Nov 23 2006, 2:15 am
Newsgroups: comp.lang.lisp
From: Pascal Bourguignon <p...@informatimago.com>
Date: Thu, 23 Nov 2006 08:15:43 +0100
Local: Thurs, Nov 23 2006 2:15 am
Subject: Re: obtaining a package's functions

Macros also have a symbol-function.

> (defun defun-in-package-p (s p)
>   "Is this symbol interned in this package, and is there a
>   function asssociated with it?"
>   (and (symbol-function-p s)
>        (eq p (symbol-package s))))

Well implementations may export from COMMON-LISP symbols that are
actually defined somewhere else and imported into COMMON-LISP...

(length (remove (find-package "COMMON-LISP")
                 (com.informatimago.common-lisp.package:package-exports "COMMON-LISP")
                :key (function symbol-package)))
--> 54

Better use com.informatimago.common-lisp.package:package-exports to get the symbols
exported from a package...
http://darcs.informatimago.com/lisp/common-lisp/package.lisp

So, to get the list of the functions that are _exported_ from a package:

(defun package-functions (package)
  (remove-if-not (lambda (x) (and (fboundp x) (not (macro-function x))))
                 (com.informatimago.common-lisp.package:package-exports package)))

(length (package-functions "COMMON-LISP"))
--> 660

--
__Pascal Bourguignon__                     http://www.informatimago.com/

HEALTH WARNING: Care should be taken when lifting this product,
since its mass, and thus its weight, is dependent on its velocity
relative to the user.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Mizrahi  
View profile  
 More options Nov 23 2006, 5:18 am
Newsgroups: comp.lang.lisp
From: "Alex Mizrahi" <udode...@users.sourceforge.net>
Date: Thu, 23 Nov 2006 12:18:17 +0200
Local: Thurs, Nov 23 2006 5:18 am
Subject: Re: obtaining a package's functions
(message (Hello 'Graham)
(you :wrote  :on '(22 Nov 2006 21:30:51 -0800))
(

 GF> (defun symbol-function-p (sym)
 GF>   "Is there a function associated with this symbol?"
 GF>   (handler-case (symbol-function sym)
 GF>     (undefined-function () nil)))

why not just fboubdp?

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ken Tilton  
View profile  
 More options Nov 23 2006, 5:26 am
Newsgroups: comp.lang.lisp
From: Ken Tilton <kentil...@gmail.com>
Date: Thu, 23 Nov 2006 05:26:09 -0500
Local: Thurs, Nov 23 2006 5:26 am
Subject: Re: obtaining a package's functions

fboundp?

> (defun defun-in-package-p (s p)
>   "Is this symbol interned in this package, and is there a
>   function asssociated with it?"
>   (and (symbol-function-p s)
>        (eq p (symbol-package s))))

I would expect something named defun-xxxx to be a variant on defun. One
is not looking for defuns in a package, one is looking for functions.
One does not call a defun, once calls a function. etc etc.

> (defun functions-in-package (pkg)
>   "Return a list of functions defined in the package PKG."
>   (loop for s being the symbols in pkg
>      when (defun-in-package-p s pkg)

fboundp?

You already know s is a symbol in pkg, so why does dipp have to check
the package of the symbol?

kt

--
Cells: http://common-lisp.net/project/cells/

"I'll say I'm losing my grip, and it feels terrific."
    -- Smiling husband to scowling wife, New Yorker cartoon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Bradshaw  
View profile  
 More options Nov 23 2006, 6:44 am
Newsgroups: comp.lang.lisp
From: Tim Bradshaw <t...@tfeb.org>
Date: Thu, 23 Nov 2006 11:44:56 +0000
Local: Thurs, Nov 23 2006 6:44 am
Subject: Re: obtaining a package's functions
On 2006-11-23 07:15:43 +0000, Pascal Bourguignon <p...@informatimago.com> said:

> Well implementations may export from COMMON-LISP symbols that are
> actually defined somewhere else and imported into COMMON-LISP...

However the test for the symbol-package of the symbol being the package
you're looking at tells you just that.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 9:01 am
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 23 Nov 2006 06:01:16 -0800
Local: Thurs, Nov 23 2006 9:01 am
Subject: Re: obtaining a package's functions

Alex Mizrahi wrote:
> (message (Hello 'Graham)
> (you :wrote  :on '(22 Nov 2006 21:30:51 -0800))
> (

>  GF> (defun symbol-function-p (sym)
>  GF>   "Is there a function associated with this symbol?"
>  GF>   (handler-case (symbol-function sym)
>  GF>     (undefined-function () nil)))

> why not just fboubdp [sic]?

Ignorance of its existence. ;-) Thank you.

Graham


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 9:20 am
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 23 Nov 2006 06:20:47 -0800
Local: Thurs, Nov 23 2006 9:20 am
Subject: Re: obtaining a package's functions

Ken Tilton wrote:
> Graham Fawcett wrote:
> > (defun symbol-function-p (sym)
> >   "Is there a function associated with this symbol?"
> >   (handler-case (symbol-function sym)
> >     (undefined-function () nil)))

> fboundp?

Thanks. I knew I must be reinventing something, just didn't know what.
;-)

> > (defun defun-in-package-p (s p)
> >   "Is this symbol interned in this package, and is there a
> >   function asssociated with it?"
> >   (and (symbol-function-p s)
> >        (eq p (symbol-package s))))

> I would expect something named defun-xxxx to be a variant on defun. One
> is not looking for defuns in a package, one is looking for functions.
> One does not call a defun, once calls a function. etc etc.

Good point.

> > (defun functions-in-package (pkg)
> >   "Return a list of functions defined in the package PKG."
> >   (loop for s being the symbols in pkg
> >      when (defun-in-package-p s pkg)

> fboundp?
> You already know s is a symbol in pkg, so why does dipp have to check
> the package of the symbol?

The OP wanted functions that were defined in-package, not imported into
it. Actually, I expected the "being the symbols" clause not to include
imported symbols, but it appears to; at least for me, over here in
SBCL. Check out SB-ALIEN, for example:

CL-USER> (loop with set = '()
               for s being the symbols in (find-package :SB-ALIEN)
               and p = (symbol-package s)
               do (pushnew (package-name p) set)
               finally (return set))
("SB-EXT" "SB-INT" "SB-ALIEN-INTERNALS" "SB-SYS" "SB-ALIEN"
"COMMON-LISP")

--g


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 9:40 am
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 23 Nov 2006 06:40:55 -0800
Local: Thurs, Nov 23 2006 9:40 am
Subject: Re: obtaining a package's functions

Pascal Bourguignon wrote:
> "Graham Fawcett" <graham.fawc...@gmail.com> writes:
> > (defun symbol-function-p (sym)
> >   "Is there a function associated with this symbol?" ...)
> Macros also have a symbol-function.

I didn't know that. Thanks.

> So, to get the list of the functions that are _exported_ from a package:

> (defun package-functions (package)
>   (remove-if-not (lambda (x) (and (fboundp x) (not (macro-function x))))
>                  (com.informatimago.common-lisp.package:package-exports package)))

LOOP has a "being the external-symbols" clause; I think this would do
the same thing, right?

(flet ((test (x) (and (fboundp x)
                      (not (macro-function x)))))
  (loop for s being the external-symbols in (find-package :common-lisp)
        when (test s) count s))
--> 661

You got 660; I wonder what my 661st function is...

--g


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pascal Bourguignon  
View profile  
 More options Nov 23 2006, 11:36 am
Newsgroups: comp.lang.lisp
From: Pascal Bourguignon <p...@informatimago.com>
Date: Thu, 23 Nov 2006 17:36:13 +0100
Local: Thurs, Nov 23 2006 11:36 am
Subject: Re: obtaining a package's functions

Using:

(FLET ((TEST (X)
         (AND (FBOUNDP X) (NOT (MACRO-FUNCTION X)))))
  (LOOP FOR S BEING THE EXTERNAL-SYMBOLS IN (FIND-PACKAGE :COMMON-LISP) WHEN
        (TEST S) COLLECT S))

in these implementations:

CLISP 2.41 (2006-10-13) (built 3372383352) (memory 3372383930)
SBCL 0.9.18
CMU Common Lisp 19c (19C)
GNU Common Lisp (GCL) GCL 2.6.7
ECL 0.9g
International Allegro CL Free Express Edition 8.0 [Linux (x86)] (Jun 6, 2006 16:01)

(sorry to use some oldish versions of some of these lisp implemenations),
to collect the symbols that are external in CL and bound to a function
but not a macro, we get:

(loop :for a :in '(clisp sbcl cmucl gcl ecl acl)
      :do (loop  :for b :in '(clisp sbcl cmucl gcl ecl acl)
                 :initially (format t "~%|~A| = ~A~%" a (length (symbol-value a)))
                 :do (when (set-difference (symbol-value a) (symbol-value b))
                        (format t "~%"))
                     (com.informatimago.common-lisp.interactive::flow-list
                      (format nil "~A - ~A = " a b)
                       (set-difference (symbol-value a) (symbol-value b)))))

|CLISP| = 660

   CLISP - GCL =  ARITHMETIC-ERROR-OPERANDS BROADCAST-STREAM-STREAMS
                  CELL-ERROR-NAME COMPILER-MACRO-FUNCTION
                  CONCATENATED-STREAM-STREAMS COPY-PPRINT-DISPATCH
                  DESCRIBE-OBJECT ECHO-STREAM-INPUT-STREAM
                  ECHO-STREAM-OUTPUT-STREAM ENSURE-DIRECTORIES-EXIST
                  FDEFINITION FILE-STRING-LENGTH FIND-METHOD
                  FUNCTION-LAMBDA-EXPRESSION GET-SETF-EXPANSION
                  HASH-TABLE-REHASH-SIZE HASH-TABLE-REHASH-THRESHOLD
                  INTERACTIVE-STREAM-P
                  LOAD-LOGICAL-PATHNAME-TRANSLATIONS LOGICAL-PATHNAME
                  LOGICAL-PATHNAME-TRANSLATIONS MAKE-LOAD-FORM
                  MAKE-LOAD-FORM-SAVING-SLOTS NO-NEXT-METHOD
                  OPEN-STREAM-P PATHNAME-MATCH-P PPRINT-DISPATCH
                  PPRINT-FILL PPRINT-INDENT PPRINT-LINEAR
                  PPRINT-NEWLINE PPRINT-TAB PPRINT-TABULAR
                  PRINT-NOT-READABLE-OBJECT READ-SEQUENCE
                  READTABLE-CASE SET-PPRINT-DISPATCH
                  SIMPLE-CONDITION-FORMAT-CONTROL
                  STREAM-EXTERNAL-FORMAT SYMBOL-MACROLET
                  SYNONYM-STREAM-SYMBOL TRANSLATE-LOGICAL-PATHNAME
                  TRANSLATE-PATHNAME TWO-WAY-STREAM-INPUT-STREAM
                  TWO-WAY-STREAM-OUTPUT-STREAM UNBOUND-SLOT-INSTANCE
                  UPGRADED-COMPLEX-PART-TYPE WILD-PATHNAME-P
                  WRITE-SEQUENCE

   CLISP - ECL =  LOAD-TIME-VALUE THE

|SBCL| = 661

   SBCL - CLISP =  LOCALLY

   SBCL - GCL =   ARITHMETIC-ERROR-OPERANDS BROADCAST-STREAM-STREAMS
                  CELL-ERROR-NAME COMPILER-MACRO-FUNCTION
                  CONCATENATED-STREAM-STREAMS COPY-PPRINT-DISPATCH
                  DESCRIBE-OBJECT ECHO-STREAM-INPUT-STREAM
                  ECHO-STREAM-OUTPUT-STREAM ENSURE-DIRECTORIES-EXIST
                  FDEFINITION FILE-STRING-LENGTH FIND-METHOD
                  FUNCTION-LAMBDA-EXPRESSION GET-SETF-EXPANSION
                  HASH-TABLE-REHASH-SIZE HASH-TABLE-REHASH-THRESHOLD
                  INTERACTIVE-STREAM-P
                  LOAD-LOGICAL-PATHNAME-TRANSLATIONS LOCALLY
                  LOGICAL-PATHNAME LOGICAL-PATHNAME-TRANSLATIONS
                  MAKE-LOAD-FORM MAKE-LOAD-FORM-SAVING-SLOTS
                  NO-NEXT-METHOD OPEN-STREAM-P PATHNAME-MATCH-P
                  PPRINT-DISPATCH PPRINT-FILL PPRINT-INDENT
                  PPRINT-LINEAR PPRINT-NEWLINE PPRINT-TAB
                  PPRINT-TABULAR PRINT-NOT-READABLE-OBJECT
                  READ-SEQUENCE READTABLE-CASE SET-PPRINT-DISPATCH
                  SIMPLE-CONDITION-FORMAT-CONTROL
                  STREAM-EXTERNAL-FORMAT SYMBOL-MACROLET
                  SYNONYM-STREAM-SYMBOL TRANSLATE-LOGICAL-PATHNAME
                  TRANSLATE-PATHNAME TWO-WAY-STREAM-INPUT-STREAM
                  TWO-WAY-STREAM-OUTPUT-STREAM UNBOUND-SLOT-INSTANCE
                  UPGRADED-COMPLEX-PART-TYPE WILD-PATHNAME-P
                  WRITE-SEQUENCE

   SBCL - ECL =   LOAD-TIME-VALUE THE

|CMUCL| = 661

   CMUCL - CLISP =  LOCALLY

   CMUCL - GCL =  ARITHMETIC-ERROR-OPERANDS BROADCAST-STREAM-STREAMS
                  CELL-ERROR-NAME COMPILER-MACRO-FUNCTION
                  CONCATENATED-STREAM-STREAMS COPY-PPRINT-DISPATCH
                  DESCRIBE-OBJECT ECHO-STREAM-INPUT-STREAM
                  ECHO-STREAM-OUTPUT-STREAM ENSURE-DIRECTORIES-EXIST
                  FDEFINITION FILE-STRING-LENGTH FIND-METHOD
                  FUNCTION-LAMBDA-EXPRESSION GET-SETF-EXPANSION
                  HASH-TABLE-REHASH-SIZE HASH-TABLE-REHASH-THRESHOLD
                  INTERACTIVE-STREAM-P
                  LOAD-LOGICAL-PATHNAME-TRANSLATIONS LOCALLY
                  LOGICAL-PATHNAME LOGICAL-PATHNAME-TRANSLATIONS
                  MAKE-LOAD-FORM MAKE-LOAD-FORM-SAVING-SLOTS
                  NO-NEXT-METHOD OPEN-STREAM-P PATHNAME-MATCH-P
                  PPRINT-DISPATCH PPRINT-FILL PPRINT-INDENT
                  PPRINT-LINEAR PPRINT-NEWLINE PPRINT-TAB
                  PPRINT-TABULAR PRINT-NOT-READABLE-OBJECT
                  READ-SEQUENCE READTABLE-CASE SET-PPRINT-DISPATCH
                  SIMPLE-CONDITION-FORMAT-CONTROL
                  STREAM-EXTERNAL-FORMAT SYMBOL-MACROLET
                  SYNONYM-STREAM-SYMBOL TRANSLATE-LOGICAL-PATHNAME
                  TRANSLATE-PATHNAME TWO-WAY-STREAM-INPUT-STREAM
                  TWO-WAY-STREAM-OUTPUT-STREAM UNBOUND-SLOT-INSTANCE
                  UPGRADED-COMPLEX-PART-TYPE WILD-PATHNAME-P
                  WRITE-SEQUENCE

   CMUCL - ECL =  LOAD-TIME-VALUE THE

|GCL| = 695

   GCL - CLISP =  ACCESSOR-METHOD-SLOT-DEFINITION ADD-DEPENDENT
                  ADD-DIRECT-METHOD ADD-DIRECT-SUBCLASS APPLYHOOK
                  CHAR-BIT CHAR-BITS CHAR-FONT CLASS-DEFAULT-INITARGS
                  CLASS-DIRECT-DEFAULT-INITARGS CLASS-DIRECT-SLOTS
                  CLASS-DIRECT-SUBCLASSES CLASS-DIRECT-SUPERCLASSES
                  CLASS-FINALIZED-P CLASS-PRECEDENCE-LIST
                  CLASS-PROTOTYPE CLASS-SLOTS COMMONP COMPILER-LET
                  COMPUTE-APPLICABLE-METHODS-USING-CLASSES
                  COMPUTE-CLASS-PRECEDENCE-LIST
                  COMPUTE-DISCRIMINATING-FUNCTION
                  COMPUTE-EFFECTIVE-METHOD
                  COMPUTE-EFFECTIVE-SLOT-DEFINITION COMPUTE-SLOTS
                  DECLARE DIRECT-SLOT-DEFINITION-CLASS
                  EFFECTIVE-SLOT-DEFINITION-CLASS ENSURE-CLASS
                  ENSURE-CLASS-USING-CLASS
                  ENSURE-GENERIC-FUNCTION-USING-CLASS EVALHOOK
                  EXTRACT-LAMBDA-LIST EXTRACT-SPECIALIZER-NAMES
                  FINALIZE-INHERITANCE FIND-METHOD-COMBINATION
                  FUNCALLABLE-STANDARD-INSTANCE-ACCESS
                  GENERIC-FUNCTION-LAMBDA-LIST
                  GENERIC-FUNCTION-METHOD-CLASS
                  GENERIC-FUNCTION-METHOD-COMBINATION
                  GENERIC-FUNCTION-METHODS GENERIC-FUNCTION-NAME
                  GET-SETF-METHOD GET-SETF-METHOD-MULTIPLE-VALUE
                  IN-PACKAGE INT-CHAR INTERN-EQL-SPECIALIZER MAKE-CHAR
                  MAKE-METHOD-LAMBDA MAP-DEPENDENTS METHOD-FUNCTION
                  METHOD-GENERIC-FUNCTION METHOD-LAMBDA-LIST
                  METHOD-SPECIALIZERS READER-METHOD-CLASS
                  REMOVE-DEPENDENT REMOVE-DIRECT-METHOD
                  REMOVE-DIRECT-SUBCLASS RESET-SYS-PATHS SET-CHAR-BIT
                  SET-FUNCALLABLE-INSTANCE-FUNCTION
                  SIMPLE-CONDITION-FORMAT-STRING
                  SLOT-BOUNDP-USING-CLASS SLOT-DEFINITION-ALLOCATION
                  SLOT-DEFINITION-INITARGS SLOT-DEFINITION-INITFORM
                  SLOT-DEFINITION-INITFUNCTION SLOT-DEFINITION-LOCATION
                  SLOT-DEFINITION-NAME SLOT-DEFINITION-READERS
                  SLOT-DEFINITION-TYPE SLOT-DEFINITION-WRITERS
                  SLOT-MAKUNBOUND-USING-CLASS SLOT-VALUE-USING-CLASS
                  SPECIAL-FORM-P SPECIALIZER-DIRECT-METHODS
                  SPECIFIC-CORRECTABLE-ERROR SPECIFIC-ERROR
                  STANDARD-INSTANCE-ACCESS STRING-CHAR-P TYPE-ERROR
                  UPDATE-DEPENDENT VALIDATE-SUPERCLASS
                  WRITER-METHOD-CLASS

   GCL - SBCL =   ACCESSOR-METHOD-SLOT-DEFINITION ADD-DEPENDENT
                  ADD-DIRECT-METHOD ADD-DIRECT-SUBCLASS APPLYHOOK
                  CHAR-BIT CHAR-BITS CHAR-FONT CLASS-DEFAULT-INITARGS
                  CLASS-DIRECT-DEFAULT-INITARGS CLASS-DIRECT-SLOTS
                  CLASS-DIRECT-SUBCLASSES CLASS-DIRECT-SUPERCLASSES
                  CLASS-FINALIZED-P CLASS-PRECEDENCE-LIST
                  CLASS-PROTOTYPE CLASS-SLOTS COMMONP COMPILER-LET
                  COMPUTE-APPLICABLE-METHODS-USING-CLASSES
                  COMPUTE-CLASS-PRECEDENCE-LIST
                  COMPUTE-DISCRIMINATING-FUNCTION
...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 11:47 am
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 23 Nov 2006 08:47:14 -0800
Local: Thurs, Nov 23 2006 11:47 am
Subject: Re: obtaining a package's functions

Pascal Bourguignon wrote:
> "Graham Fawcett" <graham.fawc...@gmail.com> writes:
> > You got 660; I wonder what my 661st function is...

> Using: [snip] in these implementations: [snip] we get: [big-snip]

Must...resist...the...urge... to generate the Venn diagram... ;-)

--g


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Raffael Cavallaro  
View profile  
 More options Nov 23 2006, 12:19 pm
Newsgroups: comp.lang.lisp
From: Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Date: Thu, 23 Nov 2006 12:19:37 -0500
Local: Thurs, Nov 23 2006 12:19 pm
Subject: Re: obtaining a package's functions
On 2006-11-23 00:30:51 -0500, "Graham Fawcett" <graham.fawc...@gmail.com> said:

> here's a piecewise
> one

The same, all at one hackish go thanks to relentless use of loop keywords ;^)

(defun doc-pkg-fns (pkg)
  (loop with home-package = (find-package pkg)
        for sym being each symbol of home-package
        when (handler-case (symbol-function sym) (undefined-function () nil))
        when (eq (symbol-package sym) home-package)
        do (format t "~a~%~a~%~%" sym
                   (or (documentation sym 'function) ""))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Raffael Cavallaro  
View profile  
 More options Nov 23 2006, 12:21 pm
Newsgroups: comp.lang.lisp
From: Raffael Cavallaro <raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com>
Date: Thu, 23 Nov 2006 12:21:29 -0500
Local: Thurs, Nov 23 2006 12:21 pm
Subject: Re: obtaining a package's functions
On 2006-11-23 12:19:37 -0500, Raffael Cavallaro
<raffaelcavallaro@pas-d'espam-s'il-vous-plait-mac.com> said:

> The same, all at one hackish go thanks to relentless use of loop keywords ;^)

Or with fboundp - duh!

(defun doc-pkg-fns (pkg)
  (loop with home-package = (find-package pkg)
        for sym being each symbol of home-package
        when (fboundp sym)
        when (eq (symbol-package sym) home-package)
        do (format t "~a~%~a~%~%" sym
                   (or (documentation sym 'function) ""))))


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jakemiles  
View profile  
 More options Nov 23 2006, 5:03 pm
Newsgroups: comp.lang.lisp
From: "jakemiles" <jacob.mi...@gmail.com>
Date: 23 Nov 2006 14:03:06 -0800
Local: Thurs, Nov 23 2006 5:03 pm
Subject: Re: obtaining a package's functions
Thanks everyone for all the input.  This is what I came up with on my
own, though there are clearly more experienced lispers in the room.
This code works though, for any third parties interested.  It also
doesn't use loop, which I personally don't like because I find it
complicated.  I prefer plain old tail recursion.  I know I'm weird this
way.

(defun package-symbols (package &key (external t) (internal t)
(inherited nil))
  (mapcar #'car (package-symbol-access-pairs package
                                             :external external
                                             :internal internal
                                             :inherited inherited)))

(defun package-symbol-access-pairs (package &key (external t) (internal
t) (inherited nil))
  (remove-if-not (lambda (symbol-access-pair)
                   (let ((accessibility (cdr symbol-access-pair)))
                     (or (and external (eq accessibility :external))
                         (and internal (eq accessibility :internal))
                         (and inherited (eq accessibility :inherited)))))
  (all-package-symbol-access-pairs package)))

(defun all-package-symbol-access-pairs (package)
  (let ((all-symbols))
    (do-symbols (x package)
      (multiple-value-bind (symbol accessibility)
          (find-symbol (symbol-name x) package)
        (push (cons symbol accessibility) all-symbols)))
    all-symbols))

- Jake


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
jakemiles  
View profile  
 More options Nov 23 2006, 5:05 pm
Newsgroups: comp.lang.lisp
From: "jakemiles" <jacob.mi...@gmail.com>
Date: 23 Nov 2006 14:05:17 -0800
Local: Thurs, Nov 23 2006 5:05 pm
Subject: Re: obtaining a package's functions
Not that my code above uses tail recursion :)  I actually swiped and
modified the bottommost function from the GNU CL documentation.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Graham Fawcett  
View profile  
 More options Nov 23 2006, 7:12 pm
Newsgroups: comp.lang.lisp
From: "Graham Fawcett" <graham.fawc...@gmail.com>
Date: 23 Nov 2006 16:12:21 -0800
Local: Thurs, Nov 23 2006 7:12 pm
Subject: Re: obtaining a package's functions

jakemiles wrote:
> Thanks everyone for all the input.  This is what I came up with on my
> own, though there are clearly more experienced lispers in the room.
> This code works though, for any third parties interested.  It also
> doesn't use loop, which I personally don't like because I find it
> complicated.  I prefer plain old tail recursion.  I know I'm weird this
> way.

Erm, no it doesn't use tail recursion. It does use a functional style
of programming. MAPCAR and REMOVE-IF-NOT are both higher-order
functions --- functions that take other functions as arguments --- and
are usual suspects in a functional program. I think this is what you
mean. Tail recursion is something else entirely, and it's not present
in your code.

Whether you use LOOP or a functional approach is a matter of personal
taste, and I doubt that you would be considered "weird" in any Lisp
circles for preferring the latter. Stand tall and be functional! ;-)

--g


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »