[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two bugs in reference implementation of SRFI 13

On Dec 24, 2011, at 3:40 PM, Taylor R Campbell wrote:

>   Date: Sat, 24 Dec 2011 20:48:10 +0100
>   From: Me
>   string-parse-start+end is documented to return three values:
>   "rest start end", but in make-kmp-restart-vector its result is bound
>   to two variables (start end). I found the same issue in
>   string-kmp-partial-search, which also attempts to capture only the
>   "start" and "end" values.
>   The fix in both places is to call string-parse-final-start+end  
> instead,
>   which strips off the first unwanted rest value from string-parse- 
> start
>   +end.
> Not quite.  The fix is to identify and use the intended definition of
> the name LET-OPTIONALS*.  With Olin's definition of LET-OPTIONALS*,
> such as you will find in scsh, or reimplemented with SYNTAX-RULES in
> more recent Scheme48, the use of STRING-PARSE-START+END is correct.
> It seems (a) he forgot to say what definition to use in the reference
> implementation, and (b) the authors of Kawa chose a different one.

I see. Actually, I wrote Kawa's, based on my (obviously incomplete)
understanding of how it was implicitly being used in the SRFI-13
reference implementation, so I guess it's an edge case I missed.
Thanks for pointing me to more authoritative implementations. It looks
like scsh's let-opt.scm has good documentation for the intended behavior
(and Scheme48's -- like most other let-optionals* I've found, including
my own -- comes with no documentation whatsoever).

So, for posterity: if you're trying to adopt SRFI 13, refer to the  
in scsh 0.6.7's let-opt.scm to see how your let-optionals* should  
work. The
important part here is:

;;; - A clause of the form ((var1 ... varn) external-arg-parser)  
allows you
;;;   to parse & arg-check a group of arguments together. EXTERNAL-ARG- 
;;;   is applied to the argument list. It returns n+1 values: one
;;;   for the leftover argument list, and one for each VARi.

Jamison Hope
The PTR Group