[plt-scheme] Scribble question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Feb 25 08:52:30 EST 2010

At Thu, 25 Feb 2010 09:02:15 +0100, Damir Ćavar wrote:
> is there a standardized way to document in Scribble the R6RS type of
> case-lambda optional parameters? Here is a concrete example:
> (define token-sequence->ngrams
>    (case-lambda
>      [(tokens)   (token-sequence->ngrams tokens 2)]
>      [(tokens n) (token-sequence->ngrams
>                      tokens n
>                      (make-hashtable equal-hash equal?))]
>      [(tokens n ngrams)
>       ...
> How would you document such cases of optional parameters, with @defproc,
> or in an alternative way? I can't find any example anywhere on the net?

You can supply a default value as the third part of an argument spec:

@defproc[(token-sequence->ngrams [tokens ???]
                                 [n exact-integer? 2]
                                 [ngrams hashtable?
                                         (make-hashtable equal-hash equal?)])

Posted on the users mailing list.