From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Arne Babenhauserheide Newsgroups: gmane.lisp.guile.user Subject: Re: get all available symbols in scheme Date: Mon, 13 Jun 2016 23:46:20 +0200 Message-ID: <8737oghidv.fsf@web.de> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1465854701 22672 80.91.229.3 (13 Jun 2016 21:51:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Jun 2016 21:51:41 +0000 (UTC) Cc: "guile-user@gnu.org" To: source liu Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jun 13 23:51:31 2016 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bCZla-0003f9-4h for guile-user@m.gmane.org; Mon, 13 Jun 2016 23:51:30 +0200 Original-Received: from localhost ([::1]:59577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCZlZ-0005ck-8v for guile-user@m.gmane.org; Mon, 13 Jun 2016 17:51:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCZgq-0001Jp-C0 for guile-user@gnu.org; Mon, 13 Jun 2016 17:46:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCZgl-0002Hp-9n for guile-user@gnu.org; Mon, 13 Jun 2016 17:46:36 -0400 Original-Received: from mout.web.de ([212.227.17.11]:65337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCZgk-0002HV-VR for guile-user@gnu.org; Mon, 13 Jun 2016 17:46:31 -0400 Original-Received: from fluss ([85.212.77.49]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MQvkQ-1azxRi07YM-00UMbR; Mon, 13 Jun 2016 23:46:28 +0200 User-agent: mu4e 0.9.16; emacs 24.5.1 In-reply-to: X-Provags-ID: V03:K0:OmfrKkeuBJj8SS284tffSGMMUeJC0N+u1KZ8rAk6GduH1cYk056 igxjeK1zO2EBAfgu5yB6Fwsvz3xEwO0I8pt2cw4MGi0BVdmdm4bGT8hjCMTRK6+K9w8q1Bz MX8S6pFoWgJ4jIDM503bmLbvY9G29iWFrNWC2kShazcT+2PZWrVWguVmK3VcJ8JH6YPdiko nunoH+RYBbgyWXo/S0Asg== X-UI-Out-Filterresults: notjunk:1;V01:K0:+6aYzkY04uo=:RcLUdIkuukQU2FNqIJAWlB r7MPb7k6PxlIrsQhfFzDKbNJTAA8qiYt5Sy3Yb8Q/5KYjHpOiRv25U1XVhT2ZYL6vftCsU2ac AMwQZrbngol8+B/HglAYwa+7iR5DYa4dg3RbE8A4bhcaHq09cUbBIyQjF8A2nxHam5n+6NKKo iB+ZIyQzWK4AJzMITrzHsmR2c627ZMONA8dpDNfyQNaDbjGPCY5p0tLLI8jxwAH3svjin9zuj JzHLsAGumjegMBJspfv6mxevIDisKAJi4pTA2QztEbJ1Nl7EG7UsIo7zTA7/9TBO33Uz2r/w6 C/YAlJaodcH84wduoalWFv1sSORqR4qcp78gsmPiun5woi1RkcqWfwZP6ywgux/QfzphpXdXe LbskE9o7PWaAcs485mNFSLdZr2FjGULbo4/RtVXzSBfBy/Dwi5bO61/idLEHmhlfXuGgbI1ip Lr+n2TyU1Ix/Y6a0Ym56ziXZB+SUll3vduFmO6L5B+geBsyp4uoW0duitXoAKh3AZJJYDPCs7 faWbwlhWJ4cyicQJqIqD0nz4v6BL9ePNNDNSsJ93ssw0MG+ics2dCHdPw+PfOvc0w4ye68x1O IDaMIrx38n6+JWuT6QXf6MCyGRYl4aH3IdlOaVFz2AjRwt56X/dEI1VSegaTxsUyWzi+tvX7w PEhPf8/hboDEFlWTHKGLvY7cuopcGLJIXFQ1EAVl5uLKDYce6i097ihqZ4GlPfDTq+zxmtJj7 JFsepyyEbbtPmAzayZ74EF6/gcfLi+jPX2NyzJbzKjPp01nj4uZx7gQkX8k= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.11 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:12634 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Welcome to Guile! source liu writes: > I wonder if there is some way to dump all available symbols in current > enviroment=EF=BC=88something like =E2=80=9Cdir=E2=80=9D in python=EF=BC= =89=EF=BC=8C i think it is very useful when > you are trying new modules > I have tried the guile reference guide as well as google=EF=BC=8Cbut cant= find any > clue It=E2=80=99s pretty hidden. The easiest way is activating readline and just hitting tab twice: echo "(use-modules (ice-9 readline))(activate-readline)" >> ~/.guile Essentially this: (module-map (=CE=BB (sym var) sym) (resolve-interface '(guile))) and ,use ; returns (guile-user) ,in (guile-user) ,use ; returns module listing ,in (guile) ,b ; returns the bindings ,in ... Essentially this: (map (=CE=BB (x) (cons (module-name x) (module-map (=CE=BB (sym var) sy= m) (resolve-interface (module-name x))))) (module-uses (resolve-module '(gu= ile-user)))) There actually isn=E2=80=99t a dir function, yet=E2=80=A6 (import (ice-9 optargs)) (import (oop goops)) (use-modules (texinfo reflection)) ; define basic dir (define* (dir #:key (all? #f)) (if all? (map (=CE=BB (x) (cons (module-name x) (module-map (=CE=BB (sym var) sym) (resolve-interfa= ce (module-name x))))) (module-uses (current-module))) (module-map (=CE=BB (sym var) sym) (current-module)))) ; add support for giving the module as argument (define-generic dir) (define-method (dir (all? )) (dir #:all? all?)) (define-method (dir (m )) (module-map (=CE=BB (sym var) sym) (resolve= -interface m))) ; add support for using modules directly (interfaces are also modules, so t= his catches both) (define-method (dir (m )) (module-map (=CE=BB (sym var) sym) (resol= ve-interface (module-name m)))) Now there is dir, but its output is a bit unwieldy for large modules=E2=80= =A6 You can use it this: (dir) ; all local bindings, excluding imported modules (dir #t) ; all available bindings, including imported modules (dir #:all? #t) ; same as above (dir '(ice-9 optargs)) ; all exported bindings from the (ice-9 optargs) mod= ule ; =3D> (let-optional* define* let-keywords let-keywords* define*-public def= macro* defmacro*-public let-optional lambda*) (dir (resolve-module '(ice-9 optargs)) ; all bindings in the module ; =3D> (let-optional* parse-lambda-case %module-public-interface let-keywor= ds let-keywords* define*-public defmacro* defmacro*-public *uninitialized* = let-optional vars&inits) I just added this to guile-basics: http://www.draketo.de/proj/guile-basics/= #sec-2-5 Best wishes, Arne =2D-=20 Unpolitisch sein hei=C3=9Ft politisch sein ohne es zu merken --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXXymyAAoJEBPvjUUkA8Pri0sQAMVrYkJwoIpLEVMi02PdxcDr bfaP4vLkSkfzRdsgYrQN3ELNI593At3csh4PLHwKS1xDEWmimRAZtPTzcXnp4KWE L91xOSEFmu0ldTElZHnl5kFB2bN0+HSAfYbZKsH9sCn6P3qGFH+zswvwPewBwgLf bVMFA+w76KmS/Umtl658Cz8liVQ5H6fIseZYox90F8AgwULfV3khJF+3SYzEgmh8 Sck76xAL+0W1KKHy/BumDOkBtKFTFrl6J0P8dpRgIP4sXr8VZDBm3FWMUN77l/Xm OSyiGm7P+kfuRkfLPeyq/PUOLTqGS8oi2HF6qH9PdxMHH5di82JEelh2c9t7FmsY VTplKktI5BeawgDPwXAaF3TtA6OW4SX+o0NKIRP15CeqtN9tVNKuXcpkZgSUMiLA wVeAyjz2xpOkZeWzU13o+D4v7E/2ZqAZA0aunz1bCdIQkr2iIfyZ4jvmsyhEZ+Nk acyRaxBbpaFh98ohURVdzAet/tr+oA5SBZJMjYg+yS5j4v2Xkzd68g4/rJi7eHTn 2GN3E9NXqHRtEXBfU2wrmemAOoOXCgYMXUR5xM0xNrei6P+sxu6akRl/2lKhcY6X 9IvEhUFPI2as+477f/zmfPEuasLDQC8R0ASQjU6w0MDgba5o17MxMfnBUK+xvc0f DnHron7BCBbyV6oFFa8D =TAwN -----END PGP SIGNATURE----- --=-=-=--