Re: Easiest way to set procedure-documentation?
I found an easy way to set documentation for closures and procedures. I wrote this to guile-user earlier but send it to guile-devel as well as it may be of interest. On Fri, Aug 9, 2013 at 8:06 PM, Roland Orre wrote: > > There is no simple way to set procedure-documentation in guile. > For some years I've done it in the module's scheme description like > (set-procedure-property! proc 'documentation "help text") > > > but this is quite hard to maintain, and what seems to be the standard way > (looking at libguile) SCM_DEFINE is too complicted and tedious. > I attach the code part as a file also, in case someone wants to use it. OK, I solved it like this, //I redefined the macros SCM_DEFINE and SCM_PROC //as SCM_DEFINED and SCM_PROCD #define SCM_DEFINED(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ SCM_SNARF_HERE(\ static const char s_ ## FNAME [] = PRIMNAME; \ SCM FNAME ARGLIST\ )\ SCM_SNARF_INIT(\ scm_procedure_documentation_x \ (scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR,\ (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME), \ scm_str2string(DOCSTRING))) //SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) #define SCM_PROCD(RANAME, STR, REQ, OPT, VAR, CFN,DOCSTRING)\ SCM_SNARF_HERE(static const char RANAME[]=STR) \ SCM_SNARF_INIT(scm_procedure_documentation_x\ (scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \ (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN), \ scm_str2string(DOCSTRING)); \ ) // added a procedure procedure-documentation! static SCM scm_documentation; SCM_PROCD(s_procedure_documentation, "procedure-documentation!", 1,0,0, scm_procedure_documentation_x, "(procedure-documentaton! proc {doc})\n" "Returns or sets the doc string associated with @code{proc}."); SCM scm_procedure_documentation_x(SCM proc, SCM doc) { SCM code,orig; SCM_ASSERT (scm_is_true (scm_procedure_p (proc)), proc, SCM_ARG1, s_procedure_documentation); switch (SCM_TYP7 (proc)) { case scm_tcs_closures: code = SCM_CLOSURE_BODY (proc); if (scm_is_null (SCM_CDR (code))) return SCM_BOOL_F; orig = SCM_CAR (code); if (scm_is_string (orig)) { if (scm_is_string (doc)) { SCM_SETCAR(code,doc); return doc; } return orig; } else return SCM_BOOL_F; break; default: if (scm_is_string (doc)) { scm_set_procedure_property_x(proc,scm_documentation,doc); return doc; } else return scm_procedure_property(proc,scm_documentation); break; } return SCM_BOOL_F; } //and to the init procedure // scm_documentation=scm_from_locale_symbol("documentation"); // #include "yourmodule.x" This results in the following definition in the .x file scm_procedure_documentation_x (scm_c_define_gsubr (s_procedure_documentation, 1, 0, 0, (SCM (*)()) scm_procedure_documentation_x), scm_str2string("(procedure-documentaton! proc {doc}\n" "Returns or sets the doc string associated with @code{proc}.")); ; and of course similar for SCM_DEFINED, but I've defined most of my procedures with SCM_PROC anyway as the documentation hadn't been easy to get working. I also consider SCM_PROCD the cleaner solution, as I do not need to do one #define #undef for every procedure, and I can clearly see what arguments the procdure takes. I intended to generalise it to a a similar object-documentation! later with support for doc on file/database etc, but now I can finally get all my old C-routines documented without having the info in different files (the module init file). //I redefined the macros SCM_DEFINE and SCM_PROC //as SCM_DEFINED and SCM_PROCD #define SCM_DEFINED(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ SCM_SNARF_HERE(\ static const char s_ ## FNAME [] = PRIMNAME; \ SCM FNAME ARGLIST\ )\ SCM_SNARF_INIT(\ scm_procedure_documentation_x \ (scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR, \ (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME), \ scm_str2string(DOCSTRING)); \ )\ //SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, DOCSTRING) #define SCM_PROCD(RANAME, STR, REQ, OPT, VAR, CFN,DOCSTRING) \ SCM_SNARF_HERE(static const char RANAME[]=STR) \ SCM_SNARF_INIT(scm_procedure_documentation_x \ (scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \ (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN), \ scm_str2string(DOCSTRING))) // added a procedure procedure-documentation! static SCM scm_documentation; SCM_PROCD(s_procedure_documentation, "procedure-documentation!", 1,0,0, scm_procedure_documentation_x, "(procedure-documentaton! proc {doc})\n" "Returns or sets the doc string associated with @code{proc}."); SCM scm_procedure_documentation_x(SCM proc, SCM doc) { SCM code,orig; SCM_ASSERT (scm_is_true (scm_procedure_p (proc)), proc, SCM_ARG
Re: Easiest way to set procedure-documentation?
Sorry, the declaration should be this of course SCM_PROCD(s_procedure_documentation, "procedure-documentation!", 1,1,0, scm_procedure_documentation_x, "(procedure-documentaton! proc {doc})\n" "Returns or sets the doc string associated with @code{proc}."); On Mon, Aug 12, 2013 at 12:21 PM, Roland Orre wrote: > I found an easy way to set documentation for closures and procedures. > I wrote this to guile-user earlier but send it to guile-devel as well > as it may be of interest. > > On Fri, Aug 9, 2013 at 8:06 PM, Roland Orre wrote: >> >> There is no simple way to set procedure-documentation in guile. >> For some years I've done it in the module's scheme description like >> (set-procedure-property! proc 'documentation "help text") >> >> >> but this is quite hard to maintain, and what seems to be the standard way >> (looking at libguile) SCM_DEFINE is too complicted and tedious. >> > I attach the code part as a file also, in case someone wants to use it. > > OK, I solved it like this, > > //I redefined the macros SCM_DEFINE and SCM_PROC > //as SCM_DEFINED and SCM_PROCD > #define SCM_DEFINED(FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) \ > SCM_SNARF_HERE(\ > static const char s_ ## FNAME [] = PRIMNAME; \ > SCM FNAME ARGLIST\ > )\ > SCM_SNARF_INIT(\ > scm_procedure_documentation_x \ > (scm_c_define_gsubr (s_ ## FNAME, REQ, OPT, VAR,\ > (SCM_FUNC_CAST_ARBITRARY_ARGS) FNAME), \ > scm_str2string(DOCSTRING))) > > //SCM_SNARF_DOCS(primitive, FNAME, PRIMNAME, ARGLIST, REQ, OPT, VAR, > DOCSTRING) > > #define SCM_PROCD(RANAME, STR, REQ, OPT, VAR, CFN,DOCSTRING)\ > SCM_SNARF_HERE(static const char RANAME[]=STR) \ > SCM_SNARF_INIT(scm_procedure_documentation_x\ > (scm_c_define_gsubr (RANAME, REQ, OPT, VAR, \ > (SCM_FUNC_CAST_ARBITRARY_ARGS) CFN), \ >scm_str2string(DOCSTRING)); \ > ) > > // added a procedure procedure-documentation! > static SCM scm_documentation; > SCM_PROCD(s_procedure_documentation, "procedure-documentation!", > 1,0,0, scm_procedure_documentation_x, > "(procedure-documentaton! proc {doc})\n" > "Returns or sets the doc string associated with @code{proc}."); > SCM scm_procedure_documentation_x(SCM proc, SCM doc) > { > SCM code,orig; > SCM_ASSERT (scm_is_true (scm_procedure_p (proc)), > proc, SCM_ARG1, s_procedure_documentation); > switch (SCM_TYP7 (proc)) > { > case scm_tcs_closures: > code = SCM_CLOSURE_BODY (proc); > if (scm_is_null (SCM_CDR (code))) > return SCM_BOOL_F; > orig = SCM_CAR (code); > if (scm_is_string (orig)) { > if (scm_is_string (doc)) { > SCM_SETCAR(code,doc); > return doc; > } > return orig; > } > else > return SCM_BOOL_F; > break; > default: > if (scm_is_string (doc)) { > scm_set_procedure_property_x(proc,scm_documentation,doc); > return doc; > } > else > return scm_procedure_property(proc,scm_documentation); > break; > } > return SCM_BOOL_F; > } > > //and to the init procedure > // scm_documentation=scm_from_locale_symbol("documentation"); > // #include "yourmodule.x" > > This results in the following definition in the .x file > scm_procedure_documentation_x (scm_c_define_gsubr > (s_procedure_documentation, 1, 0, 0, (SCM (*)()) > scm_procedure_documentation_x), > scm_str2string("(procedure-documentaton! proc {doc}\n" "Returns or > sets the doc string associated with @code{proc}.")); ; > > and of course similar for SCM_DEFINED, but I've defined most of my > procedures with SCM_PROC anyway as the documentation hadn't been > easy to get working. I also consider SCM_PROCD the cleaner > solution, as I do not need to do one #define #undef for every procedure, > and I can clearly see what arguments the procdure takes. > > I intended to generalise it to a a similar object-documentation! > later with support for doc on file/database etc, but now I can > finally get all my old C-routines documented without having the > info in different files (the module init file).
Re: Determining programatically whether the interpreter is Guile or Clisp or Emcs
() 白い熊 () Thu, 01 Aug 2013 16:42:31 +0400 So if anyone would have alternate ideas [...] If you are comfortable w/ starting from a Lisp (Emacs or CLISP) base, perhaps you can find fruitful the "recode" facility of CEDET: http://www.emacswiki.org/emacs/SemanticRecoder This addresses the (unavoidable, you will see) translation requirement, not the "distinguishing the fragility of superficial syntax similarity" part (avoidable, but nonetheless fun to experiment with :-D). Anyway, you can see what pains CEDET takes to grow text into a (com)pliant tree. -- Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) => nil pgp87U055nh3P.pgp Description: PGP signature
Re: Issue with compiling to scheme
() mark.d.wit...@gmail.com () Sat, 03 Aug 2013 13:12:48 -0400 I can't see a way to do that without wrapping the whole set of expressions in `begin', but that's what creates the problem I described above. I can hack a solution for now but if anyone knows a clean way to do it, that'd be much appreciated. Maybe the simplest way is to completely separate code generation from compilation. This also gives you an opportunity to do compilation in two places (of the code that generates the code, and of the generated code). So your Makefile would look like: gen: gen.scm $(COMPILE) -o $@ $(COMPILEFLAGS) $< chmod +x gen %.generated : %.xml ./gen -o $@ $(GENFLAGS) $< %.go : %.generated $(COMPILE) -o $@ $(COMPILEFLAGS) $< This presumes that $(COMPILE) can create an executable -- not merely "loadable" -- file. (I wouldn't know, personally; under Guile 2, i still keep ‘GUILE_AUTO_COMPILE=0’ in the environment.) Anyway, once you discover and settle on the cleanest methods, i invite you to write it up in Texinfo and add it to CMOD-PLAY: http://www.gnuvola.org/software/cmod-play/ I am very much looking forward to learning what you discover, and applying it to all the projects i maintain. (For example, Guile-SDL test/gfx.scm is a dog under Guile 2.x, blech.) Fingers crossed... -- Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) => nil pgpYvIIoVaMxH.pgp Description: PGP signature
is there any guile windows binary distribution available?
Hello Guilers, I like to install guile on windows. is there any "ready to use"™ binary available.? Thanks. -- ఎందరో మహానుభావులు అందరికి వందనములు. YYR
Guile-GDBM 1.1.0 available
release notes: Got tired of waiting for Debian, and installed GNU dbm 1.10 under /usr/local; naturally, Guile-GDBM must follow suit. thi README excerpt: Guile-GDBM is a Guile module that provides Scheme bindings to the GNU dbm library. It was originally written by Martin Grabmüller and is now released under the GNU General Public License (GPL) version 3. Guile-GDBM has been tested with Guile 1.4.x, 1.8.7, 2.0.9, and GNU dbm 1.8.3, 1.10. NEWS excerpt: - 1.1.0 | 2013-08-03 - bug-report address changed Please send bug reports to the address shown by running command: ./configure --help Mail sent to the previous address is likely to be misplaced. - support for GNU dbm 1.10 GNU dbm 1.9 (released 2011-08-12) added several "mode flags" and runtime options; GNU dbm 1.10 (released 2011-11-13) added the close-on-exec mode flag. These are now fully supported, if you build Guile-GDBM against one of those versions (see following NEWS entries for details). Building against GNU dbm 1.8.3 (released 2002 or thereabouts) is still supported, but of course functionality is degraded. There is no plan to remove this support in the Guile-GDBM 1.x series. - ‘gdbm-open’ MODE can include flags Previously, the MODE arg was a simple symbol. Now it can also be the form: ‘(MODE [FLAG...])’, where FLAG is from the set: sync nolock nommap cloexec Note that not all flags are valid with all GNU dbm versions. - ‘gdbm-setopt!’ handles more options In addition to ‘cachesize’ and ‘fastmode’, these options are now also handled: syncmode centfree coalesceblks mmap maxmapsize Note that not all options are valid with all GNU dbm versions. - new proc: ‘gdbm-getopt’ Although GNU dbm 1.9 and later provide read-access to the runtime options via the same C func underlying ‘gdbm-setopt!’, namely ‘gdbm_setopt’, we separate this functionality at the Scheme level to avoid horrible confusion (most options are both readable and writable, but there exist some that are write-only and some that are read-only). See manual. - tested against Guile 2.0.9 As usual, we lamely keep ‘GUILE_AUTO_COMPILE=0’ in the env. OTOH, testing is now full flow, i.e., from "sh autogen.sh" onward, to exercise tools portability, as well. - bootstrap tools upgraded - GNU Automake 1.13.4 - Guile-BAUX 20130731.0252.f6841da tarball, etc, in dir: http://www.gnuvola.org/software/guile-gdbm/ atom feed: http://www.gnuvola.org/NEWS.atom -- Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) => nil signature.asc Description: PGP signature