Gauche Devlog

< Comparators | Better error reporting during loading/compiling >


Did you mean...?

Recently I improved REPL info feature (browsing document on REPL) in a few ways. If you use Emacs, it is more convenient to jump to info directly; however, having document available on REPL is sometimes handy, for example, when you start gosh on ssh prompt to do some quick chores.

To view online doc on REPL, use info function, or toplevel ,info command:

gosh> ,info assoc
 -- Function: assq obj list
 -- Function: assv obj list
 -- Function: assoc obj list :optional key=
     [R7RS][SRFI-1] Each element in LIST must be a pair.  These
     procedures search a pair whose car matches OBJ (in the sense of
     'eq?' for 'assq', 'eqv?' for 'assv', and 'equal?' for 'assoc') from
     left to right, and return the leftmost matched pair if any.  If no
     pair matches, these return '#f'.

     If the optional argument of 'ascoc' is given, it is called instead
     of 'equal?' to check the equivalence of OBJ and each key.

Here are the new features:

  • You can now search not only function and syntax names, but also module name and class names:
gosh> ,info data.imap
 -- Module: data.imap
     This module provides a immutable data structure with O(log n)
     access and update operations (here, update means to return a new
     structure with requested changes).  The current implementation is
     based on the functional red-black tree.

gosh> ,info <tree-map>
 -- Builtin Class: <tree-map>
     Tree map class.  Tree maps are a data structure that maps key
     objects to value objects.  It's like hash tables except tree maps
     uses balanced tree internally.  Insertion and lookup is O(log n).

     Unlike hashtables, a tree map keeps the order of the keys, so it is
     easy to traverse entries in the order of keys, to find
     minimum/maximum keys, or to find a key closest to the given value.

     The '<tree-map>' class inherits '<sequence>' and
  • If there are more than one entry with the same name, the system prompts you to choose:
gosh> ,info string-map
There are multiple entries for string-map:
 1. "R7RS base library"
 2. "SRFI-13 String mapping"
Select number, or q to cancel [1]: 
 -- Function: string-map proc str ...
 -- Function: string-for-each proc str ...
     [R7RS] These take different arguments from 'string-map' and
     'string-for-each' in SRFI-13 (*note SRFI-13 String mapping::), so
     provided only in 'scheme.base' module to avoid confusion.

  • If there are no entries for the given word, it suggests similar words if there's any:
gosh> ,info vectre
There is no entry for vectre.
Did you mean:

I hope these changes would make REPL more pleasant to use. BTW, is ,info intuitive enough? I'm also tempted to add alias ,doc, especially for clojure users.

Oh, by the way, when you're on Emacs, this little elisp code allows you to jump to info page with a few keystrokes on a word...

(defun gauche-info-index (topic)
   (list (read-string
          (concat "Gauche help topic : ")
  (switch-to-buffer-other-window (get-buffer-create "*info*"))
  (info "/usr/share/info/")
  (Info-index topic))

(define-key global-map "\C-xH" 'gauche-info-index)

Tags: info, repl

Post a comment