Update minimum versions of some compilers.
[clon.git] / doc / user.texi
blobe63629d2bbd387e75933509e9128f81ed877def6
1 \input texinfo
3 @c user.texi --- User manual
5 @c Copyright (C) 2010, 2011, 2012 Didier Verna.
7 @c Author:     Didier Verna <didier@lrde.epita.fr>
8 @c Maintainer: Didier Verna <didier@lrde.epita.fr>
10 @c This file is part of Clon.
12 @c Permission to use, copy, modify, and distribute this software for any
13 @c purpose with or without fee is hereby granted, provided that the above
14 @c copyright notice and this permission notice appear in all copies.
16 @c THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
17 @c WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
18 @c MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19 @c ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 @c WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
21 @c ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
22 @c OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25 @c Commentary:
27 @c Contents management by FCM version 0.1.
30 @c ====================================================================
31 @c Header
32 @c ====================================================================
33 @c %**start of header
34 @setfilename clon-user.info
35 @settitle The Clon User Manual
36 @afourpaper
37 @documentencoding ISO-8859-1
38 @c %**end of header
42 @c ====================================================================
43 @c Settings
44 @c ====================================================================
45 @set VERSION 1.0 beta 22 "Michael Brecker"
46 @set COPYRIGHT_DATE 2010, 2011, 2012
47 @setchapternewpage odd
48 @setcontentsaftertitlepage
49 @documentdescription
50 The Clon User Manual for version @value{VERSION}.
51 @end documentdescription
55 @c ====================================================================
56 @c New Commands
57 @c ====================================================================
59 @macro clon
60 @t{Clon}
61 @end macro
63 @macro cl
64 Common Lisp
65 @end macro
67 @macro tty
68 @t{tty}
69 @end macro
71 @macro etc
72 @i{etc.}
73 @end macro
75 @macro eg
76 @i{e.g.}
77 @end macro
79 @macro ie
80 @i{i.e.}
81 @end macro
83 @macro perse
84 @i{per-se}
85 @end macro
87 @macro cmdline
88 command-line
89 @end macro
91 @macro CmdLine
92 Command-Line
93 @end macro
95 @macro bioption{name}
96 @option{--clon-\name\}
97 @end macro
100 @c --------------------------------
101 @c Manuals cross-referencing macros
102 @c --------------------------------
103 @c The following 3 macros are here to circumvent the info filenames
104 @c changes, when referencing the end-user manual:
106 @macro pxenduserref{node}
107 @ifinfo
108 @pxref{\node\, , , clon-enduser, The Clon End-User Manual}
109 @end ifinfo
110 @ifnotinfo
111 @pxref{\node\, , , enduser, The Clon End-User Manual}
112 @end ifnotinfo
113 @end macro
115 @macro xenduserref{node}
116 @ifinfo
117 @xref{\node\, , , clon-enduser, The Clon End-User Manual}
118 @end ifinfo
119 @ifnotinfo
120 @xref{\node\, , , enduser, The Clon End-User Manual}
121 @end ifnotinfo
122 @end macro
124 @macro enduserref{node}
125 @ifinfo
126 @ref{\node\, , , clon-enduser, The Clon End-User Manual}
127 @end ifinfo
128 @ifnotinfo
129 @ref{\node\, , , enduser, The Clon End-User Manual}
130 @end ifnotinfo
131 @end macro
134 @c ---------------
135 @c Indexing macros
136 @c ---------------
138 @c Concept index
139 @c -------------
141 @c Built-in options
142 @macro bioindex{opt}
143 @cindex @t{--clon-\opt\}
144 @cindex Built-In Options, @t{--clon-\opt\}
145 @cindex Options, built-in, @t{--clon-\opt\}
146 @end macro
148 @c Common option properties
149 @macro copindex{prop}
150 @cindex Options, common properties, @t{\prop\}
151 @cindex Common Option Properties, @t{\prop\}
152 @end macro
154 @c Options
155 @c #### NOTE: not an alias because of argument syntax.
156 @macro oindex{name,class}
157 @cindex \name\ (@t{\class\})
158 @cindex Options, \name\ (@t{\class\})
159 @ocindex{\class\}
160 @end macro
162 @c Valued options
163 @macro voindex{name,class}
164 @cindex \name\ (@t{\class\})
165 @cindex Valued Options, \name\ (@t{\class\})
166 @cindex Options, valued, \name\ (@t{\class\})
167 @ocindex{\class\}
168 @end macro
170 @c Common valued option properties
171 @macro cvopindex{prop}
172 @cindex Valued Options, common properties, @t{\prop\}
173 @cindex Common Valued Option Properties, @t{\prop\}
174 @cindex Options, valued, common properties, @t{\prop\}
175 @end macro
177 @c Valued option properties
178 @macro vopindex{name,class,prop}
179 @cindex \name\ (@t{\class\}), properties, @t{\prop\}
180 @cindex Valued Options, \name\ (@t{\class\}), properties, @t{\prop\}
181 @cindex Options, valued, \name\ (@t{\class\}), properties, @t{\prop\}
182 @end macro
184 @c Configuration options
185 @macro coindex{name}
186 @vindex com.dvlsoft.clon.configuration
187 @cindex Configuration Option, @t{:\name\}
188 @cindex @t{:\name\}
189 @end macro
192 @c Functions index
193 @c ---------------
195 @c Function options
196 @macro foindex{func,opt}
197 @findex \func\@r{, options, }\opt\
198 @end macro
200 @c Function items
201 @macro fiindex{func,item}
202 @findex \func\@r{, items, }\item\
203 @end macro
205 @c Function keys
206 @macro fkindex{func,key}
207 @findex \func\@r{, keys, }\key\
208 @end macro
210 @c Function initargs
211 @macro fiaindex{func,arg}
212 @findex \func\@r{, initargs, }\arg\
213 @end macro
215 @c Generic functions sub-index
216 @macro gfsubindex{func}
217 @findex @r{Generic Functions, }\func\
218 @end macro
220 @c Generic functions
221 @macro gfindex{func}
222 @findex \func\
223 @gfsubindex{\func\}
224 @end macro
226 @c Generic function methods
227 @macro gfmindex{func,method}
228 @findex \func\@r{, methods, }\method\
229 @findex @r{Generic Functions, }\func\@r{, methods, }\method\
230 @end macro
232 @c #### FIXME: I need this because when using @defun, the function is
233 @c referenced directly but not under the Constructors sub-index. This
234 @c sucks because what I would like is the ability to define my own
235 @c @defXXX macros, which apparently I can't. Besides, doing this
236 @c produces 2 separate index entries, instead of only one with two pagerefs.
237 @c This problem stands for @gfsubindex (see above), @rfsubindex (see
238 @c below) and @ecsubindex (see below) as well.
239 @c Constructor functions sub-index
240 @macro cfsubindex{func}
241 @findex @r{Constructors, }\func\
242 @end macro
244 @c Constructor functions
245 @macro cfindex{func}
246 @findex \func\
247 @cfsubindex{\func\}
248 @end macro
250 @c Constructor function initargs
251 @macro cfiaindex{func,arg}
252 @fiaindex{\func\, \arg\}
253 @findex @r{Constructors, }\func\@r{, initargs, }\arg\
254 @end macro
256 @c Reader functions subindex
257 @macro rfsubindex{func}
258 @findex @r{Readers, }\func\
259 @end macro
261 @c Reader functions
262 @macro rfindex{func}
263 @findex \func\
264 @rfsubindex{\func\}
265 @end macro
268 @c Variables index
269 @c ---------------
271 @c Environment variables
272 @macro evindex{var}
273 @vindex \var\
274 @vindex @r{Environment, }\var\
275 @end macro
277 @c Built-in environment variables
278 @macro bievindex{var}
279 @evindex{CLON_\var\}
280 @end macro
283 @c Data Types index
284 @c ----------------
286 @c Classes
287 @macro clsindex{cls}
288 @tpindex \cls\
289 @tpindex @r{Classes, }\cls\
290 @end macro
292 @c Class slots
293 @macro clssindex{cls,slot}
294 @tpindex \cls\@r{, slots, }\slot\
295 @tpindex @r{Classes, }\cls\@r{, slots, }\slot\
296 @end macro
298 @c Class initargs
299 @macro clsiaindex{cls,arg}
300 @tpindex \cls\@r{, initargs, }\arg\
301 @tpindex @r{Classes, }\cls\@r{, initargs, }\arg\
302 @end macro
304 @c Option classes
305 @macro ocindex{cls}
306 @clsindex{\cls\}
307 @tpindex @r{Option Classes, }\cls\
308 @end macro
310 @c Error conditions subindex
311 @macro ecsubindex{cond}
312 @tpindex @r{Error Conditions, }\cond\
313 @end macro
315 @c Error conditions
316 @macro ecindex{cond}
317 @tpindex \cond\
318 @ecsubindex{\cond\}
319 @end macro
321 @c Error condition slots
322 @macro ecsindex{cond,slot}
323 @tpindex \cond\@r{, slots, }\slot\
324 @tpindex @r{Error Conditions, }\cond\@r{, slots, }\slot\
325 @end macro
327 @c Packages
328 @macro pkgindex{name}
329 @tpindex \name\
330 @tpindex @r{Packages, }\name\
331 @end macro
333 @c Systems
334 @macro sysindex{name}
335 @tpindex \name\
336 @tpindex @r{Systems, }\name\
337 @end macro
341 @c ====================================================================
342 @c Info Category and Directory
343 @c ====================================================================
344 @dircategory Common Lisp
345 @direntry
346 * Clon User: (clon-user).               The Clon User Manual.
347 @end direntry
351 @c ====================================================================
352 @c Copying
353 @c ====================================================================
354 @copying
355 @quotation
356 Copyright @copyright{} @value{COPYRIGHT_DATE} Didier Verna
358 Permission is granted to make and distribute verbatim copies of this
359 manual provided the copyright notice and this permission notice are
360 preserved on all copies.
362 @ignore
363 Permission is granted to process this file through TeX and print the
364 results, provided the printed document carries a copying permission
365 notice identical to this one except for the removal of this paragraph
366 (this paragraph not being relevant to the printed manual).
368 @end ignore
369 Permission is granted to copy and distribute modified versions of this
370 manual under the conditions for verbatim copying, provided also that the
371 section entitled ``Copying'' is included exactly as in the original.
373 Permission is granted to copy and distribute translations of this manual
374 into another language, under the above conditions for modified versions,
375 except that this permission notice may be translated as well.
376 @end quotation
377 @end copying
381 @c ====================================================================
382 @c Title Page
383 @c ====================================================================
384 @titlepage
385 @title The Clon User Manual
386 @subtitle The @CmdLine{} Options Nuker, Version @value{VERSION}
387 @vskip 2cm
388 @image{splash,16cm}
389 @author Didier Verna <@email{didier@@lrde.epita.fr}>
390 @page
391 @vskip 0pt plus 1filll
392 @insertcopying
394 @hfill Cover art by Alexis Angelidis.
395 @end titlepage
399 @c ====================================================================
400 @c Table of Contents
401 @c ====================================================================
402 @contents
406 @c ====================================================================
407 @c Master Menu
408 @c ====================================================================
409 @ifnottex
410 @node Top, Copying, (dir), (dir)
411 @top The Clon User Manual
413 This is the @clon{} User Manual for @clon{} version @value{VERSION}:
414 it explains how to use @clon{} in your application.
416 @menu
417 * Copying::                 The BSD license
418 * Introduction::            What Clon is all about
419 * Installation::            Library, documentation and sample code
420 * Quick Start::             For the brave and the impatient
421 * Using Clon::              Clonificating your application
422 * Extending Clon::          Creating your own option types
423 * Advanced Usage::          Things rarely needed
424 * Conclusion::              That's all folks
425 * Technical Notes::         Configuration, platforms and portability
426 * API Quick Reference::     The Complete protocols
427 * Indexes::                 Concept, Function and Variable
428 * Acknowledgments::         Hall of Pride
429 @end menu
431 @insertcopying
432 @end ifnottex
436 @c ====================================================================
437 @c Copying
438 @c ====================================================================
439 @node Copying, Introduction, Top, Top
440 @unnumbered Copying
442 @quotation
443 Permission to use, copy, modify, and distribute this software for any
444 purpose with or without fee is hereby granted, provided that the above
445 copyright notice and this permission notice appear in all copies.
447 THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
448 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
449 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
450 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
451 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
452 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
453 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
454 @end quotation
458 @c ====================================================================
459 @c Introduction
460 @c ====================================================================
461 @node Introduction, Installation, Copying, Top
462 @chapter Introduction
464 @clon{} is a library for managing @cmdline{} options in standalone @cl{}
465 applications. It provides a unified option syntax with both short and
466 long names, automatic completion of partial names and automatic
467 retrieval/conversion of option arguments from the @cmdline{}, associated
468 environment variables, fallback or default values. @clon{} comes with a
469 set of extensible option types (switches, paths, strings @etc{}).
470 @clon{} also provides automatic generation and formatting of help
471 strings, with support for highlighting on @tty{}'s through ISO/IEC 6429
472 SGR. This formatting is customizable through @emph{themes}.
474 Depending on the target audience, @clon{} stands for either ``The
475 @CmdLine{} Options Nuker'' or ``The @cl{} Options Nuker''. @clon{} also
476 has a recursive acronym: ``@clon{} Likes Options Nuking'', and a reverse
477 one: ``Never Omit to Link with @clon{}''. Other possible expansions of
478 the acronym are still being investigated.
480 This manual is for the @clon{} @emph{user}, that is, the developer of a
481 @cl{} application who wants to use @clon{} for @cmdline{} option
482 management@footnote{An application using @clon{} for its @cmdline{}
483 option management is said to be @emph{clonified}. It is also possible to
484 say @emph{clonfiscated}. However, we advise against using
485 @emph{clonistified}. The term @emph{clonificated} is also considered bad
486 style, and the use of @emph{clonificationated} is strictly prohibited.}.
487 As opposed to the user of the @emph{library}, the user of an
488 @emph{application} powered by @clon{} is called an @emph{end-user}.
489 @clon{} provides both a user manual (this one) and an end-user manual
490 (@pxenduserref{Top}). Everybody should read the end-user manual first.
492 @ref{Quick Start} provides a very short example in order to give an
493 overview of what's coming next. @ref{Using Clon} explains in detail how
494 to clonify your application, and @ref{Extending Clon} describe how to
495 extend @clon{} with your own option types.
499 @c ====================================================================
500 @c Installation
501 @c ====================================================================
502 @node Installation, Quick Start, Introduction, Top
503 @chapter Installation
504 @clon{} currently works on Unix (including MacOS X) and Windows (Cygwin
505 or MinGW) with SBCL (> 1.0.56), CMUCL (> 20b), CCL, ECL, CLISP, ABCL (>
506 1.1.0), Allegro (both standard and modern) and LispWorks. @clon{} is
507 provided as an ASDF 2 system, but has no mandatory dependency. CFFI may
508 optionally be used with CLISP, Allegro and LispWorks. @xref{Supported
509 Platforms}, for more information.
511 In order to install and load the bare Lisp library, unpack it somewhere
512 in the ASDF 2 source registry and type this at the REPL:
513 @verbatim
514 (asdf:load-system :com.dvlsoft.clon)
515 @end verbatim
516 If you are using SBCL, you may want to make sure that the @code{CC}
517 environment variable is set to your favorite C compiler in your init
518 file. Otherwise, @clon{} will run in restricted mode (@pxref{Technical
519 Notes}). For instance, put this in your @file{.sbclrc}:
520 @verbatim
521 (require :sb-posix)
522 (sb-posix:setenv "CC" "gcc" 1)
523 @end verbatim
525 In addition to the library itself, the Clon distribution offers
526 documentation in the form of 3 different manuals, some data files like
527 sample themes (@pxenduserref{Theme Creation}), and a couple of
528 demonstration programs. If you want to benefit from all those wonders,
529 some bits of manual installation are needed. After unpacking somewhere
530 in the ASDF 2 source registry, please perform the following steps, in
531 order.
533 @enumerate
534 @item
535 Edit @file{Makefile.cnf} to your specific needs.
537 @item
538 Type @command{make} to compile the documentation and the demo programs
539 (end-user manual, user manual and possibly reference manual). By
540 default, the documentation is built in info, PDF and HTML formats. If
541 you want other formats (DVI and PostScript are available), type
542 @command{make all-formats}. You can also type individually @command{make
543 dvi} and/or @command{make ps} in order to get the corresponding format.
545 @item
546 As documented in @file{Makefile.cnf}, the reference manual is only
547 generated if you have SBCL and the Declt library at hand (see
548 @uref{http://www.lrde.epita.fr/~didier/software/lisp/misc.php#declt}).
550 @item
551 Type @command{make install} to install both the documentation and the
552 data files. If you have compiled the documentation in DVI and PostScript
553 format, those will be installed as well. The same goes for the reference
554 manual. The demo programs are not installed anywhere.
555 @end enumerate
557 Type @command{make uninstall} to uninstall the library.
561 @c ====================================================================
562 @c Quick Start
563 @c ====================================================================
564 @node Quick Start, Using Clon, Installation, Top
565 @chapter Quick Start
566 In this chapter, we assume that you have properly installed @clon{}
567 (@pxref{Technical Notes}), and we build a very short program to get you
568 started. Let's call it @file{quickstart.lisp}.
570 @menu
571 * Full Source::         The complete source code
572 * Explanation::         Step-by-step code walking
573 @end menu
576 @c -----------
577 @c Full Source
578 @c -----------
579 @node Full Source, Explanation, Quick Start, Quick Start
580 @section Full Source
581 For cut'n paste convenience, the complete source code is given below.
582 For a slightly longer example, have a look at the demonstration program
583 called @file{simple} in the distribution.
585 @cartouche
586 @verbatim
587 (in-package :cl-user)
589 (require :asdf)
590 (asdf:load-system :com.dvlsoft.clon)
591 (use-package :com.dvlsoft.clon)
593 (defsynopsis (:postfix "FILES...")
594   (text :contents "A very short program.")
595   (group (:header "Immediate exit options:")
596     (flag :short-name "h" :long-name "help"
597       :description "Print this help and exit.")
598     (flag :short-name "v" :long-name "version"
599           :description "Print version number and exit.")))
601 (defun main ()
602   "Entry point for our standalone application."
603   (make-context)
604   (when (getopt :short-name "h")
605     (help)
606     (exit))
607   (do-cmdline-options (option name value source)
608     (print (list option name value source)))
609   (terpri)
610   (exit))
612 (dump "quickstart" main)
613 @end verbatim
614 @end cartouche
617 @c -----------
618 @c Explanation
619 @c -----------
620 @node Explanation, , Full Source, Quick Start
621 @section Explanation
622 Let's examine this program step-by-step now.
624 @pkgindex{com.dvlsoft.clon}@c
625 @sysindex{com.dvlsoft.clon}@c
626 First, we put ourselves in the @cl{} user package, and load @clon{} from
627 its ASDF system @samp{com.dvlsoft.clon}. Next, we use the @clon{}
628 package, also named @samp{com.dvlsoft.clon}.
630 @cartouche
631 @verbatim
632 (in-package :cl-user)
634 (require :asdf)
635 (asdf:load-system :com.dvlsoft.clon)
636 (use-package :com.dvlsoft.clon)
637 @end verbatim
638 @end cartouche
640 In fact, using the @clon{} package directly is done here for simplicity,
641 but is not recommended. In case you find the package name too long to
642 prefix every symbol with, @clon{} provides a utility function that
643 allows you to add (and use) a shorter nickname instead (the
644 demonstration programs in the distribution show how to use it):
646 @cindex Package, nicknames
647 @defun nickname-package &optional NICKNAME
648 Add NICKNAME (:CLON by default) to the :COM.DVLSOFT.CLON package.
649 @end defun
651 @cindex Synopsis
652 @findex defsynopsis
653 @cindex Postfix
654 @cindex Text, in synopsis
655 @cindex Options, in synopsis
656 @cindex Groups, in synopsis
657 @cindex Help String
658 The next thing you want to do is to create a set of options, groups or
659 texts that your application will recognize and/or display in its help
660 string. The structure of your @cmdline{} is known to @clon{} as the
661 @dfn{synopsis}. In order to create it, use the macro @code{defsynopsis}.
663 @foindex{defsynopsis,:postfix}
664 @fiindex{defsynopsis,text}
665 @fiindex{defsynopsis,options}
666 @fiindex{defsynopsis,group}
667 @cartouche
668 @verbatim
669 (defsynopsis (:postfix "FILES...")
670   (text :contents "A very short program.")
671   (group (:header "Immediate exit options:")
672     (flag :short-name "h" :long-name "help"
673       :description "Print this help and exit.")
674     (flag :short-name "v" :long-name "version"
675           :description "Print version number and exit.")))
676 @end verbatim
677 @end cartouche
679 Note that the synopsis has a double role: it not only serves to define
680 the options recognized by your application, but also the order in which
681 every element appears in the help string. In that particular example, we
682 define a line of text and a group with a header and two flags.
684 @cindex Context
685 @cfindex{make-context}
686 Now, we are going to define a function @code{main} for our standalone
687 application. The first thing that we need to do is create a
688 @dfn{context}. A context is an object that @clon{} uses to store various
689 things, including some state related to the parsing of the @cmdline{}.
690 You create a context with the function @code{make-context}.
692 @cartouche
693 @verbatim
694 (defun main ()
695   "Entry point for our standalone application."
696   (make-context)
697 @end verbatim
698 @end cartouche
700 @cindex Options Retrieval, explicit
701 @cindex Retrieval, of options, explicit
702 @findex getopt
703 @cindex Help String, display
704 @findex help
705 At that point, @clon{} is ready to retrieve the options you want from
706 the @cmdline{}. Let's first see if the user has called the option
707 @option{-h}, and give him the help string. Option retrieval is done with
708 the function @code{getopt}, and automatic help string output with the
709 function @code{help}. Note that what we do here is @emph{not} process
710 the @cmdline{} in sequence, but look directly for a specific option by
711 name (this retrieval method is said to be @dfn{explicit}).
713 @fkindex{getopt,:short-name}
714 @cartouche
715 @verbatim
716   (when (getopt :short-name "h")
717     (help)
718     (exit))
719 @end verbatim
720 @end cartouche
722 @findex exit
723 The @code{exit} function is a wrapper around an
724 implementation-dependent way to exit (shall I say quit?) the @cl{}
725 environment, hence the program. It takes an optional argument that
726 stands for the exit status.
728 @cindex Options Retrieval, sequential
729 @cindex Retrieval, of options, sequential
730 @findex do-cmdline-options
731 And now, we are going to retrieve the other options and simply print
732 them. This time however, we process the @cmdline{} sequentially (so this
733 retrieval method is said to be @dfn{sequential}). This is done with the
734 @code{do-cmdline-options} macro. We also close the @code{main} function.
736 @cartouche
737 @verbatim
738   (do-cmdline-options (option name value source)
739     (print (list option name value source)))
740   (terpri)
741   (exit))
742 @end verbatim
743 @end cartouche
745 Finally, time to save the Lisp image.
747 @cindex Dumping
748 @findex dump
749 @cartouche
750 @verbatim
751 (dump "quickstart" main)
752 @end verbatim
753 @end cartouche
755 The first argument to @code{dump} is the name of the executable to
756 produce, and the second argument is the name of the function to call
757 automatically at startup.
759 In order to get a standalone executable from this program, all you need
760 to do now is to type @samp{CC=gcc sbcl --script quickstart.lisp}. Note
761 that the actual way of dumping executables is compiler-dependent. For
762 more information on the proper way to do it and on the compilers
763 currently supported, see @ref{Dumping Executables}.
765 Note also that it is possible to use @clon{} without actually dumping a
766 standalone executable (@pxref{Not Dumping Executables}).
770 @c ====================================================================
771 @c Using Clon
772 @c ====================================================================
773 @node Using Clon, Extending Clon, Quick Start, Top
774 @chapter Using Clon
776 Using @clon{} in your application is a two stages process. In phase 1,
777 you create a @dfn{synopsis}, which is a description of your
778 application's @cmdline{} and a @dfn{context}, which describes this
779 specific execution of the program. In phase 2, you retrieve the option
780 values and possibly display help strings. Phase 1 is called the
781 @dfn{initialization phase}, while phase 2 is called the @dfn{runtime
782 phase}.
784 @menu
785 * Synopsis Definition:: Describing your command-line
786 * Context Creation::    Instantiating your command-line
787 * Integrity Checks::    Verifying the Clon semantics
788 * Option Retrieval::    Getting the options values
789 * Help::                Generating the help string
790 @end menu
793 @c -------------------
794 @c Synopsis Definition
795 @c -------------------
796 @node Synopsis Definition, Context Creation, Using Clon, Using Clon
797 @section Synopsis Definition
799 @cindex Initialization Phase
800 @cindex Phase, initialization
801 @cindex Synopsis
802 @cindex Help String
803 Step one of the @clon{} initialization phase consists in defining a
804 @dfn{synopsis}. A synopsis is essentially a description of your
805 application's @cmdline{}: it describes what are the available options,
806 whether your application has a postfix @etc{} The synopsis, however,
807 plays a second role: it also describes the contents of your
808 application's help string. When you create a synopsis, you describe the
809 @cmdline{} and the help string at the same time.
811 @menu
812 * Synopsis Items::              Defsynopsis and its contents
813 * Built-In Option Types::       The exhaustive list
814 * Advanced Synopsis Creation::  The non-declarative way
815 @end menu
817 @node Synopsis Items, Built-In Option Types, Synopsis Definition, Synopsis Definition
818 @subsection Synopsis Items
819 Look again at the synopsis definition provided in @ref{Quick Start}.
821 @cartouche
822 @verbatim
823 (defsynopsis (:postfix "FILES...")
824   (text :contents "A very short program.")
825   (group (:header "Immediate exit options:")
826     (flag :short-name "h" :long-name "help"
827           :description "Print this help and exit.")
828     (flag :short-name "v" :long-name "version"
829           :description "Print version number and exit.")))
830 @end verbatim
831 @end cartouche
833 You define a synopsis with the @code{defsynopsis} macro.
835 @defmac defsynopsis ([OPTIONS@dots{}]) ITEMS@dots{}
836 Define a new synopsis and return it. @var{OPTIONS} are key/value pairs.
837 @var{ITEMS} are text, group or option descriptions.
839 The following @var{OPTIONS} are currently available.
840 @table @t
841 @item :postfix
842 @cindex Postfix
843 @foindex{defsynopsis,:postfix}@c
844 @cindex Command-Line, remainder
845 @cindex Remainder, of command-line
846 A string which will appear at the end of the synopsis line in the help
847 string. When you provide a postfix, you also implicitely tell @clon{}
848 that your application accepts non-option arguments at the end of the
849 @cmdline{} (this is called the @dfn{remainder} of the @cmdline{}). See
850 @enduserref{Option Separator} for more information on the behavior of
851 @clon{} with respect to postfixes. Also, see @ref{Command-Line
852 Remainder} on how to access the @cmdline{} remainder.
853 @end table
854 @end defmac
856 We now examine the syntax for each possible @var{ITEM}.
857 @menu
858 * Text::        Adding arbitrary text
859 * Options::     Adding options
860 * Groups::      Adding groups
861 @end menu
863 @node Text, Options, Synopsis Items, Synopsis Items
864 @subsubsection Text
865 @cindex Text
866 @cindex Text, in synopsis
867 @fiindex{defsynopsis,text}
868 In order to add arbitrary text to your help string, use the following
869 form:
871 @noindent
872 @t{(text} [@var{OPTIONS@dots{}}]@t{)}
874 @var{OPTIONS} are key/value pairs. The following @var{OPTIONS} are
875 currently available.
876 @table @t
877 @item :contents
878 @cindex Text, contents
879 The actual text string. Try to make proper sentences when adding
880 arbitrary text. You can use explicit newline characters in your text if
881 you really want to go next line, but in general, you should not worry
882 about the formatting because the themes are here to do so. In
883 particular, don't finish your text with a newline. This would break
884 potential theme specifications.
885 @item :hidden
886 @cindex Hidden Text
887 @cindex Text, hidden
888 @cindex Help String
889 When non-@code{nil}, the text won't appear in the help string. Hidden
890 texts can still be displayed individually though (@pxref{Help}).
891 @end table
893 @node Options, Groups, Text, Synopsis Items
894 @subsubsection Options
895 @cindex Options
896 @cindex Options, in synopsis
897 @fiindex{defsynopsis,options}
898 In order to add an option to your help string, you must provide a list
899 beginning with the option type and followed by key/value pairs
900 describing the option's properties. For instance, to add a flag with a
901 short name and a description, you could do this:
903 @verbatim
904 (flag :short-name "h" :description "Print this help and exit.")
905 @end verbatim
907 Option properties vary depending on the option type. The exact list of
908 available option types, and the corresponding properties are described
909 in @ref{Built-In Option Types}.
911 @node Groups, , Options, Synopsis Items
912 @subsubsection Groups
913 @cindex Groups
914 @cindex Groups, in synopsis
915 @fiindex{defsynopsis,group}
916 In order to add a group to your help string, use the following form:
918 @noindent
919 @t{(group} ([@var{OPTIONS@dots{}}]) @var{ITEMS@dots{}}@t{)}
921 @cindex Text, in groups
922 @cindex Options, in groups
923 @cindex Groups, in groups
924 @var{OPTIONS} are key/value pairs. @var{ITEMS} simply are arbitrary
925 text, option or sub-group descriptions as we've just seen.
927 The following @var{OPTIONS} are currently available.
928 @table @t
929 @item :header
930 @cindex Group Header
931 @cindex Header, in group
932 @foindex{defgroup,:header}@c
933 A string which will be displayed above the group's contents in the help
934 string. The same formatting recommendations as for arbitrary text apply
935 (@pxref{Text}).
936 @item :hidden
937 @cindex Hidden Groups
938 @cindex Groups, hidden
939 @foindex{defgroup,:hidden}@c
940 @cindex Help String
941 @cindex Built-In Groups
942 @cindex Groups, built-in
943 @bioindex{help}
944 When non-@code{nil}, the group won't appear in the help string. Hidden
945 groups can still be displayed individually though (@pxref{Help}). For
946 instance, the @clon{} built-in group is hidden in the regular help
947 string, but the @bioption{help} option still displays it individually.
948 @end table
950 @node Built-In Option Types, Advanced Synopsis Creation, Synopsis Items, Synopsis Definition
951 @subsection Built-In Option Types
952 @cindex Built-In Option Types
953 @cindex Options, built-in types
954 @cindex Option Types, built-in
955 In this section, we will review all the built-in option types that
956 @clon{} provides, along with their corresponding properties. You can use
957 them directly in your synopsis description. For adding personal option
958 types to @clon{}, see @ref{New Option Types}.
960 @menu
961 * Common Properties::                   For all options
962 * Flags::                               Built-in options without arguments
963 * Common Valued Option Properties::     For all valued options
964 * Built-In Valued Options::             Built-in options with arguments
965 @end menu
967 @node Common Properties, Flags, Built-In Option Types, Built-In Option Types
968 @subsubsection Common Properties
969 @cindex Options, common properties
970 @cindex Common Option Properties
971 @clsindex{option}
972 All option types in @clon{}, including those you define yourself
973 (@pxref{New Option Types}), have a set of basic, common properties. Here
974 is a list of them.
976 @table @code
977 @item :short-name
978 @copindex{:short-name}
979 The option's short name. A string or @code{nil}.
980 @item :long-name
981 @copindex{:long-name}
982 The option's long name. A string or @code{nil}.
983 @item :description
984 @copindex{:description}
985 The option's descriptive text. A string or @code{nil}. The same
986 formatting recommendations as for arbitrary text apply (@pxref{Text}).
987 @item :env-var
988 @copindex{:env-var}
989 The option's associated environment variable. A string or @code{nil}.
990 @item :hidden
991 @copindex{:hidden}
992 @cindex Hidden Options
993 @cindex Options, hidden
994 @cindex Help String
995 When non-@code{nil}, the option won't appear in the help string. Hidden
996 options can still be displayed individually though (@pxref{Help}).
997 @end table
999 Note that an option is required to have at least one name (either short
1000 or long). Non-@code{nil} but empty names are also prohibited, and of
1001 course, a short name cannot begin with a dash (otherwise, it would be
1002 mistaken for a long name, but did I really need to mention this?).
1004 @node Flags, Common Valued Option Properties, Common Properties, Built-In Option Types
1005 @subsubsection Flags
1006 @oindex{Flags,flag}
1007 In @clon{}, options that don't take any argument are of type
1008 @code{flag}. These options don't provide additional properties on top of
1009 the common set described in @ref{Common Properties}. All properties
1010 default to @code{nil}.
1012 @node Common Valued Option Properties, Built-In Valued Options, Flags, Built-In Option Types
1013 @subsubsection Common Valued Option Properties
1014 @cindex Valued Options
1015 @cindex Options, valued
1016 @clsindex{valued-option}
1017 All non-flag options in @clon{} are said to be @dfn{valued}. All valued
1018 options, including those you define yourself (@pxref{New Option Types}),
1019 share a set of additional properties. Here is a list of them.
1021 @cindex Valued Options, common properties
1022 @cindex Common Valued Option Properties
1023 @cindex Options, valued, common properties
1024 @table @code
1025 @item :argument-name
1026 @cvopindex{:argument-name}
1027 The name of the option's argument, as it appears in the help string. It
1028 defaults to @code{"ARG"}, so that for instance, a @samp{name} option
1029 would appear like this: @samp{--name=ARG}.
1030 @item :argument-type
1031 @cvopindex{:argument-type}
1032 The status of the argument. Possible values are @code{:required} (the
1033 default) and @code{:mandatory} which are synonyms, or @code{:optional}.
1034 @item :fallback-value
1035 @cvopindex{:fallback-value}
1036 @cindex Values, source, fallback
1037 @item :default-value
1038 @cvopindex{:default-value}
1039 @cindex Values, source, default
1040 The option's fallback and default values. Remember that a fallback value
1041 only makes sense when the argument is optional. Besides, also when the
1042 argument is optional, you need to provide at least a fallback or a
1043 default value (or both of course; see @enduserref{Value Sources}).
1044 @end table
1046 @node Built-In Valued Options, , Common Valued Option Properties, Built-In Option Types
1047 @subsubsection Built-In Valued Options
1048 @cindex Option Types, valued
1049 @cindex Built-In Option Types, valued
1050 @cindex Options, built-in types, valued
1051 @cindex Option Types, built-in, valued
1052 @clon{} currently defines 6 built-in valued option types. These option
1053 types may change the default value for some common properties, and / or
1054 provide additional properties of their own. All of this is described
1055 below.
1057 @table @code
1058 @item stropt
1059 @voindex{Strings,stropt}@c
1060 @cvopindex{:argument-name}@c
1061 This option type is for options taking strings as their argument. String
1062 options don't provide any additional properties, but their default
1063 argument name is changed from @code{"ARG"} to @code{"STR"}.
1064 @item lispobj
1065 @voindex{Lisp Objects,lispobj}@c
1066 @cvopindex{:argument-name}@c
1067 @vopindex{Lisp Objects,lispobj,:typespec}@c
1068 @bioindex{line-width}@c
1069 This option type is for options taking any kind of Lisp object as their
1070 argument. @code{lispobj} options change their default argument name from
1071 @code{"ARG"} to @code{"OBJ"}. Also, they provide an additional property
1072 called @code{:typespec} which must be a @cl{} type specifier that the
1073 argument must satisfy. It defaults to @code{t}. Look at the
1074 @bioption{line-width} built-in option for an example.
1075 @item enum
1076 @voindex{Enumerations,enum}@c
1077 @cvopindex{:argument-name}@c
1078 @vopindex{Enumerations,enum,:enum}@c
1079 @bioindex{version}@c
1080 This option type is for options taking values from an enumerated set of
1081 keywords. @code{enum} options change their default argument name from
1082 @code{"ARG"} to @code{"TYPE"}. Also, they provide an additional property
1083 called @code{:enum} to store the list of @cl{} keywords enumerating the
1084 possible values. The end-user does not use a colon when providing an
1085 argument to an @code{enum} option. Only the keyword's name. The end-user
1086 also has the ability to abbreviate the possible values. An empty
1087 argument is considered as an abbreviation for the first element in the
1088 set. Look at the @bioption{version} built-in option for an example.
1089 @item path
1090 @bioindex{search-path}@c
1091 @bioindex{theme}@c
1092 @voindex{Paths,path}@c
1093 @cvopindex{:argument-name}@c
1094 @vopindex{Paths,path,:type}@c
1095 This option type is for options taking a colon-separated list of
1096 pathnames as argument. @code{path} options change their default argument
1097 name from @code{"ARG"} to @code{"PATH"}. Also, they provide an
1098 additional property called @code{:type} which specifies the kind of path
1099 which is expected. Possible values are: @code{:file}, @code{:directory},
1100 @code{:file-list}, @code{:directory-list} or @code{nil} (meaning that
1101 anything is allowed). Null paths are allowed, and may be provided by an
1102 empty argument. Look at the @bioption{search-path} and
1103 @bioption{theme} built-in options for examples.
1104 @item switch
1105 @voindex{Switches,switch}@c
1106 @cvopindex{:argument-name}@c
1107 @cvopindex{:argument-type}@c
1108 @vopindex{Switches,switch,:argument-style}@c
1109 This option type is for Boolean options. @code{switch} options change
1110 their default argument type from required to optional and provide a
1111 fallback value of @code{t} automatically for optional arguments.
1112 @code{switch} options provide a new property called
1113 @code{:argument-style}. Possible values are @code{:yes/no} (the
1114 default), @code{:on/off}, @code{:true/false}, @code{:yup/nope},
1115 @code{:yeah/nah}. This property affects the way the argument name and
1116 true or false values are advertized in help strings. However, all
1117 possible arguments forms (@pxenduserref{Switches}) are always available
1118 to all switches.
1119 @item xswitch
1120 @voindex{Extended Switches,xswitch}@c
1121 @cvopindex{:argument-name}@c
1122 @cvopindex{:argument-type}@c
1123 @vopindex{Extended Switches,xswitch,:argument-style}@c
1124 @vopindex{Extended Switches,xswitch,:enum}@c
1125 @bioindex{highlight}@c
1126 This option type stands for @dfn{extended} switch. Extended switches
1127 result from the mating of a male switch and a female enumeration, or the
1128 other way around (elementary decency prevents me from describing this
1129 mating process in detail): their possible values are either Boolean or
1130 from an @code{:enum} property as in the case of @code{enum} options. As
1131 simple switches, @code{xswitch} options change their default argument
1132 type from required to optional and provide a fallback value of @code{t}
1133 automatically for optional arguments. They also provide the
1134 @code{:argument-style} property. Contrary to switches, however, this
1135 property does not affect the argument name. It only affects the way true
1136 or false values are displayed in help strings. Look at the
1137 @bioption{highlight} built-in option for an example.
1138 @end table
1140 @node Advanced Synopsis Creation, , Built-In Option Types, Synopsis Definition
1141 @subsection Advanced Synopsis Creation
1142 @findex defsynopsis
1143 The fact that @code{defsynopsis} lets you define things in a
1144 @emph{declarative} way has not escaped you. Declarative is nice but
1145 sometimes it gets in the way, so it is time to see how things work under
1146 the hood. Every item in a synopsis is in fact implemented as an object
1147 (an instance of some class), so it turns out that @code{defsynopsis}
1148 simply is a convenience wrapper around the corresponding constructor
1149 functions for all such objects. Instead of using @code{defsynopsis}, you
1150 can then use those constructor functions explicitely.
1152 @menu
1153 * Constructors::        The expansion of defsynopsis
1154 * Advantages::          Yes, but why?
1155 * Group Definition::    The declarative way
1156 @end menu
1158 @node Constructors, Advantages, Advanced Synopsis Creation, Advanced Synopsis Creation
1159 @subsubsection Constructors
1160 Let's have a look at the expansion of @code{defsynopsis} from the quick
1161 start example (@pxref{Quick Start}).
1163 The original code is like this:
1165 @cartouche
1166 @verbatim
1167 (defsynopsis (:postfix "FILES...")
1168   (text :contents "A very short program.")
1169   (group (:header "Immediate exit options:")
1170     (flag :short-name "h" :long-name "help"
1171           :description "Print this help and exit.")
1172     (flag :short-name "v" :long-name "version"
1173           :description "Print version number and exit.")))
1174 @end verbatim
1175 @end cartouche
1177 And once the macro is expanded, it will look like this:
1179 @cfindex make-synopsis
1180 @cfindex make-text
1181 @cfindex make-group
1182 @cfindex make-flag
1183 @findex defsynopsis@r{, expansion}
1184 @cartouche
1185 @verbatim
1186 (make-synopsis :postfix "FILES..."
1187   :item (make-text :contents "A very short program.")
1188   :item (make-group :header "Immediate exit options:"
1189           :item (make-flag :short-name "h"
1190                            :long-name "help"
1191                            :description "Print this help and exit.")
1192           :item (make-flag :short-name "v"
1193                            :long-name "version"
1194                            :description "Print version number and exit.")))
1195 @end verbatim
1196 @end cartouche
1198 As you can see, every synopsis element has a corresponding
1199 @code{make-@var{SOMETHING}} constructor, and the keywords used here and
1200 there in @code{defsyopsis} are in fact initargs to those constructors.
1201 We now examine those constructors in greater detail.
1203 @cindex Options, creation
1204 @defun make-text [@code{:hidden} BOOL] @code{:contents} STRING
1205 @cfsubindex{make-text}
1206 @cfiaindex{make-text,:contents}
1207 @cfiaindex{make-text,:hidden}
1208 Create an arbitrary text object, possibly hidden, whose contents is
1209 @var{STRING}.
1210 @end defun
1212 @c #### FIXME: I would like an environment without indexing here.
1213 @defun make-@var{OPTION} :INITARG INITVAL@dots{}
1214 @cfsubindex{make-@var{OPTION}}
1215 @cfindex make-flag
1216 @cfindex make-stropt
1217 @cfindex make-lispobj
1218 @cfindex make-enum
1219 @cfindex make-path
1220 @cfindex make-switch
1221 @cfindex make-xswitch
1222 Create a new @var{OPTION} object, @var{OPTION} being any built-in option
1223 type (@code{flag}, @code{stropt} @etc{}, see @ref{Built-In Valued
1224 Options}) or user-defined one (@pxref{New Option Types}). For a list of
1225 available initialization arguments (depending on the option type), see
1226 @ref{Built-In Option Types}.
1227 @end defun
1229 @defun make-group [@code{:header} STRING @code{:hidden} BOOL] @
1230 @code{:item} ITEM1 @code{:item} ITEM2@dots{}
1231 @cfsubindex{make-group}
1232 @cfiaindex{make-group,:header}
1233 @cfiaindex{make-group,:hidden}
1234 @cfiaindex{make-group,:item}
1235 @cindex Help String
1236 Create a group object, possibly hidden, whose header is @var{STRING}.
1237 Every @var{ITEM} is an arbitrary text object, option object or group
1238 object. The order is important as it determines the display of the help
1239 string.
1240 @end defun
1242 @defun make-synopsis [@code{:postfix} STRING] @
1243 @code{:item} ITEM1 @code{:item} ITEM2@dots{}
1244 @cfsubindex{make-synopsis}
1245 @cfiaindex{make-synopsis,:postfix}
1246 @cfiaindex{make-synopsis,:item}
1247 @cindex Help String
1248 Create a synopsis object whose postfix is @var{STRING}. Every @var{ITEM} is
1249 an arbitrary text object, option object or group object. The order is
1250 important as it determines the display of the help string.
1251 @end defun
1253 In fact, the @code{defsynopsis} macro allows you to freely mix
1254 declarative forms, constructor calls or whatever Lisp code you may want
1255 to use. The way this works is as follows: if a synopsis @var{ITEM}
1256 (@pxref{Synopsis Items}) is a list whose @code{car} is @code{text},
1257 @code{group}, or any option type (inluding those you define yourselves;
1258 see @ref{New Option Types}), then the @var{ITEM} is expanded as
1259 explained earlier. Otherwise, it is just left @emph{as-is}.
1261 To sum up, here's a example of things you can do in @code{defsynopsis}.
1263 @cartouche
1264 @verbatim
1265 (com.dvlsoft.clon:defsynopsis ()
1266   (flag #| ... |#)
1267   *my-great-option*
1268   (setq *another-option* (com.dvlsoft.clon:make-switch #| ... |#)))
1269 @end verbatim
1270 @end cartouche
1273 @node Advantages, Group Definition, Constructors, Advanced Synopsis Creation
1274 @subsubsection Advantages
1275 @findex defsynopsis
1276 So, why would you want to use constructors directly or mix declarative
1277 and imperative forms in @code{defsynopsis}? There are several reasons
1278 for doing so.
1279 @enumerate
1280 @item
1281 Some people prefer to declare (or should I say, create) their arbitrary
1282 texts, options and groups locally, in files, modules or ASDF components
1283 where they belong. In such a case, you need to keep references to the
1284 corresponding objects in order to compute the synopsis in the end.
1285 @item
1286 Since using constructors explicitely allows you to keep references to
1287 the created objects, these objects can be @emph{reused}. For instance,
1288 you can use the same text at different places, you can also use a single
1289 option several times, or even a single group several times so that its
1290 items appear in different places @etc{} Note that @clon{} knows its way
1291 around multiple occurrences of the same object: even if you use the same
1292 option object several times in a synopsis, @clon{} only maintains a
1293 single option definition.
1294 @end enumerate
1296 @node Group Definition, , Advantages, Advanced Synopsis Creation
1297 @subsubsection Group Definition
1298 There is one last point we need to address in order to complete this
1299 section. There might be times when you need to manipulate an explicit
1300 group object, but the object itself can still be created in a
1301 declarative (or mixed) way because you don't need to keep references on
1302 its items. For this, @clon{} provides a macro called @code{defgroup}.
1304 @defmac defgroup (OPTIONS@dots{}) ITEMS@dots{}
1305 @cindex Groups, in synopsis
1306 @fiindex{defsynopsis,group}
1307 @foindex{defgroup,:header}
1308 @foindex{defgroup,:hidden}
1309 Define a new group and return it. This macro behaves exactly like the
1310 @code{group} form in a call to @code{defsynopsis} (@pxref{Groups}). In
1311 fact, an intermediate step in the expansion of the @code{defsynopsis}
1312 macro is to transform @code{group} forms into @code{defgroup} macro
1313 calls. As for @code{defsynopsis}, @code{defgroup} allows you to mix
1314 declarative forms, constructor calls or any kind of Lisp code.
1315 @end defmac
1319 @c ----------------
1320 @c Context Creation
1321 @c ----------------
1322 @node Context Creation, Integrity Checks, Synopsis Definition, Using Clon
1323 @section Context Creation
1325 @cindex Initialization Phase
1326 @cindex Phase, initialization
1327 @cindex Context
1328 Step two of the @clon{} initialization phase consists in creating a
1329 @dfn{context}. A context is an object representing a particular instance
1330 of your program, for example (and most notably) with an actual
1331 @cmdline{} as the user typed it.
1333 @menu
1334 * Making A Context::            The Constructor function
1335 * Contextual Information::      Interesting context slots
1336 @end menu
1338 @node Making A Context, Contextual Information, Context Creation, Context Creation
1339 @subsection Making A Context
1341 @cfindex{make-context}
1342 You create a context with the @code{make-context} function.
1344 @defun make-context
1345 @cfsubindex{make-context}
1346 Create a new context. That's it.
1347 @end defun
1349 @node Contextual Information, , Making A Context, Context Creation
1350 @subsection Contextual Information
1352 Once a context object is created, you have access to some interesting
1353 contextual information.
1355 @menu
1356 * Program Name::                As it appear on the command-line
1357 * Command-Line Remainder::      The non-options part
1358 * Command-Line Polling::        Whether something is left
1359 @end menu
1361 @node Program Name, Command-Line Remainder, Contextual Information, Contextual Information
1362 @subsubsection Program Name
1363 The application's program name, as it appears on the @cmdline{}, may be
1364 accessed from @clon{}. You may find it easier to do this way, as @clon{}
1365 wraps around implementation-dependent access methods to @code{argv[0]}.
1367 @findex progname
1368 In order to retrieve @code{argv[0]}, use the @code{progname} function
1369 like this: @code{(progname)}.
1371 @node Command-Line Remainder, Command-Line Polling, Program Name, Contextual Information
1372 @subsubsection Command-Line Remainder
1373 @cindex Remainder, of command-line
1374 @cindex Command-Line, remainder
1375 In the case your @cmdline{} has a remainder (that is, a non-options
1376 part; see @enduserref{Option Separator} and @ref{Synopsis Items}), you
1377 may need to access it in order to process it independently from @clon{}.
1378 Since @clon{} is responsible for parsing the @cmdline{}, it is also in
1379 charge of figuring out where the remainder of the @cmdline{} begins.
1381 @findex remainder
1382 The @cmdline{} remainder is known to @clon{} as soon as a context is
1383 created. You can retrieve it by using the @code{remainder} function like
1384 this: @code{(remainder)}. The remainder is provided as a list of strings.
1386 @node Command-Line Polling, , Command-Line Remainder, Contextual Information
1387 @subsubsection Command-Line Polling
1388 @cindex Polling, of command-line
1389 @cindex Command-Line, polling
1391 @clon{} provides two utility functions to inquire on the current status
1392 of the @cmdline{}.
1394 @findex cmdline-options-p
1395 @findex cmdnline-p
1396 The function @code{cmdline-options-p} returns true if there are still
1397 unprocessed options on the @cmdline{}. The function @code{cmdline-p}
1398 returns true if there's @emph{anything} left on the @cmdline{}, that is,
1399 either unprocessed options, or a remainder. A potential use of
1400 @code{cmdline-p} at a very early stage of your application could be to
1401 automatically display a help string if the @cmdline{} is effectively
1402 empty.
1405 @c ----------------
1406 @c Integrity Checks
1407 @c ----------------
1408 @node Integrity Checks, Option Retrieval, Context Creation, Using Clon
1409 @section Integrity Checks
1410 @findex defsynopsis
1411 @cfindex{make-context}
1412 At this point, you know about the two necessary steps to initialize
1413 @clon{}: defining a synopsis and creating a context. If you paid
1414 attention to the quick start application (@pxref{Quick Start}), you may
1415 have noticed that @code{defsynopsis} was called as a top-level form
1416 whereas @code{make-context} was called from the function @code{main}. So
1417 why the difference?
1419 First, I hope that you see why a context cannot be created as a toplevel
1420 form. If you do that, you will end-up creating a context relevant to the
1421 Lisp environment from which the application is created, not run.
1423 The synopsis, on the other hand, could be defined either as a toplevel
1424 form, as done in the quick start and the demo programs, or in the
1425 function @code{main}, just before making a context. There is a very good
1426 reason to prefer a toplevel form however: that reason is called
1427 ``integrity checks''.
1429 When you define a synopsis (or any synopsis item, for that matter),
1430 @clon{} performs a number of checks to make sure that you're making a
1431 sensible use of the library. In fact, the number of semantic mistakes
1432 that you can make is quite puzzling. You could for instance define
1433 several options with identical names, forget to provide a fallback or
1434 default value when it is required, provide invalid fallback or default
1435 values, and the list goes on and on. These are just a few examples but
1436 there are many more, and @clon{} checks all of those (I think).
1438 Since those mistakes relate to the definition of the application itself,
1439 they do not depend on a particular execution of it. Consequently, the
1440 sooner @clon{} catches them, the better. If you define your
1441 application's synopsis as a toplevel form, @clon{} will be able to
1442 perform its integrity checks when the application is created, not only
1443 when it is used. In other words, you won't be able to get a working
1444 application until your use of @clon{} is semantically correct.
1446 This is why it is strongly recommended to create synopsis from toplevel
1447 forms, and this also explains why @clon{} chooses @emph{not} to provide
1448 an @code{initialize} function that would wrap around @code{defsynopsis}
1449 and @code{make-context} together.
1453 @c ----------------
1454 @c Option Retrieval
1455 @c ----------------
1456 @node Option Retrieval, Help, Integrity Checks, Using Clon
1457 @section Option Retrieval
1458 @cindex Runtime Phase
1459 @cindex Phase, runtime
1460 @cindex Retrieval, of options
1461 @cindex Options Retrieval
1463 During the runtime phase of @clon{}, your main activity will be to
1464 retrieve options and their values. @clon{} provides two techniques for
1465 retrieving options: you can request the value for a specific option
1466 directly, or you can process the @cmdline{} sequentially, which is the
1467 more traditional approach.
1469 @cindex Command-Line
1470 @findex cmdline
1471 Both of these techniques can be freely combined together at any time,
1472 because @clon{} keeps track of the current status of the @cmdline{}. In
1473 fact, @clon{} never works on the original @cmdline{}, but uses a mutable
1474 @emph{copy} of it after parsing. If you want to access the real
1475 @cmdline{} of your application (except for the compiler-specific
1476 options, see @ref{Not Dumping Executables}), you may use the
1477 @code{cmdline} function, which is a wrapper around an
1478 implementation-dependent way to access it.
1481 Finally, remember that the @cmdline{} is scanned from left to right
1482 during option retrieval (@pxenduserref{Option Retrieval}).
1484 @menu
1485 * Explicit Retrieval::          Accessing options by name
1486 * Sequential Retrieval::        Accessing options in order
1487 @end menu
1489 @node Explicit Retrieval, Sequential Retrieval, Option Retrieval, Option Retrieval
1490 @subsection Explicit Retrieval
1491 @cindex Options Retrieval, explicit
1492 @cindex Retrieval, of options, explicit
1493 Since @clon{} lets you retrieve options on demand (at any time), it
1494 makes sense to be able to request the value of a specific option
1495 explicitely. For instance, you might want to try the @samp{--help}
1496 option first, without looking at the rest of the @cmdline{} because the
1497 application will in fact quit immediately after having displayed the
1498 help string.
1500 @defun getopt :KEY VALUE@dots{}
1501 Retrieve the value of a specific option. The following @var{:KEY}s are
1502 currently available.
1504 @table @code
1505 @item :short-name
1506 @item :long-name
1507 @fkindex{getopt,:short-name}
1508 @fkindex{getopt,:long-name}
1509 Use one of these 2 keys to specify the name of the option you wish to
1510 retrieve.
1511 @item :option
1512 @fkindex{getopt,:option}
1513 Alternatively, you can use a reference to an option object
1514 (@pxref{Constructors}).
1515 @end table
1517 This function return two values: the option's value and the value's
1518 source (@pxenduserref{Value Sources}).
1519 @end defun
1521 The value's source may have the following forms:
1522 @table @code
1523 @item (:cmdline @var{NAME})
1524 @cindex Values, source, @cmdline{}
1525 This is for options found on the @cmdline{}. @var{NAME} is the name used
1526 on the @cmdline{}. It can be the option's long or short name, or a
1527 completed long name if the option's name was abbreviated. A completed
1528 name displays the omitted parts in parentheses (@code{"he(lp)"} for
1529 instance).
1530 @item (:fallback @var{NAME})
1531 @cvopindex{:fallback-value}
1532 @cindex Values, source, fallback
1533 The same but when the fallback value is used, that is, when an option is
1534 not provided with its (optional) argument.
1535 @item (:default @var{NAME})
1536 @cvopindex{:default-value}
1537 @cindex Values, source, default
1538 The same, but when the default value is used (because there is no
1539 fallback).
1540 @item (:environment @var{VAR})
1541 @copindex{:env-var}
1542 @cindex Values, source, environment
1543 This is for options not found on the @cmdline{} but for which there is
1544 an associated environment variable set in the application's environment.
1545 @var{VAR} is the name of the corresponding environment variable.
1546 @item :default
1547 @cvopindex{:default-value}
1548 @cindex Values, source, default
1549 This is for options not found anywhere, but for which a default value
1550 was provided.
1551 @end table
1553 @oindex{Flags,flag}
1554 @findex getopt
1555 Note that because flags don't take any argument, @code{getopt} returns a
1556 virtual value of @code{t} when they are found or a corresponding
1557 environment variable exists in the environment. For the same reason, a
1558 flag's value source may ony be @code{(:cmdline @var{NAME})} or
1559 @code{(:environment @var{VAR})}.
1561 @findex getopt
1562 When an option is not found anywhere and there is no default value,
1563 @code{getopt} just returns nil (no second value). Also, note that when
1564 your option accepts @code{nil} as a value, you @emph{need} to handle the
1565 second retrun value to make the difference between an option not found,
1566 and an actual value of @code{nil}.
1569 @node Sequential Retrieval, , Explicit Retrieval, Option Retrieval
1570 @subsection Sequential Retrieval
1571 @cindex Options Retrieval, sequential
1572 @cindex Retrieval, of options, sequential
1573 The more traditional approach to option retrieval is to scan the
1574 @cmdline{} for options in their order of appearance. @clon{} supports
1575 this by providing you with one function and two macros, as explained
1576 below.
1578 @defun getopt-cmdline
1579 Get the @dfn{next} @cmdline{} option, that is, the first option on the
1580 @cmdline{} that has not been previously retrieved, either explicitely or
1581 sequentially.
1583 When there are no more options on the @cmdline{}, this function returns
1584 @code{nil}. Otherwise, four values are returned: the corresponding
1585 option object from the synopsis definition (@pxref{Constructors}), the
1586 name used on the @cmdline{}, the option's value and the value source
1587 (@code{:cmdline}, @code{:fallback} or @code{:default}). As in the case
1588 of explicit retrieval (@pxref{Explicit Retrieval}), the option's name
1589 may be completed in case of abbreviation.
1591 @rfindex{short-name}
1592 @rfindex{long-name}
1593 @copindex{:short-name}
1594 @copindex{:long-name}
1595 Unless you keep references to all your option objects (and thus can
1596 compare them directly to the one returned by this function), you can
1597 still identify the retrieved option by using the @code{short-name} and
1598 @code{long-name} readers on it: simply use @code{(long-name
1599 @var{OPTION})} or @code{(short-name @var{OPTION})} and you will get the
1600 corresponding strings.
1601 @end defun
1603 @defmac multiple-value-getopt-cmdline (OPTION NAME VALUE SOURCE) BODY
1604 Evaluate @var{BODY} with @var{OPTION}, @var{NAME}, @var{VALUE} and
1605 @var{SOURCE} bound to the values returned by the @code{getopt-cmdline}
1606 function above. Note that @var{BODY} is not evaluated if there was no
1607 remaining option on the @cmdline{}, so you don't need to conditionalize
1608 on @var{OPTION} being @code{null} yourself.
1609 @end defmac
1611 @defmac do-cmdline-options (OPTION NAME VALUE SOURCE) BODY
1612 As above, but loop over all @cmdline{} options.
1613 @end defmac
1616 @c ----
1617 @c Help
1618 @c ----
1619 @node Help, , Option Retrieval, Using Clon
1620 @section Help
1621 @cindex Help String
1622 One of the first motivations in the design of @clon{} was to automate
1623 the generation of the help string, which is a very boring maintenance
1624 task to do by hand. The application's synopsis contains all the
1625 necessary information to do so. In order to print your application's
1626 help string, use the @code{help} function.
1628 @defun help [@code{:item} ITEM]
1629 @bioindex{search-path}
1630 @bievindex{SEARCH_PATH}
1631 @bioindex{highlight}
1632 @bievindex{HIGHLIGHT}
1633 @bioindex{theme}
1634 @bievindex{THEME}
1635 @bioindex{line-width}
1636 @bievindex{LINE_WIDTH}
1637 Print the application's help string. Printing honors the search path,
1638 theme, line width and highlight settings provided by the corresponding
1639 built-in options (@pxenduserref{Theme Mechanism}).
1640 @end defun
1642 @fkindex{help,:item}
1643 By default, @code{help} prints the whole application help string,
1644 excluding hidden items. However, if you have kept a reference to any
1645 synopsis item (option, text, group), you can pass it as the value of the
1646 @code{:item} key, and @clon{} will only print the help string for that
1647 particular item. In this case however, the hidden state of the item is
1648 discarded (but @emph{not} the ones of sub-items).
1650 @bioindex{help}
1651 @cindex Built-In Groups
1652 @cindex Groups, built-in
1653 @cindex Hidden Groups
1654 @cindex Groups, hidden
1655 For instance, the @clon{} built-in group is normally hidden, so it
1656 doesn't show up in the global help string, but the @bioption{help}
1657 option uses the @code{help} function on it explicitely, so it discards
1658 its hidden state.
1660 Here is a potentially useful application of hidden groups in conjunction
1661 with the @code{:item} key. Look at ImageMagick's @file{convert}
1662 program's help string for instance: it is 276 lines long. Gosh. The help
1663 string is decomposed into several categories: image settings, image
1664 operators, misc options @etc{}. If I were to implement this program, I
1665 would rather have the @option{--help} option display an overview of the
1666 program, advertise @option{--version} and a couple of others, and I
1667 would then implement @option{--help} as an enumeration for listing every
1668 option category individually (they would normally be stored in hidden
1669 groups). The user could then use @option{--help=settings},
1670 @option{--help=operators} and so on to display only the category she's
1671 interested in.
1673 Finally, here is potentially useful application of hidden options that
1674 are never ever displayed in any help string whatsoever, and I mean,
1675 like, ever. This is the perfect tool for backdoor'ing a program. For
1676 instance, if you ever need to implement a
1677 @option{--discard-all-security-measures-and-blow-the-nuke} option, then
1678 you'd better have it hidden@dots{}
1682 @c ====================================================================
1683 @c Extending Clon
1684 @c ====================================================================
1685 @node Extending Clon, Advanced Usage, Using Clon, Top
1686 @chapter Extending Clon
1688 As you know, @clon{} already provides seven built-in option types: flags
1689 and six other types for valued options (@pxref{Built-In Valued
1690 Options}). After using @clon{} for a while, you may find that however
1691 brilliant and perfectly designed it is, none of the provided built-in
1692 types fullfill your requirements exactly. There are two ways around
1693 this: the right way and the wrong way (hint).
1695 @voindex{Strings,stropt}
1696 The wrong, although perhaps quicker way would be to use the
1697 @code{stropt} option type to simply retrieve unprocessed string values,
1698 and then do whatever tweaking required on them. In doing so, you risk
1699 reinventing some of @clon{}'s wheels.
1701 The right way is to define a new option type. Properly defined option
1702 types are a good thing because they allow for reusability and also
1703 extensibility, since new option types can always be defined on top of
1704 others.
1705 @voindex{Enumerations,enum}
1706 In this chapter we explain how to extend @clon{} by providing new option
1707 types. We illustrate the process with the example of the built-in
1708 @code{enum} one.
1710 @cindex Valued Options
1711 @cindex Options, valued
1712 @oindex{Flags,flag}
1713 Oh, and I almost forgot. I hope it is obvious to everyone that new
1714 option types are always @emph{valued}. There's no point in extending
1715 @clon{} with options that don't take any arguments, since we already
1716 have flags.
1718 @menu
1719 * New Option Types::    In four steps
1720 * Extension Tips::      Some advice
1721 @end menu
1724 @c ----------------
1725 @c New Option Types
1726 @c ----------------
1727 @node New Option Types, Extension Tips, Extending Clon, Extending Clon
1728 @section New Option Types
1729 @cindex Option Types, in files
1730 @cindex Files, one per option type
1731 @pkgindex{com.dvlsoft.clon}
1732 From a software engineering point of view, it is better to implement new
1733 option types in a file of their own, preferably named after the option
1734 type itself, and to put this file in the @clon{} package, like this:
1736 @cartouche
1737 @verbatim
1738 (in-package :com.dvlsoft.clon)
1739 @end verbatim
1740 @end cartouche
1742 Creating your own option type involves 5 steps: providing a class for
1743 them, implementing three protocols related to argument/value tweaking,
1744 and providing a constructor function. We now review those 5 steps in
1745 order.
1747 @menu
1748 * New Option Classes::                  Step 1
1749 * Value Check Protocol::                Step 2
1750 * Argument Conversion Protocol::        Step 3
1751 * Error Management::                    In-between steps coffee time!
1752 * Value Stringification Protocol::      Step 4
1753 * Constructor Functions::               Step 5
1754 @end menu
1756 @node New Option Classes, Value Check Protocol, New Option Types, New Option Types
1757 @subsection New Option Classes
1758 @clsindex{option}
1759 @clsindex{valued-option}
1760 @clon{} maintains a class hierarchy for all option types. The mother of
1761 all option types is the @code{option} abstract class. It handles the
1762 options'short and long names, description and associated environment
1763 variable (@pxref{Common Properties}). Valued options inherit from an
1764 abstract subclass of @code{option} called @code{valued-option}. This
1765 class handles the option's argument name and status (optional or
1766 mandatory), fallback and default values (@pxref{Common Valued Option
1767 Properties}).
1769 @cindex User-Defined Option Classes
1770 @cindex Option Classes, user-defined
1771 In order to create a new option type, use the @code{defoption} macro.
1773 @defmac defoption CLASS SUPERCLASSES SLOTS &rest OPTIONS
1774 Create a new option CLASS and register it with @clon{}.
1775 Syntactically, thismacro behaves like @code{defclass}. Option types
1776 created like this implicitely inherit from @code{valued-option} and in
1777 turn @code{option}, so you don't need to put them explicitely in the
1778 @var{SUPERCLASSES} list.
1779 @end defmac
1781 Let's look at the enumeration example now.
1783 @cartouche
1784 @verbatim
1785 (defoption enum (enum-base)
1786   ((argument-name ;; inherited from the VALUED-OPTION class
1787     :initform "TYPE"))
1788   (:documentation "The ENUM class.
1789 This class implements options whose values belong to a set of keywords."))
1790 @end verbatim
1791 @end cartouche
1793 @voindex{Enumerations,enum}
1794 @vopindex{Enumerations,enum,:enum}
1795 @voindex{Extended Switches,xswitch}
1796 @vopindex{Extended Switches,xswitch,:enum}
1797 @clsindex{enum-base}
1798 As you can see, this class inherits from @code{enum-base}, which is the
1799 class handling the @code{:enum} property. The reason for this split is
1800 that there are currently two option types providing enumeration-like
1801 facility: @code{enum} and @code{xswitch}, so @code{xswitch} also
1802 inherits from @code{enum-base}.
1804 @clsindex{valued-option}
1805 @cvopindex{:argument-name}
1806 There are no new slots in this class, but the @code{argument-name} slot
1807 provided by the @code{valued-option} class has its initform changed from
1808 @code{"ARG"} to @code{"TYPE"}.
1810 @node Value Check Protocol, Argument Conversion Protocol, New Option Classes, New Option Types
1811 @subsection Value Check Protocol
1812 @cindex Value Check Protocol
1813 @cindex Protocols, value check
1814 Now that we have our new option class, we need to implement the
1815 so-called @dfn{value check} protocol. This protocol is used to make sure
1816 that values provided for options of your new type actually comply with
1817 the type in question. Values going through this protocol are fallback
1818 values, default values, and values provided from a debugger restart
1819 (@pxenduserref{Error Management}). In the case of fallback and default
1820 values (which, by the way, are provided by @emph{you}, the @clon{}
1821 user), the check is performed only once, when the option object is
1822 created. Values provided from a debugger restart come from the
1823 application end-user, and hence are checked every time.
1825 The value check protocol is implemented through a @code{check} generic
1826 function for which you must provide a method.
1828 @deffn {Generic Function} check OPTION VALUE
1829 @gfsubindex{check}
1830 @ecindex invalid-value
1831 Check that @var{VALUE} is valid for @var{OPTION}. If @var{VALUE} is
1832 valid, return it. Otherwise, raise an @code{invalid-value} error.
1833 @end deffn
1835 As you can see, you need to provide a method with the first argument
1836 specialized to your new option type. This method must return @var{VALUE}
1837 if it is okay, and raise an @code{invalid-value} error otherwise.
1839 @ecindex invalid-value
1840 @clon{} maintains a hierarchy of error conditions. The
1841 @code{invalid-value} error condition is defined like this:
1843 @cartouche
1844 @verbatim
1845 (define-condition invalid-value (option-error)
1846   ((value :documentation "The invalid value."
1847           :initarg :value
1848           :reader value)
1849    (comment :documentation "An additional comment about the error."
1850             :type string
1851             :initarg :comment
1852             :reader comment))
1853   (:report (lambda (error stream)
1854              (format stream "Option ~A: invalid value ~S.~@[~%~A~]"
1855                (option error) (value error) (comment error))))
1856   (:documentation "An invalid value error."))
1857 @end verbatim
1858 @end cartouche
1860 @ecindex invalid-value
1861 @ecsindex{invalid-value,value}
1862 @ecsindex{invalid-value,comment}
1863 When the error is raised, you must fill in the @code{value} and
1864 @code{comment} slots appropriately.
1865 @ecindex option-error
1866 @ecsindex{option-error,option}
1867 The super-condition @code{option-error} provides an additional
1868 @code{option} slot that you must also fill in when the error is raised.
1870 @gfmindex{check,@r{Enumerations (}enum@r{)}}
1871 @voindex{Enumerations,enum}
1872 @vopindex{Enumerations,enum,:enum}
1873 @findex list-to-string
1874 Let's look at the enumeration example now.
1876 @cartouche
1877 @verbatim
1878 (defmethod check ((enum enum) value)
1879   "Check that VALUE is a valid ENUM."
1880   (unless (member value (enum enum))
1881     (error 'invalid-value
1882            :option enum
1883            :value value
1884            :comment (format nil "Valid values are: ~A."
1885                       (list-to-string (enum enum)
1886                                       :key #'prin1-to-string))))
1887   value)
1888 @end verbatim
1889 @end cartouche
1891 This code should be self-explanatory. We check that the value we got
1892 belongs to the enumeration. @code{list-to-string} is a utility function
1893 that will separate every element with comas in the resulting string.
1895 @node Argument Conversion Protocol, Error Management, Value Check Protocol, New Option Types
1896 @subsection Argument Conversion Protocol
1897 @cindex Argument Conversion Protocol
1898 @cindex Protocols, argument conversion
1899 The next protocol we need to implement is the so-called @dfn{argument
1900 conversion} protocol. This protocol is used to convert option arguments
1901 (that is, strings) to an actual value of the proper type. Arguments
1902 going through this protocol come from the @cmdline{}, the value of an
1903 environment variable or a debugger restart (@pxenduserref{Error
1904 Management}). Also, note that @clon{} assumes that you implement this
1905 protocol correctly, so no value check is performed on values coming from
1906 the conversion of an argument.
1908 The conversion protocol is implemented through a @code{convert} generic
1909 function for which you must provide a method.
1911 @deffn {Generic Function} convert OPTION ARGUMENT
1912 @gfsubindex{convert}
1913 @ecindex invalid-argument
1914 Convert @var{ARGUMENT} to @var{OPTION's} value. If @var{ARGUMENT} is
1915 invalid, raise an @code{invalid-argument} error.
1916 @end deffn
1918 As you can see, you need to provide a method with the first argument
1919 specialized to your new option type. This method must return the
1920 conversion of @var{ARGUMENT} to the appropriate type if it is valid, and
1921 raise an @code{invalid-argument} error otherwise.
1923 @ecindex invalid-argument
1924 The @code{invalid-argument} error condition is defined like this:
1926 @cartouche
1927 @verbatim
1928 (define-condition invalid-argument (option-error)
1929   ((argument :documentation "The invalid argument."
1930              :type string
1931              :initarg :argument
1932              :reader argument)
1933    (comment :documentation "An additional comment about the error."
1934             :type string
1935             :initarg :comment
1936             :reader comment))
1937   (:report (lambda (error stream)
1938              (format stream "Option ~A: invalid argument ~S.~@[~%~A~]"
1939                (option error) (argument error) (comment error))))
1940   (:documentation "An invalid argument error."))
1941 @end verbatim
1942 @end cartouche
1944 @ecindex invalid-argument
1945 @ecsindex{invalid-argument,argument}
1946 @ecsindex{invalid-argument,comment}
1947 When the error is raised, you must fill in the @code{argument} and
1948 @code{comment} slots appropriately.
1949 @ecindex option-error
1950 @ecsindex{option-error,option}
1951 As before, the super-condition @code{option-error} provides an
1952 additional @code{option} slot that you must also fill in when the error
1953 is raised.
1955 @gfmindex{convert,@r{Enumerations (}enum@r{)}}
1956 @voindex{Enumerations,enum}
1957 @vopindex{Enumerations,enum,:enum}
1958 @findex closest-match
1959 Let's look at the enumeration example now.
1961 @cartouche
1962 @verbatim
1963 (defmethod convert ((enum enum) argument)
1964   "Convert ARGUMENT to an ENUM value."
1965   (or (closest-match argument (enum enum) :ignore-case t :key #'symbol-name)
1966       (error 'invalid-argument
1967              :option enum
1968              :argument argument
1969              :comment (format nil "Valid arguments are: ~A."
1970                         (list-to-string (enum enum)
1971                                         :key (lambda (value)
1972                                                (stringify enum value)))))))
1974 @end verbatim
1975 @end cartouche
1977 Since enumerations allow their arguments to be abbreviated, a utility
1978 function named @code{closest-match} is used to find the closest match
1979 between an argument and the possible values. Otherwise, an
1980 @code{invalid-argument} error is raised. For an explanation of
1981 @code{stringify}, @xref{Value Stringification Protocol}.
1983 @node Error Management, Value Stringification Protocol, Argument Conversion Protocol, New Option Types
1984 @subsection Error Management
1985 @cindex Debugger
1986 @cindex Debugger restarts
1987 Let's take a short break in our @clon{} extension process. We have seen
1988 that @clon{} may throw errors in different situations, including invalid
1989 arguments or values. The end-user manual advertises that the interactive
1990 error handler offers a set of ``options to fix problems'' (if you don't
1991 know what I'm talking about, please read @enduserref{Error Management}
1992 and you will know). Well, you may have guessed that these options are
1993 simply ``restarts'' (of course, we don't use that term there, as we
1994 wouldn't want to frighten the casual user, or would we?).
1996 When you ship your application, you are encouraged to disable the
1997 debugger in the standalone executable because that also might scare the
1998 casual user a little bit (the end-user manual only mentions the
1999 @code{none} error-handler to explain that people shouldn't use it). The
2000 way error handling is done in @cl{} standalone executables is
2001 implementation-dependent, so please refer to your favorite compiler's
2002 documentation. More generally, the behavior of @cl{} standalone
2003 executables may depend on:
2004 @itemize @bullet
2005 @item
2006 @cindex Dumping
2007 the state of the Lisp environment when the application was dumped, which
2008 may in turn depend on @cmdline{} options passed to the Lisp itself
2009 (@pxref{Dumping Executables}),
2010 @item
2011 @findex dump
2012 the arguments passed to the dumping function (look at @clon{}'s
2013 @code{dump} macro to see what it does),
2014 @item
2015 worse: @emph{both}.
2016 @end itemize
2018 No, really, @cl{} is no fun at all.
2020 @node Value Stringification Protocol, Constructor Functions, Error Management, New Option Types
2021 @subsection Value Stringification Protocol
2022 Okay, back to implementing our new option type.
2024 @cindex Value Stringification Protocol
2025 @cindex Protocols, value stringification
2026 The third and last protocol we need to implement is called the
2027 @dfn{value stringification} protocol. This protocol can be seen as the
2028 reverse protocol for argument conversion (@pxref{Argument Conversion
2029 Protocol}): its purpose is to transform an option's value into a
2030 corresponding argument that the end-user could have provided in order to
2031 get that value.
2033 @cindex Help String
2034 @cvopindex{:fallback-value}
2035 @cindex Values, source, fallback
2036 @cvopindex{:default-value}
2037 @cindex Values, source, default
2038 @gfmindex{convert,@r{Enumerations (}enum@r{)}}
2039 The main use for this protocol is to advertise the fallback and default
2040 values correctly in help strings: the end-user does not want to see
2041 those @emph{values}, but rather the @emph{argument} that would lead to
2042 them. However, you are free to use it wherever you like (see the
2043 @code{convert} method for @code{enum} options for instance).
2045 The value stringification protocol is implemented through a
2046 @code{stringify} generic function for which you must provide a method.
2048 @deffn {Generic Function} stringify OPTION VALUE
2049 @gfsubindex{stringify}
2050 Transform OPTION's @var{VALUE} into an argument.
2051 @end deffn
2053 I admit that this function could also have been called
2054 @code{argumentize} or even @code{deconvertify}. As you can see, you need
2055 to provide a method with the first argument specialized to your new
2056 option type. You can assume that @var{VALUE} is a valid value for your
2057 option, so no checking is necessary and no error needs to be raised.
2059 @gfmindex{stringify,@r{Enumerations (}enum@r{)}}
2060 @voindex{Enumerations,enum}
2061 Let's look at the enumeration example now.
2063 @cartouche
2064 @verbatim
2065 (defmethod stringify ((enum enum) value)
2066   "Transform ENUM's VALUE into an argument."
2067   (string-downcase (symbol-name value)))
2068 @end verbatim
2069 @end cartouche
2071 Pretty straightforward, right?
2074 @node Constructor Functions, , Value Stringification Protocol, New Option Types
2075 @subsection Constructor Functions
2076 @cindex Constructors, for options objects
2077 @cindex Option Constructors
2078 The last required step to complete our new option type extension is to
2079 provide a @dfn{constructor} function that wraps around
2080 @code{make-instance} on the corresponding option class. I won't insult
2081 you by explaining how to write a constructor. Let me just give four good
2082 reasons why providing constructors is important.
2084 Providing a constructor for every new option type is important because:
2085 @enumerate
2086 @item
2087 it is important,
2088 @item
2089 it is a good software engineering practice,
2090 @item
2091 it is important,
2092 @item
2093 @findex defsynopsis
2094 @findex defgroup
2095 and above all, it makes your new option type automatically available in
2096 calls to @code{defsynopsis} and @code{defgroup} (@pxref{Synopsis Items}
2097 and @ref{Group Definition}).
2098 @end enumerate
2101 @voindex{Enumerations,enum}
2102 @cfindex{make-enum}
2103 Let's look at the enumeration example now.
2105 @cartouche
2106 @verbatim
2107 (defun make-enum (&rest keys
2108                   &key short-name long-name description
2109                        argument-name argument-type
2110                        enum env-var fallback-value default-value
2111                        hidden)
2112   "Make a new enum option.
2113 - SHORT-NAME is the option's short name (without the dash).
2114   It defaults to nil.
2115 - LONG-NAME is the option's long name (without the double-dash).
2116   It defaults to nil.
2117 - DESCRIPTION is the option's description appearing in help strings.
2118   It defaults to nil.
2119 - ARGUMENT-NAME is the option's argument name appearing in help strings.
2120 - ARGUMENT-TYPE is one of :required, :mandatory or :optional (:required and
2121   :mandatory are synonyms).
2122   It defaults to :optional.
2123 - ENUM is the set of possible values.
2124 - ENV-VAR is the option's associated environment variable.
2125   It defaults to nil.
2126 - FALLBACK-VALUE is the option's fallback value (for missing optional
2127   arguments), if any.
2128 - DEFAULT-VALUE is the option's default value, if any.
2129 - When HIDDEN, the option doesn't appear in help strings."
2130   (declare (ignore short-name long-name description
2131                   argument-name argument-type
2132                   enum env-var fallback-value default-value
2133                   hidden))
2134   (apply #'make-instance 'enum keys))
2135 @end verbatim
2136 @end cartouche
2138 Woah, what a mouthful for a single line of code@dots{} Yeah, I'm a
2139 maniac and I like redundancy. I always restate all the available keys
2140 explicitely, and everything again in the docstring so that all the
2141 interesting information is directly available (I might change my mind as
2142 I grow older though).
2145 @c --------------
2146 @c Extension Tips
2147 @c --------------
2148 @node Extension Tips, , New Option Types, Extending Clon
2149 @section Extension Tips
2150 So that's it. Now you know how to extend @clon{} with your own option
2151 types. Here is some piece of advice that you might find useful in the
2152 process.
2154 @menu
2155 * Incremental Option Types::    Doing without defoption
2156 * Lisp Option Abuse::           Thinking in end-user terms
2157 @end menu
2159 @node Incremental Option Types, Lisp Option Abuse, Extension Tips, Extension Tips
2160 @subsection Incremental Option Types
2161 @findex defoption
2162 If one of the built-in options is almost what you need, you may be
2163 tempted to subclass it directly instead of using @code{defoption}, and
2164 only change what's needed, After all, it's Lisp. Lisp is a world of
2165 mess@t{^D^D^D^D}freedom.
2167 Wrong.
2169 @findex defsynopsis
2170 @findex defgroup
2171 @code{defoption} is not @emph{only} a convenience wrapper around
2172 @code{defclass}. It also arranges for @code{defsynopsis} and
2173 @code{defgroup} to recognize your new option type. So please, do use it
2174 systematically.
2176 @node Lisp Option Abuse, , Incremental Option Types, Extension Tips
2177 @subsection Lisp Option Abuse
2178 @voindex{Lisp Objects,lispobj}
2179 @vopindex{Lisp Objects,lispobj,:typespec}
2180 Along with the same lines, you may find that the @code{lispobj} type is
2181 all you need in many situations. Let's take an example. Suppose you want
2182 to implement a @code{--stars} option to assign a rank to a movie, from 0
2183 to 5. The lazy approach is to simply create a @code{lispobj} option with
2184 a @code{:typespec} (type specifier) of @code{(integer 0 5)} and you're
2185 done.
2187 But now, remember that the end-user of your application is probably not
2188 a Lisper (in fact, I would hope that @clon{} contributes to increasing
2189 the number of standalone @cl{} applications out there@dots{}). What do
2190 you think would be her reaction, if, after providing a bogus value to
2191 the @code{--stars} option, she get the following error message:
2193 @verbatim
2194  Option 'stars': invalid argument "6".
2195 Argument "6" must evaluate to (integer 0 5).
2196 @end verbatim
2198 or worse, a @code{"Cannot parse argument"} error message because of a
2199 typo?
2201 Not very friendly, right? In other words, you need to think in terms of
2202 what the end-user of your application will expect. In that particular
2203 situation, you might want to subclass @code{lispobj} (with
2204 @code{defoption}!) only to provide friendlier error messages.
2208 @c ====================================================================
2209 @c Advanced Usage
2210 @c ====================================================================
2211 @node Advanced Usage, Conclusion, Extending Clon, Top
2212 @chapter Advanced Usage
2214 This chapter contains information about different features that are
2215 present in @clon{} because of design decisions, but that I expect to be
2216 used only rarely, if at all.
2218 @menu
2219 * Multiple Clon Instances::     Different command-lines, synopsis or contexts
2220 * Programmatic Help Strings::   Beyond the --help option
2221 * Version Numbering::           In case you need to conditionalize
2222 @end menu
2225 @c -----------------------
2226 @c Multiple Clon Instances
2227 @c -----------------------
2228 @node Multiple Clon Instances, Programmatic Help Strings, Advanced Usage, Advanced Usage
2229 @section Multiple @clon{} Instances
2231 It is possible to use different instances of @clon{} in parallel in a
2232 single application, by using a virtual @cmdline{} instead of the real
2233 one, different synopsis and multiple contexts simultaneously.
2235 @menu
2236 * Using Different Synopsis::            The default one, and the others
2237 * Using Different Command-Lines::       The real one, and the others
2238 * Using Multiple Contexts::             The current one, and the others
2239 * Potential Uses::                      What to do with all that
2240 @end menu
2242 @node Using Different Synopsis, Using Different Command-Lines, Multiple Clon Instances, Multiple Clon Instances
2243 @subsection Using Different Synopsis
2244 @cindex Synopsis, default
2245 Did you notice that after defining a synopsis, there is actually never
2246 any explicit reference to it anymore? So where is the magick? In fact,
2247 there's no magick at all involved here.
2249 @vindex *synopsis*
2250 @foindex{defsynopsis,:make-default}
2251 @cfiaindex{make-synopsis,:make-default}
2252 @clon{} has a global variable named @code{*synopsis*} which holds the
2253 current synopsis. When you define/create a synopsis with either
2254 @code{defsynopsis} or @code{make-synopsis}, it is automatically made the
2255 default one, unless you use the @code{:make-default} option/initarg with
2256 a value of @code{nil}, like this:
2258 @verbatim
2259 (defsynopsis (:make-default nil) ...)
2260 @end verbatim
2262 or this:
2264 @verbatim
2265 (make-synopsis :make-default nil ...)
2266 @end verbatim
2268 @cfindex{make-context}
2269 When you create a context with @code{make-context}, the default synopsis
2270 is used implicitely, but you have two ways to avoid this.
2272 @enumerate
2273 @item
2274 @vindex *synopsis*
2275 At any time in your program, you may change the value of
2276 @code{*synopsis*}. All subsequent calls to @code{make-context} will
2277 hence use this other synopsis.
2278 @item
2279 @cfiaindex{make-context,:synopsis}@c
2280 If you prefer to use another synopsis only temporarily, you can use the
2281 @code{:synopsis} initarg to @code{make-context} instead.
2282 @end enumerate
2284 @node Using Different Command-Lines, Using Multiple Contexts, Using Different Synopsis, Multiple Clon Instances
2285 @subsection Using Different Command-Lines
2286 In @ref{Context Creation}, we saw that a context object describes a
2287 particular instance of your application, most notably depending on the
2288 actual @cmdline{} the end-user provided. It turns out, however that the
2289 @cmdline{} doesn't need to be the actual program's @cmdline{}, as the
2290 user typed it. Any list of strings can act as a @cmdline{}.
2292 @cfiaindex{make-context,:cmdline}
2293 The function @code{make-context} has a @code{:cmdline} key that allows
2294 you to provide any list of strings that will act as the @cmdline{}. Of
2295 course, the default is to use the actual program's one.
2297 @node Using Multiple Contexts, Potential Uses, Using Different Command-Lines, Multiple Clon Instances
2298 @subsection Using Multiple Contexts
2299 @cindex Context, current
2300 Did you also notice that after creating a context, there is actually
2301 never any explicit reference to it anymore? So again, where is the
2302 magick? In fact, there's no magick at all involved here either.
2304 @vindex *context*
2305 @cfiaindex{make-context,:make-current}@c
2306 @clon{} has a global variable named @code{*context*} which holds the
2307 current context. When you create a context with @code{make-context}, it
2308 is automatically made current, unless you use the @code{:make-current}
2309 initarg with a value of @code{nil}.
2311 @cindex Runtime Phase
2312 @findex progname
2313 @findex remainder
2314 @findex cmdline-options-p
2315 @findex cmdline-p
2316 @findex getopt
2317 @findex getopt-cmdline
2318 @findex multiple-value-getopt-cmdline
2319 @findex do-cmdline-options
2320 @findex help
2321 The whole runtime phase API of @clon{} uses a context implicitely. This
2322 involves @code{progname}, @code{remainder}, @code{cmdline-options-p},
2323 @code{cmdline-p}, @code{getopt}, @code{getopt-cmdline},
2324 @code{multiple-value-getopt-cmdline}, @code{do-cmdline-options} and
2325 @code{help}. As a consequence, it is possible to use @clon{} with
2326 multiple contexts at the same time. There are in fact three ways to
2327 achieve this.
2329 @enumerate
2330 @item
2331 @vindex *context*
2332 At any time in your program, you may change the value of
2333 @code{*context*}. All subsequent calls to the runtime phase API
2334 will hence use this other context.
2335 @item
2336 @clon{} also provides a macro which changes the current context for you.
2337 @defun with-context CONTEXT &body BODY
2338 Execute @var{BODY} with @code{*context*} bound to @var{CONTEXT}.
2339 @end defun
2340 @item
2341 @fkindex{progname,:context}@c
2342 @fkindex{remainder,:context}@c
2343 @fkindex{cmdline-options-p,:context}@c
2344 @fkindex{cmdline-p,:context}@c
2345 @fkindex{getopt,:context}@c
2346 @fkindex{getopt-cmdline,:context}@c
2347 @fkindex{help,:context}@c
2348 @foindex{multiple-value-getopt-cmdline,:context}@c
2349 @foindex{do-cmdline-options,:context}@c
2350 If you prefer to use another context only once, you can use the
2351 @code{:context} key instead. The whole runtime phase API of @clon{}
2352 understands it. For the functions @code{getopt}, @code{getopt-cmdline}
2353 and @code{help}, it's just another key in addition to those we've
2354 already seen. For the macros @code{multiple-value-getopt-cmdline} and
2355 @code{do-cmdline-options}, the key must appear at the end of the first
2356 (list) argument, like this:
2358 @verbatim
2359 (multiple-value-getopt-cmdline (option name value :context ctx) ...)
2360 (do-cmdline-options (option name value :context ctx) ...)
2361 @end verbatim
2362 @end enumerate
2364 @node Potential Uses, , Using Multiple Contexts, Multiple Clon Instances
2365 @subsection Potential Uses
2366 By combining @clon{}'s ability to use a virtual @cmdline{}, different
2367 synopsis and multiple contexts, you can achieve very neat (read: totally
2368 useless) things. For instance, you could write an application that takes
2369 an option providing @cmdline{} arguments for an external program to be
2370 forked. Some revision control systems do that for controlling external
2371 @code{diff} programs for instance, so no big deal. The big deal is that
2372 you can completely control the validity of the external program's
2373 @cmdline{}, before it is forked, from your original one.
2375 Here is another idea, again related to revision control systems. Some of
2376 them feature a @cmdline{} syntax like the following:
2378 @verbatim
2379 prog [global options] command [command-specific options]
2380 @end verbatim
2382 @cindex Postfix
2383 @cindex Command-Line, remainder
2384 @cindex Remainder, of command-line
2385 You can achieve this with @clon{} quite easily. In fact, the
2386 demonstration program called @file{advanced} in the distribution shows
2387 you how to do it. First, define a synopsis which only handles the global
2388 options, and provide a postfix of @code{"command [command-specific
2389 option]"} or something like that. This will authorize a @cmdline{}
2390 remainder which will start with the command name.
2392 Now, for every command in your program, define a specific synopsis with
2393 only the command-specific options. Get the remainder of the original
2394 @cmdline{} (@pxref{Command-Line Remainder}) and figure out which command
2395 was used. Depending on it, create a new context with the appropriate
2396 synopsis and the original @cmdline{}'s remainder as the new, virtual,
2397 @cmdline{}. You're done: retrieve global options from the first context,
2398 and command-specific ones from the second one.
2400 @cindex Help String, display
2401 @findex help
2402 What's even cooler is that you can display the command-specific options
2403 on demand quite easily as well (like what @file{git} does when you call
2404 it like this: @code{git commit --help} for instance): calling the
2405 @code{help} function on the original context gives you the global
2406 options's help string while calling it on the command-specific one will
2407 display the command-specific usage.
2409 @bioindex{search-path}
2410 @bievindex{SEARCH_PATH}
2411 @bioindex{highlight}
2412 @bievindex{HIGHLIGHT}
2413 @bioindex{theme}
2414 @bievindex{THEME}
2415 @bioindex{line-width}
2416 @bievindex{LINE_WIDTH}
2417 One thing to remember here is that every context/synopsis duet you
2418 create gets its own set of built-in @clon{} options. As a consequence,
2419 there is currently no simple way to have a single set of built-in
2420 options apply to the whole application, for instance, to both a global
2421 and a command-specific context. Let me make this clearer: if your
2422 end-user calls @code{prog --clon-theme=foo command -h}, then the theme
2423 option will have no effect because it would only affect the global help
2424 option. In order to actually use the expected theme, your end-user would
2425 need to use @code{prog command --clon-theme=foo -h}. Depending on which
2426 cerebral emisphere (s)he prefers to use, this may seem logical or not.
2428 Finally, note that you can use the virtual @cmdline{} / specific
2429 synopsis technique recursively to manage complicated @cmdline{} syntax,
2430 for instance alternating options and non-options parts several times.
2432 In the future, @clon{} may provide better ways to achieve this kind of
2433 things (a notion of ``sub-context'' may be in order).
2437 @c -------------------------
2438 @c Programmatic Help Strings
2439 @c -------------------------
2440 @node Programmatic Help Strings, Version Numbering, Multiple Clon Instances, Advanced Usage
2441 @section Programmatic Help Strings
2443 @findex help
2444 @cindex Help String
2445 @cindex Themes
2446 @cindex Themes, standard, @t{refcard}
2447 @cindex Standard Themes, @t{refcard}
2448 So far, we've seen how to use the @code{help} function to implement a
2449 typical @code{--help} option. This is mostly intended for the end-user.
2450 There are also times when this function could be useful to @emph{you},
2451 the application developer. For instance, one could imagine that part of
2452 the compilation phase would involve generating the help string in order
2453 to include it in the manual. Another idea would be that @samp{make
2454 install} creates a @file{REFCARD} file in
2455 @file{/usr/local/share/doc/my-app/} which contains the help string
2456 formatted with the @code{refcard} theme, @etc{}.
2458 @bioindex{theme}
2459 @bievindex{THEME}
2460 @bioindex{search-path}
2461 @bievindex{SEARCH_PATH}
2462 @bioindex{line-width}
2463 @bievindex{LINE_WIDTH}
2464 @bioindex{highlight}
2465 @bievindex{HIGHLIGHT}
2466 In such situations, calling the @code{help} function might not be
2467 directly associated with an end-user level option, or at least not
2468 @code{--help}, and you might not want to honor the end-user level
2469 settings for theme, search path, line-width, or highlighting either
2470 (remember that these settings might come from the environment variables
2471 associated with @bioption{theme}, @bioption{search-path},
2472 @bioption{line-width} and @bioption{highlight}).
2474 @fkindex{help,:theme}
2475 @fkindex{help,:search-path}
2476 @fkindex{help,:line-width}
2477 @fkindex{help,:highlight}
2478 Because of this, the @code{help} function provides additional keys that
2479 allow you to override those settings (they are in fact stored in the
2480 context object). The keys in question are: @code{:theme},
2481 @code{:search-path}, @code{:line-width} and @code{:highlight}.
2483 @fkindex{help,:output-stream}
2484 @vindex *standard-output*
2485 In addition to that, there is an @code{:output-stream} key which
2486 defaults to @code{*standard-output*} which you could use for instance to
2487 write directly to a file. Note that there is no end-user level access to
2488 this parameter.
2492 @c -----------------
2493 @c Version Numbering
2494 @c -----------------
2495 @node Version Numbering, , Programmatic Help Strings, Advanced Usage
2496 @section Version Numbering
2498 @bioindex{version}
2499 As @clon{} evolves over time, you might one day feel the need for
2500 conditionalizing your code on the version of the library. While the
2501 end-user of your application has limited means to access the current
2502 version number of @clon{} (see @enduserref{Clonification} and the
2503 built-in option @bioption{version}), you, the application programmer
2504 and @clon{} user, have a finer grained access to it.
2506 The first thing you can do to access the current version number of
2507 @clon{} is use the @code{version} function (this is in fact the function
2508 bound to the @bioption{version} option).
2510 @defun version &optional (TYPE :number)
2511 Return the current version number of @clon{}. @var{TYPE} can be one of
2512 @code{:number}, @code{:short} or @code{:long}. For @code{:number}, the
2513 returned value is a fixnum. Otherwise, it is a string.
2514 @end defun
2516 A @clon{} version is characterized by 4 elements as described below.
2517 @itemize
2518 @item
2519 @vindex +release-major-level+
2520 A major version number stored in the constant
2521 @code{+release-major-level+}.
2522 @item
2523 @vindex +release-minor-level+
2524 A minor version number, stored in the constant
2525 @code{+release-minor-level+}.
2526 @item
2527 @vindex +release-status+
2528 A release status stored in the constant @code{+release-status+}. The
2529 status of a release can be @code{:alpha}, @code{:beta}, @code{:rc}
2530 (standing for ``release candidate'') or @code{:patchlevel}. These are in
2531 effect 4 levels of expected stability.
2532 @item
2533 @vindex +release-status-level+
2534 A status-specific version number stored in the constant
2535 @code{+release-status-level+}. Status levels start at 1 (alpha 1, beta 1
2536 and release candidate 1) except for stable versions, in which case patch
2537 levels start at 0 (@eg{} 2.4.0).
2538 @end itemize
2540 @vindex +release-name+
2541 In addition to that, each version of @clon{} (in the sense
2542 @emph{major.minor}, regardless of the status) has a name, stored in the
2543 constant @code{+release-name+}. The general theme for @clon{} is ``Great
2544 Jazz Musicians'', and specifically for the 1.x series: ``Great Saxophone
2545 Players''. Anyone daring to mention Kenny G at that point will be shot
2546 on sight.
2548 Here is how the @code{version} function computes its value.
2549 @itemize
2550 @item
2551 A version @code{:number} is computed as @emph{major . 10000 + minor .
2552 100 + patchlevel}, effectively leaving two digits for each level. Note
2553 that alpha, beta and release candidate status are ignored in version
2554 numbers (this is as if the corresponding status level was considered to
2555 be always 0). Only stable releases have their level taken into account.
2556 @item
2557 A @code{:short} version will appear like this for unstable releases:
2558 1.3a4, 2.5b8 or 4.2rc1. Remember that alpha, beta or release candidate
2559 levels start at 1. Patchlevels for stable releases start at 0 but 0 is
2560 ignored in the output. So for instance, version 4.3.2 will appear as-is,
2561 while version 1.3.0 will appear as just 1.3.
2562 @item
2563 A @code{:long} version is expanded from the short one, and includes the
2564 release name. For instance, 1.3 alpha 4 "Bill Evans", 2.5 beta 8 "Scott
2565 Henderson", 4.2 release candidate 1 "Herbie Hancock" or 4.3.2 "Chick
2566 Corea". As for the short version, a patchlevel of 0 is ignored in the
2567 output: 1.3 "Bill Evans".
2568 @end itemize
2572 @c ====================================================================
2573 @c Conclusion
2574 @c ====================================================================
2575 @node Conclusion, Technical Notes, Advanced Usage, Top
2576 @chapter Conclusion
2578 So that's it I guess. You know all about @clon{} now. The next step is
2579 to actually use it to clonify your favorite application, write new
2580 applications using it and contaminate the world with standalone @cl{}
2581 programs, featuring unprecedented @cmdline{} power and thrill-a-minute
2582 option hacking.
2584 Now, go Luke. The Attack of the @clon{} is ready to begin.
2588 @c ====================================================================
2589 @c Technical Notes
2590 @c ====================================================================
2591 @node Technical Notes, API Quick Reference, Conclusion, Top
2592 @appendix Technical Notes
2594 This chapter contains important information about the library's
2595 configuration, supported platforms, non-ANSI features and
2596 portability concerns.
2598 @menu
2599 * Configuration::               Pre-loading parameters
2600 * Non-ANSI Features::           Requiring operating system access
2601 * Supported Platforms::         Systems, compilers and dependencies
2602 * Dumping Executables::         Convenience wrappers
2603 * Not Dumping Executables::     Using Clon interactively
2604 @end menu
2607 @c -------------
2608 @c Configuration
2609 @c -------------
2610 @node Configuration, Non-ANSI Features, Technical Notes, Technical Notes
2611 @section Configuration
2612 @cindex Configuration
2613 @vindex com.dvlsoft.clon.configuration
2614 Some aspects of @clon{}'s behavior can be configured @emph{before} the
2615 ASDF system is actually loaded. @clon{} looks for configuration options
2616 in a variable called @code{com.dvlsoft.clon.configuration} in the
2617 @code{cl-user} package. If set, this variable should contain a property
2618 list of configuration options and their corresponding values. Currently,
2619 the following options are provided.
2621 @table @t
2622 @item :swank-eval-in-emacs
2623 @coindex{swank-eval-in-emacs}@c
2624 @vindex slime-enable-evaluate-in-emacs
2625 This option is only useful if you use Slime, and mostly if you plan on
2626 hacking @clon{} itself. The library provides indentation information for
2627 some of its functions directly embedded in the code. This information
2628 can be automatically transmitted to (X)Emacs when the ASDF system is
2629 loaded if you set this option to @code{t}. However, note that for this
2630 to work, the Slime variable @code{slime-enable-evaluate-in-emacs} must
2631 also be set to @code{t} in your (X)Emacs session. If you're interested
2632 to know how this process works, I have described it in the following
2633 blog entry:
2634 @uref{http://www.didierverna.com/sciblog/index.php?post/2011/07/20/One-more-indentation-hack}.
2635 @item :restricted
2636 @coindex{restricted}@c
2637 @cindex Restricted Mode
2638 Some non-ANSI features of @clon{} require external functionality that
2639 may not be available in all contexts. Normally, @clon{} should
2640 autodetect this and switch to so-called @emph{restricted mode} at
2641 build-time (@pxref{Non-ANSI Features}). If @clon{} has failed to
2642 autodetect the problem (in which case I would like to know), or if for
2643 some reason, you explicitly want to disable those features, you may set
2644 the @code{:restricted} configuration option to @code{t}.
2645 @item :dump
2646 @coindex{dump}@c
2647 This option is only used by the ABCL port. @ref{Dumping Executables},
2648 provides more information on its use.
2649 @end table
2652 @c -----------------
2653 @c Non-ANSI Features
2654 @c -----------------
2655 @node Non-ANSI Features, Supported Platforms, Configuration, Technical Notes
2656 @section Non-ANSI Features
2657 One feature of @clon{} that is beyond the ANSI standard is terminal
2658 autodetection (it requires an @code{ioctl} call and hence a foreign
2659 function interface). Terminal autodetection is used in several
2660 situations, for turning on highlighting automatically and for detecting
2661 a terminal line width.
2663 @cindex Restricted Mode
2664 If, for some reason, terminal autodetection is not available, @clon{}
2665 will work in so-called @emph{restricted mode}. This means that
2666 @bioption{highlight=auto} won't work (highlighting will @emph{not} be
2667 turned on automatically on a @tty{}). For the same reason, unless
2668 otherwise specified via either the @code{COLUMNS} environment variable
2669 or the @bioption{line-width} option, terminal output will be formatted
2670 for 80 columns regardless of the actual terminal width
2671 (@pxenduserref{Global Control}).
2674 @c ----------------------
2675 @c Supported Platforms
2676 @c ----------------------
2677 @node Supported Platforms, Dumping Executables, Non-ANSI Features, Technical Notes
2678 @section Supported Platforms
2679 @clon{} currently works on Unix (including MacOS X) and Windows (Cygwin
2680 or MinGW) and has been ported to 8 @cl{} implementations. The following
2681 table lists the supported platforms.
2683 @multitable {Compiler} {Minimum Version} {@code{cffi} (optional)}
2684 @headitem Compiler @tab Minimum Version @tab Dependencies
2685 @item SBCL
2686 @tab 1.0.56
2687 @tab
2688 @item CMU-CL
2689 @tab 20b
2690 @tab
2691 @item CCL
2692 @tab
2693 @tab
2694 @item ECL
2695 @tab 11.1.2@footnote{more precisely, git revision
2696 3e2e5f9dc3c5176ef6ef8d7794bfa43f1af8f8db}
2697 @tab
2698 @item CLISP
2699 @tab
2700 @tab @code{cffi} (optional)
2701 @item ABCL
2702 @tab 1.1.0@footnote{more precisely, svn trunk revision 140640}
2703 @tab
2704 @item Allegro@footnote{both standard and modern images are supported}
2705 @tab
2706 @tab @code{cffi} (optional)
2707 @item LispWorks
2708 @tab
2709 @tab @code{cffi} (optional)
2710 @end multitable
2712 @unnumberedsubsec CLISP, Allegro and LispWorks specificities
2713 @cindex Restricted Mode
2714 As mentioned in the above table, CLISP, Allegro and LispWorks dependency
2715 on @code{cffi} is optional. They need @code{cffi} in order to implement
2716 terminal autodetection only (note that many other implementations come
2717 with their own foreign function interface). If @code{cffi} cannot be
2718 found when the ASDF system is loaded (or in the case of CLISP, if it has
2719 been compiled without @code{ffi} support), you get a big red blinking
2720 light and a warning but that's all. @clon{} will still work, although in
2721 restricted mode.
2723 @unnumberedsubsec ABCL specificities
2724 @clon{}'s ABCL port currently has two limitations:
2725 @itemize @bullet
2726 @item
2727 @bioindex{highlight}@c
2728 @bioindex{line-width}@c
2729 @evindex{COLUMNS}@c
2730 @cindex Restricted Mode
2731 It only works in restricted mode (@pxref{Non-ANSI Features}).
2732 @item
2733 Since Java doesn't have a @code{putenv} or @code{setenv} function (!!),
2734 the @code{modify-environment} restart, normally proposed when an
2735 environment variable is set to a bogus value, is unavailable
2736 (@pxenduserref{Error Management}).
2737 @end itemize
2740 @c -------------------
2741 @c Dumping Executables
2742 @c -------------------
2743 @node Dumping Executables, Not Dumping Executables, Supported Platforms, Technical Notes
2744 @section Dumping Executables
2745 @cindex Dumping
2746 Creating standalone executables is orthogonal to @clon{}. @clon{} is
2747 just a library that you might want to use, and in fact, it is also
2748 possible to use it without dumping executables at all (@pxref{Not
2749 Dumping Executables}).
2751 @findex exit
2752 @findex dump
2753 Unfortunately, there is no standard way to dump executables from Lisp.
2754 We're entering the portability mine field here. @clon{}, however, wants
2755 to help. We've already seen that it provides utility wrappers like
2756 @code{exit} and @code{dump} to make your life easier (I mean, more
2757 portable) in @ref{Quick Start}. If you're not interested in portability
2758 or if you prefer to do it your own way, you don't @emph{need} to use
2759 those wrappers. If you do, however, please read on.
2761 Continuing on the quickstart example, the table below provides
2762 ready-to-use @cmdline{} samples for dumping the program with the
2763 compilers currently supported. Remember that they work in conjunction
2764 with the somewhat rudimentary @code{dump} macro mentionned above.
2766 @table @strong
2767 @item SBCL
2768 @code{CC=gcc sbcl --script quickstart.lisp}@*
2769 The @code{CC=gcc} bit is needed for the @code{sb-grovel} contrib module
2770 that @clon{} uses (unless restricted mode is requested).
2771 @item CMUCL
2772 @code{lisp -noinit -nositeinit -load quickstart.lisp}
2773 @item CCL
2774 @code{ccl --no-init --load quickstart.lisp}
2775 @item ECL
2776 ECL doesn't work like the other Lisp compilers. In particular, creating
2777 an executable does not involve dumping a Lisp image, but compiling the
2778 source into separate object files and then linking them. The consequence
2779 is that there is no simple @cmdline{} recipe to show here. Instead, you
2780 might want to look at the file @file{demos/dump.lisp} in the
2781 distribution for an example. Note that this file doesn't really attempt
2782 to dump the whole application. Only the actual example file is dumped.
2784 Because the dumping scheme is different with ECL, it is also less
2785 straightforward to write portable code for standalone applications. The
2786 demo programs in the distribution both contain comments that are worth
2787 reading at the top of them.
2789 @findex dump
2790 One specific difference between ECL and the other Lisp compilers is that
2791 it doesn't require you to specify a particular function as the entry
2792 point for your executable, but instead relies on having code to execute
2793 directly at the toplevel of some file. @clon{}'s @code{dump} macro helps
2794 you with this: it normally expands to a compiler-specific function which
2795 saves the current Lisp image, but for ECL, it simply expands to the
2796 ``main'' function call, hence consituting the entry point to the code
2797 that ECL needs.
2798 @item CLISP
2799 @code{CC=gcc clisp -norc -i quickstart.lisp}@*
2800 The @code{CC=gcc} bit lets you choose your preferred C compiler for
2801 @code{cffi}. Please note that executables dumped (the @clon{} way) by
2802 CLISP still understand lisp-specific @cmdline{} options when they are
2803 prefixed with @code{--clisp-}, so you should obviously avoid defining
2804 options by those names.
2805 @item ABCL
2806 ABCL is a totally different beast because it's a Java-based @cl{}
2807 implementation. Most notably, you don't create standalone executables in
2808 Java, so the normal way of running ABCL is by telling it to load some
2809 lisp code. If you want to run the quickstart program in the usual way,
2810 you will typically type this:
2811 @verbatim
2812 abcl --noinform --noinit --nosystem --load quickstart.lisp
2813 @end verbatim
2814 Note that for this to work, the @code{dump} macro expands to the
2815 ``main'' function call for ABCL, just as for ECL.
2817 There's more to it than that though. It is possible to get closer to
2818 standalone executables with ABCL by 1/ providing your whole application
2819 in a @code{jar} file directly, and 2/ overriding ABCL's entry point by
2820 providing your own interpreter which runs your main function
2821 automatically. I have described this process in more details in the
2822 following blog entry:
2823 @uref{http://www.didierverna.com/sciblog/index.php?post/2011/01/22/Towards-ABCL-Standalone-Executables}.
2825 @coindex{dump}@c
2826 @clon{} helps you to do this to some extend. If the @code{:dump}
2827 configuration option is set (@pxref{Configuration}), then the
2828 @code{dump} macro doesn't expand to a call to the ``main'' function, but
2829 instead dumps a Java file containing an alternate ABCL interpreter that
2830 you can compile and add to the original ABCL @code{jar} file, along with
2831 @file{quickstart.lisp}. If you want more details on this, you will need
2832 to look at the @file{Makefile} in the @code{demo} directory and also at
2833 the file @file{Makefile.inc} at the toplevel.
2834 @item Allegro
2835 @findex dumplisp
2836 Dumping a complete application with Allegro is complicated, but more
2837 importantly only possible in the Enterprise edition. Because of that,
2838 @clon{}'s dumping facility only makes use of the @code{dumplisp} feature
2839 which just dumps a Lisp image. You can perform this operation with a
2840 @cmdline{} such as @samp{alisp -qq -L quickstart.lisp}. The Makefile
2841 infrastructure in the @file{demo} directory also creates shell script
2842 wrappers around this image to simplify their use.
2843 @item LispWorks
2844 @code{lispworks -init - -siteinit - -load quickstart.lisp}@*
2845 Please note that dumping a complete application with LispWorks is only
2846 possible in the Professional or Enterprise editions.
2847 @end table
2850 @c -----------------------
2851 @c Not Dumping Executables
2852 @c -----------------------
2853 @node Not Dumping Executables, , Dumping Executables, Technical Notes
2854 @section Not Dumping Executables
2855 Although @cmdline{} processing really makes sense for standalone
2856 executables, you may want to preserve interactivity with your
2857 application during the development phase, for instance for testing or
2858 debugging purposes.
2860 It is possible to use @clon{} interactively, that is, within a regular
2861 Lisp REPL, without dumping anything. First of all, we have already seen
2862 that it is possible to use a virtual @cmdline{} (@pxref{Using Different
2863 Command-Lines}). You can also use @clon{} interactively with the actual
2864 Lisp invocation's @cmdline{}, although a word of advice is in order
2865 here.
2867 @findex cmdline
2868 @findex dump
2869 As you might expect, the problem in that situation lies in the way the
2870 different Lisp implementations treat their own @cmdline{}. Guess what,
2871 it's a mess. When you dump an executable the @clon{} way, the
2872 @code{cmdline} function will always contain user options only (the
2873 @code{dump} macro instructs the compilers to @emph{not} process the
2874 @cmdline{} at all). When you use @clon{} interactively and mix
2875 compiler-specific options with application ones when invoking your Lisp
2876 environment, the situation is as follows:
2878 @table @strong
2879 @item SBCL
2880 SBCL processes its own options and leaves the others unprocessed on the
2881 @cmdline{}. This means that as long as there is no overlap between
2882 SBCL's options and yours, you can just put them all together on the
2883 @cmdline{}. In case of overlap however, you need to separate SBCL's
2884 options from yours with a call to @code{--end-toplevel-options} (that's
2885 an SBCL specific option separator).
2886 @item CMUCL
2887 @cindex Command-Line, remainder
2888 @cindex Remainder, of command-line
2889 CMUCL processes its own options, issues a warning about the options it
2890 doesn't know about, but in any case, it eats the whole @cmdline{}.
2891 Consequently, if you want to provide options to your application, you
2892 need to put them after a @code{--} separator. Note that you can still
2893 use a second such separator to provide @clon{} with both some options
2894 and a remainder (@pxenduserref{Option Separator}).
2895 @item CCL
2896 @itemx ECL
2897 @itemx CLISP
2898 CCL, ECL and CLISP all process their own options but will abort on
2899 unknown ones. Consequently, if you want to provide options to your
2900 application, you need to put them after a @code{--} separator. Note that
2901 you can still use a second such separator to provide @clon{} with both
2902 some options and a remainder (@pxenduserref{Option Separator}).
2903 @item ABCL
2904 ABCL processes its own options and leaves the others unprocessed on the
2905 @cmdline{}. This means that as long as there is no overlap between
2906 ABCL's options and yours, you can just put them all together on the
2907 @cmdline{}. In case of overlap however, you need to separate ABCL's
2908 options from yours with a @code{--} separator. Note that you can still
2909 use a second such separator to provide @clon{} with both some options
2910 and a remainder (@pxenduserref{Option Separator}).
2911 @item Allegro
2912 Allegro processes its own options, issues only a warning about options
2913 it doesn't know of, and leaves anything after a @code{--} alone.
2914 Consequently, if you want to provide options to your application, you
2915 need to put them after a @code{--} separator. Note that you can still
2916 use a second such separator to provide @clon{} with both some options
2917 and a remainder (@pxenduserref{Option Separator}).
2918 @item LispWorks
2919 LispWorks processes its own options and ignores the other ones, but
2920 always leaves everything on the command-line. It does not currently
2921 support @code{--} as an option separator either. Consequently, if you
2922 want to provide options to your application, you need to put them after
2923 a @code{--} separator, although you @emph{will} get into trouble if any
2924 option there is recognized by LispWorks itself. Note that you can still
2925 use a second such separator to provide @clon{} with both some options
2926 and a remainder (@pxenduserref{Option Separator}).
2927 @end table
2931 @c ====================================================================
2932 @c API Quick Reference
2933 @c ====================================================================
2934 @node API Quick Reference, Indexes, Technical Notes, Top
2935 @appendix API Quick Reference
2937 @menu
2938 * Utilities::                   Miscellaneous stuff
2939 * Initialization Phase API::    Synopsis, items and context creation
2940 * Runtime Phase API::           Option retrieval and help formatting
2941 * Extension API::               New option types
2942 * Versioning API::              Release identification
2943 @end menu
2946 @c ---------
2947 @c Utilities
2948 @c ---------
2949 @node Utilities, Initialization Phase API, API Quick Reference, API Quick Reference
2950 @section Utilities
2952 @defmac dump NAME FUNCTION
2953 See @ref{Quick Start}.
2954 @end defmac
2956 @defun exit &optional (STATUS 0)
2957 See @ref{Quick Start}.
2958 @end defun
2960 @cindex Command-Line
2961 @defun cmdline
2962 See @ref{Option Retrieval}.
2963 @end defun
2965 @cindex Package, nicknames
2966 @defun nickname-package &optional NICKNAME
2967 See @ref{Quick Start}.
2968 @end defun
2971 @c ------------------------
2972 @c Initialization Phase API
2973 @c ------------------------
2974 @node Initialization Phase API, Runtime Phase API, Utilities, API Quick Reference
2975 @section Initialization Phase API
2977 @defun make-text &key CONTENTS HIDDEN
2978 @cfsubindex{make-text}
2979 @cfiaindex{make-text,:contents}
2980 @cfiaindex{make-text,:hidden}
2981 @defunx make-@var{OPTION} :INITARG INITVAL@dots{}
2982 @cfsubindex{make-@var{OPTION}}
2983 @cfindex make-flag
2984 @cfindex make-stropt
2985 @cfindex make-lispobj
2986 @cfindex make-enum
2987 @cfindex make-path
2988 @cfindex make-switch
2989 @cfindex make-xswitch
2990 @defunx make-group &key HEADER HIDDEN ITEM
2991 @cfsubindex{make-group}
2992 @cfiaindex{make-group,:header}
2993 @cfiaindex{make-group,:hidden}
2994 @cfiaindex{make-group,:item}
2995 @defunx make-synopsis &key POSTFIX ITEM (MAKE-DEFAULT t)
2996 @cfsubindex{make-synopsis}
2997 @cfiaindex{make-synopsis,:postfix}
2998 @cfiaindex{make-synopsis,:item}
2999 @cfiaindex{make-synopsis,:make-default}
3000 See @ref{Constructors} and @ref{Using Different Synopsis}.
3001 @end defun
3003 @defmac defgroup (&key HEADER HIDDEN) &body FORMS
3004 @foindex{defgroup,:header}
3005 @foindex{defgroup,:hidden}
3006 @xref{Group Definition}.
3007 @end defmac
3009 @defmac defsynopsis (&key POSTFIX MAKE-DEFAULT) &body FORMS
3010 @foindex{defsynopsis,:postfix}
3011 @foindex{defsynopsis,:make-default}
3012 @fiindex{defsynopsis,text}
3013 @fiindex{defsynopsis,options}
3014 @fiindex{defsynopsis,group}
3015 See @ref{Synopsis Definition} and @ref{Using Different Synopsis}.
3016 @end defmac
3018 @defopt *synopsis*
3019 @xref{Using Different Synopsis}.
3020 @end defopt
3022 @defun make-context &key (SYNOPSIS *synopsis*) CMDLINE @
3023 (MAKE-CURRENT t)
3024 @cfsubindex{make-context}
3025 @cfiaindex{make-context,:synopsis}
3026 @cfiaindex{make-context,:cmdline}
3027 @cfiaindex{make-context,:make-current}
3028 @xref{Context Creation}, @ref{Using Different Synopsis} and @ref{Using
3029 Different Command-Lines}.
3030 @end defun
3034 @c -----------------
3035 @c Runtime Phase API
3036 @c -----------------
3037 @node Runtime Phase API, Extension API, Initialization Phase API, API Quick Reference
3038 @section Runtime Phase API
3040 @defopt *context*
3041 @xref{Using Multiple Contexts}.
3042 @end defopt
3044 @defun with-context CONTEXT &body BODY
3045 @xref{Using Multiple Contexts}.
3046 @end defun
3048 @defun progname &key (CONTEXT *context*)
3049 @fkindex{progname,:context}
3050 See @ref{Contextual Information} and @ref{Using Multiple Contexts}.
3051 @end defun
3053 @defun remainder &key (CONTEXT *context*)
3054 @fkindex{remainder,:context}
3055 See @ref{Contextual Information} and @ref{Using Multiple Contexts}.
3056 @end defun
3058 @defun cmdline-options-p &key (CONTEXT *context*)
3059 @fkindex{cmdline-options-p,:context}
3060 See @ref{Command-Line Polling} and @ref{Using Multiple Contexts}.
3061 @end defun
3063 @defun cmdline-p &key (CONTEXT *context*)
3064 @fkindex{cmdline-p,:context}
3065 See @ref{Command-Line Polling} and @ref{Using Multiple Contexts}.
3066 @end defun
3068 @defun getopt &key (CONTEXT *context*) SHORT-NAME LONG-NAME @
3069 OPTION
3070 @fkindex{getopt,:context}
3071 @fkindex{getopt,:short-name}
3072 @fkindex{getopt,:long-name}
3073 @fkindex{getopt,:option}
3074 @vindex *context*
3075 See @ref{Explicit Retrieval} and @ref{Using Multiple Contexts}.
3076 @end defun
3078 @defun getopt-cmdline &key (CONTEXT *context*)
3079 @fkindex{getopt-cmdline,:context}
3080 @vindex *context*
3081 See @ref{Sequential Retrieval} and @ref{Using Multiple Contexts}.
3082 @end defun
3084 @defmac multiple-value-getopt-cmdline (OPTION NAME VALUE SOURCE &key CONTEXT) @
3085 &body BODY
3086 @defmacx do-cmdline-options (OPTION NAME VALUE SOURCE &key CONTEXT) @
3087 &body BODY
3088 @foindex{multiple-value-getopt-cmdline,:context}
3089 @foindex{do-cmdline-options,:context}
3090 See @ref{Sequential Retrieval} and @ref{Using Multiple Contexts}.
3091 @end defmac
3093 @deffn Reader short-name OPTION
3094 @rfsubindex{short-name}
3095 @deffnx Reader long-name OPTION
3096 @rfsubindex long-name
3097 @xref{Sequential Retrieval}.
3098 @end deffn
3100 @defun help &key (CONTEXT *context*) @
3101 (ITEM (synopsis context)) @
3102 (OUTPUT-STREAM *standard-output*) @
3103 (SEARCH-PATH (search-path context)) @
3104 (THEME (theme context)) @
3105 (LINE-WIDTH (line-width context)) @
3106 (HIGHLIGHT (highlight context)))
3107 @fkindex{help,:context}
3108 @fkindex{help,:item}
3109 @fkindex{help,:output-stream}
3110 @fkindex{help,:theme}
3111 @fkindex{help,:search-path}
3112 @fkindex{help,:line-width}
3113 @fkindex{help,:highlight}
3114 @vindex *context*
3115 @vindex *standard-output*
3116 @xref{Help}, @ref{Using Multiple Contexts} and @ref{Programmatic Help
3117 Strings}.
3118 @end defun
3121 @c -------------
3122 @c Extension API
3123 @c -------------
3124 @node Extension API, Versioning API, Runtime Phase API, API Quick Reference
3125 @section Extension API
3127 @defmac defoption CLASS SUPERCLASSES SLOTS &rest OPTIONS
3128 @pxref{New Option Classes}
3129 @end defmac
3131 @deffn {Generic Function} check OPTION VALUE
3132 @gfsubindex{check}
3133 @xref{Value Check Protocol}.
3134 @end deffn
3136 @deftp {Error Condition} option-error OPTION
3137 @ecsubindex{option-error}
3138 @ecsindex{option-error,option}
3139 @deftpx {Error Condition} invalid-value VALUE COMMENT
3140 @ecsubindex{invalid-value}
3141 @ecsindex{invalid-value,value}
3142 @ecsindex{invalid-value,comment}
3143 @xref{Value Check Protocol}.
3144 @end deftp
3146 @deffn {Generic Function} convert OPTION ARGUMENT
3147 @gfsubindex{convert}
3148 @xref{Argument Conversion Protocol}.
3149 @end deffn
3151 @deftp {Error Condition} invalid-argument ARGUMENT COMMENT
3152 @ecsubindex{invalid-argument}
3153 @ecsindex{invalid-argument,argument}
3154 @ecsindex{invalid-argument,comment}
3155 @xref{Argument Conversion Protocol}.
3156 @end deftp
3158 @deffn {Generic Function} stringify OPTION VALUE
3159 @gfsubindex{stringify}
3160 @xref{Value Stringification Protocol}.
3161 @end deffn
3164 @c --------------
3165 @c Versioning API
3166 @c --------------
3167 @node Versioning API, , Extension API, API Quick Reference
3168 @section Versioning API
3170 @defun version &optional (TYPE :number)
3171 @xref{Version Numbering}.
3172 @end defun
3174 @defvr Constant +release-major-level+
3175 @defvrx Constant +release-minor-level+
3176 @defvrx Constant +release-status+
3177 @defvrx Constant +release-status-level+
3178 @defvrx Constant +release-name+
3179 @xref{Version Numbering}.
3180 @end defvr
3184 @c ====================================================================
3185 @c Indexes
3186 @c ====================================================================
3187 @node Indexes, Acknowledgments, API Quick Reference, Top
3188 @appendix Indexes
3190 @menu
3191 * Concept Index::       Well, the concept index
3192 * Function Index::      Well, the function index
3193 * Variable Index::      Well, the variable index
3194 * Data Type Index::     Well, the data type index
3195 @end menu
3198 @c --------------
3199 @c Concept Index
3200 @c --------------
3201 @node Concept Index, Function Index, Indexes, Indexes
3202 @section Concepts
3203 @printindex cp
3204 @page
3207 @c --------------
3208 @c Function Index
3209 @c --------------
3210 @node Function Index, Variable Index, Concept Index, Indexes
3211 @section Functions
3212 @printindex fn
3213 @page
3216 @c --------------
3217 @c Variable Index
3218 @c --------------
3219 @node Variable Index, Data Type Index, Function Index, Indexes
3220 @section Variables
3221 @printindex vr
3222 @page
3225 @c ---------------
3226 @c Data Type Index
3227 @c ---------------
3228 @node Data Type Index, , Variable Index, Indexes
3229 @section Data Types
3230 @printindex tp
3234 @c ====================================================================
3235 @c Acknowledgments
3236 @c ====================================================================
3237 @node Acknowledgments, , Indexes, Top
3238 @appendix Acknowledgments
3239 The following people have contributed bug reports or fixes, suggestions,
3240 compiler support or any other kind of help. You have my gratitude!
3242 @multitable @columnfractions .99
3243 Alessio Stalla@*
3244 Antony @emph{something}@*
3245 Erik Huelsmann@*
3246 Erik Winkels@*
3247 François-René Rideau@*
3248 James Wright@*
3249 Martin Simmons@*
3250 Nikodemus Siivola@*
3251 Sam Steingold@*
3252 @end multitable
3255 @bye
3257 @c  LocalWords:  Clon clon cmdline Clonification tty emph CmdLine clonified SGR
3258 @c  LocalWords:  clonfiscated clonistified clonificated clonificationated samp
3259 @c  LocalWords:  cindex subsubsection pxref Didier Nuker postfix Runtime cth
3260 @c  LocalWords:  cartouche toplevel prepended IEC
3262 @c user.texi ends here